A Node.js tool that downloads GitHub repositories and generates LLM-optimized markdown documentation for easy code understanding with Claude and other AI assistants.
This tool is designed to:
- Clone GitHub repositories
- Analyze the codebase structure and relationships
- Generate a comprehensive markdown document optimized for Large Language Models
- Package the code in a format that's ideal for uploading to Claude conversations
- 🔍 Automatic code analysis and structure mapping
- 📊 Dependency relationship tracking
- 🗺️ Visual directory structure representation
- 💡 Intelligent component identification
- 🔗 Data flow visualization
- 📝 LLM-optimized markdown output
- 🎯 Special XML-style tags for better AI comprehension
# Clone the repository
git clone https://github.com/SurfSolana/github2claude.git
# Enter the directory
cd github2claude
# Install dependencies
pnpm i
# global usage
npm link
To use the tool, provide the GitHub repository URL as a command line argument:
npx github2claude https://github.com/username/repository
The tool will:
- Clone the specified repository to a temporary directory
- Analyze its structure
- Generate markdown files in a
g2c__username-repository/version
directory in your current working directory
For example, running npx github2claude https://github.com/SurfSolana/github2claude
will generate a documentation directory named something like g2c__SurfSolana-github2claude/1.0.0
.
The generated markdown includes:
- Repository metadata
- Project structure overview
- Directory tree
- Architecture analysis
- Component relationships
- Detailed code sections with analysis
Each section is wrapped in special tags for better AI comprehension:
<codebase_metadata>
Repository information
</codebase_metadata>
<project_structure>
Directory and component organization
</project_structure>
<architecture_analysis>
System design and relationships
</architecture_analysis>
<component_analysis>
Individual file analysis
</component_analysis>
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
- HTML/CSS
- Markdown
- YAML/JSON
- And many other text-based file formats
The tool can be configured by modifying the config
object in index.js
:
const config = {
tempDir: 'temp',
outputDir: 'output',
textFileExtensions: [...],
excludePatterns: [...]
};
The tool includes robust error handling for:
- Repository access issues
- File parsing errors
- TypeScript/JavaScript analysis
- Dependency resolution
- File system operations
- Node.js >=16
- NPM or Yarn
- Git installed on your system
- @babel/parser: Code parsing
- @babel/traverse: AST traversal
- @typescript-eslint/parser: TypeScript parsing
- simple-git: Git operations
- chalk: Terminal coloring
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this in your own projects!
This tool is designed specifically for use with Anthropic's Claude AI assistant, but can be used with other AI systems that process markdown.
If you see TypeScript version warnings, you can install a compatible version:
npm install typescript@~5.3.3
Some TypeScript files might show parsing warnings. These are handled gracefully and won't affect the overall output.
- Support for more programming languages
- Enhanced relationship mapping
- Custom tag system for different AI models
- Interactive mode
- Configuration file support
- Plugin system for custom analyzers