A tool to analyze GitHub repositories and create a knowledge graph using Neo4j, optimized for AI coding agents.
- Extracts repository structure (files, directories, functions, classes)
- Analyzes commit history and author relationships
- Creates relationships between code elements
- Exports to LLM-readable format for AI coding agents
- Identifies API patterns, database connections, and error handling
Create a .env file or set these environment variables:
# GitHub Personal Access Token
# Get this from: https://github.com/settings/tokens
export GITHUB_TOKEN="your_github_token_here"
# Neo4j Database Credentials
export NEO4J_USER="neo4j"
export NEO4J_PASSWORD="your_neo4j_password_here"Start a Neo4j instance using Docker:
docker run \
--name neo4j \
-p7474:7474 -p7687:7687 \
-d \
-v $HOME/neo4j/data:/data \
-v $HOME/neo4j/logs:/logs \
-v $HOME/neo4j/import:/var/lib/neo4j/import \
-v $HOME/neo4j/plugins:/plugins \
--env NEO4J_AUTH=neo4j/your_password_here \
neo4j:latestuv sync- Update the
REPO_URLinmain.pyto point to your target repository - Run the script:
uv run main.py- The script will:
- Clear any existing graph data
- Fetch repository structure from GitHub API
- Parse Python files for functions and classes
- Clone the repository to analyze commit history
- Create a knowledge graph in Neo4j
- Export to
knowledge_graph_export.txtfor AI analysis
The tool generates:
- Neo4j Graph Database: Interactive graph with nodes and relationships
- LLM-readable Export: Text file optimized for AI coding agents with:
- Project overview and entry points
- Code architecture (functions, classes, relationships)
- API patterns and interfaces
- Error handling patterns
- Development activity and hotspots
- Codebase metrics and complexity analysis
Edit these variables in main.py:
REPO_URL: GitHub API URL for the repository to analyzeNEO4J_URI: Neo4j connection string (default: bolt://localhost:7687)LOCAL_REPO_PATH: Temporary directory for cloning (default: ./temp_repo)OUTPUT_FILE: Path for LLM-readable export (default: ./knowledge_graph_export.txt)
# Public repositories
REPO_URL = "https://api.github.com/repos/openai/codex"
REPO_URL = "https://api.github.com/repos/microsoft/vscode"
REPO_URL = "https://api.github.com/repos/python/cpython"
# Private repositories (requires appropriate token permissions)
REPO_URL = "https://api.github.com/repos/your-org/your-private-repo"-
Environment Variables Not Set
ValueError: GITHUB_TOKEN environment variable is requiredSolution: Set the required environment variables as shown above.
-
Neo4j Connection Failed
ServiceUnavailable: Failed to establish connectionSolution: Ensure Neo4j is running and accessible at the configured URI.
-
GitHub API Rate Limits
403 ForbiddenSolution: Use a GitHub Personal Access Token with appropriate permissions.
-
Repository Access Denied
404 Not FoundSolution: Ensure the repository exists and your token has access to it.
MIT License