Agent skill
repo2txt
Convert code repositories to formatted text for LLM analysis. Use when the user wants to send code to Gemini, Claude, or other LLMs for debugging, code review, or analysis. Triggers on phrases like "convert code to text", "repo to text", "format code for LLM", "send code to Gemini", or when analyzing code structure and contents for LLM consumption.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/repo2txt
SKILL.md
Repo2txt
Overview
This skill converts local code repositories into a formatted text file suitable for sending to LLMs like Gemini, Claude, or ChatGPT. It's similar to https://repo2txt.simplebasedomain.com/ but runs locally, giving you full control over file selection and formatting.
Quick Start
Basic Usage
Convert a repository to text and display in terminal:
python3 scripts/repo2txt.py /path/to/repo
Save to a file:
python3 scripts/repo2txt.py /path/to/repo -o output.txt
Filter by Extensions
Only include specific file types:
python3 scripts/repo2txt.py /path/to/repo -e .py,.js,.ts
Exclude certain extensions:
python3 scripts/repo2txt.py /path/to/repo -x .test.js,.spec.ts
Common Scenarios
Debug a specific module:
python3 scripts/repo2txt.py ./src/components -e .tsx,.ts -o component_debug.txt
Analyze backend API:
python3 scripts/repo2txt.py ./src/api -e .py -o api_analysis.txt
Review configuration files:
python3 scripts/repo2txt.py . -e .json,.yaml,.yml,.toml -o config_review.txt
Output Format
The generated text file includes three sections:
- Repository Summary: File counts, total lines, breakdown by file type
- Directory Structure: Tree visualization of the file hierarchy
- File Contents: Each file with its path, type, and full content
Example output structure:
================================================================================
REPOSITORY SUMMARY
================================================================================
Total Files: 42
Total Lines: 3,456
Total Size: 128.5 KB
Files by Type:
TypeScript: 25
JavaScript: 10
JSON: 5
CSS: 2
================================================================================
DIRECTORY STRUCTURE
================================================================================
└── src
├── components
│ ├── Button.tsx
│ └── Card.tsx
└── utils
└── helpers.ts
================================================================================
FILE CONTENTS
================================================================================
--------------------------------------------------------------------------------
File: src/components/Button.tsx
Type: React/TS
--------------------------------------------------------------------------------
[file content here]
Options Reference
| Option | Description | Example |
|---|---|---|
-o, --output |
Output file path | -o analysis.txt |
-e, --extensions |
Include only these extensions | -e .py,.js |
-x, --exclude-extensions |
Exclude these extensions | -x .test.js |
-i, --ignore |
Additional ignore patterns | -i temp,*.bak |
--no-tree |
Skip directory tree | --no-tree |
--no-summary |
Skip summary section | --no-summary |
--max-file-size |
Max file size in bytes | --max-file-size 500000 |
Default Ignore Patterns
The following are automatically ignored:
- Version control:
.git,.svn,.hg - Dependencies:
node_modules,vendor,__pycache__, virtual environments - Build outputs:
dist,build,target,.next,.nuxt - IDE files:
.idea,.vscode - Lock files:
package-lock.json,yarn.lock,poetry.lock, etc. - Binary files: images, fonts, videos, archives
- Large data files: CSV, large JSON files
Resources
scripts/
- repo2txt.py: Main script for converting repositories to formatted text. Supports filtering by extensions, custom ignore patterns, and various output options.
Usage Tips
-
For Gemini/Claude: Most LLMs have context limits. If your repo is large, filter to specific directories or file types.
-
Focus on relevant code: Use
-eto include only the file types relevant to your question. -
Skip generated files: The default ignore patterns handle most build artifacts and dependencies.
-
Copy to clipboard (macOS):
bashpython3 scripts/repo2txt.py . -e .py | pbcopy -
Copy to clipboard (Linux):
bashpython3 scripts/repo2txt.py . -e .py | xclip -selection clipboard
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?