Skip to content
/ stm Public

A command-line utility that intelligently converts your codebase into a single Markdown file, formatted for providing context to Large Language Models (LLMs)

License

Notifications You must be signed in to change notification settings

blasferna/stm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stm - Source to Markdown

License: MIT

A command-line utility that intelligently converts your codebase into a single Markdown file, perfectly formatted for providing context to Large Language Models (LLMs).

Overview

stm helps you prepare your code for LLM interactions by:

  • Converting multiple source files into a well-formatted Markdown document
  • Respecting .gitignore rules to exclude irrelevant files
  • Allowing explicit ignoring of files and directories via --ignore
  • Detecting binary files and excluding them from output
  • Automatically selecting appropriate language syntax highlighting
  • Supporting glob patterns to easily specify target files

This is particularly useful when you need to provide code context to AI assistants like ChatGPT, Claude, or GitHub Copilot.

Installation

You need uv installed for the simplest installation:

uv tool install git+https://github.com/blasferna/stm.git

Usage

stm [paths...] [-o OUTPUT] [--project-root PROJECT_ROOT] [--no-gitignore] [--ignore IGNORE [IGNORE ...]] [--verbose]

Basic Examples

# Convert entire current directory to stdout
stm

# Convert specific directory to a file
stm src -o context.md

# Convert multiple specific files
stm src/main.py tests/test_utils.py -o llm_context.md

# Use glob patterns to select files
stm "src/**/*.py" "tests/unit/**/*.py" -o context.md

# Ignore specific files or folders
stm src --ignore "src/config.py" "src/temp_data/" -o context.md

# Pipe output to clipboard (macOS)
stm "src/**/*.py" | pbcopy

# Pipe output to clipboard (Linux with xclip)
stm "src/**/*.py" | xclip -selection clipboard

# Pipe output to clipboard (Windows)
stm "src/**/*.py" | clip

Command Line Options

Option Description
paths Paths to process (files, directories, or glob patterns like src/**/*.py). Default: current directory .
-o, --output OUTPUT Output Markdown file. If not specified, prints to stdout.
--project-root PROJECT_ROOT Specify the project root directory. .gitignore files are processed relative to this. Default: current working directory.
--no-gitignore Disable .gitignore file processing.
--ignore IGNORE [IGNORE ...] List of files or directories to explicitly ignore. Supports glob patterns (e.g., *.log, build/, src/generated/**). Paths are processed relative to the current working directory or can be absolute. Explicitly ignored items take precedence over other inclusion rules (like .gitignore).
--verbose, -v Print verbose output, like skipped files.

Features

  • Smart File Filtering: Automatically excludes binary files, respects .gitignore rules, and allows for explicit ignores.
  • Language Detection: Automatically adds language identifiers for syntax highlighting.
  • Path Preservation: Maintains original file paths in the output for context.
  • Cross-Platform: Works consistently across operating systems.
  • Flexible Input: Accept individual files, directories, or glob patterns.

Use Cases

  • Prepare codebase snapshots for LLM conversations
  • Generate documentation-ready code listings
  • Create shareable code overviews
  • Prepare code context for AI pair programming

License

MIT License - see the LICENSE file for details.

Author

Blas Isaias Fernández (@blasferna)

About

A command-line utility that intelligently converts your codebase into a single Markdown file, formatted for providing context to Large Language Models (LLMs)

Topics

Resources

License

Stars

Watchers

Forks

Languages