GitHub Repository Analyzer
Analyze GitHub open-source repositories, generate structured Markdown analysis reports, and support synchronization to Notion.
Workflow
Initialization: Confirm Role
- Test whether you can connect to any of Open Code, Claude Code or Codex; if connection is successful, jump to step 3, otherwise execute step 2.
- If connection fails, please install the acpx plugin first, and test the connection to tools like Open Code, Claude Code or Codex via the acp protocol.
- Execute Step 1 to Step 5 as required below. Check the task status regularly and report to the user during the process. Step 6 is to be executed by you personally.
- If you are any of Open Code, Claude Code or Codex, please complete all tasks.
Step 1: Obtain Repository URL
Ask the user to provide the GitHub repository URL as needed. Format examples:
https://github.com/user/repo
Step 2: Clone Repository
- Create an analysis working directory in the current directory (named with a timestamp, e.g., )
- Create a subdirectory in this directory to store the cloned code
- Execute the command to clone the repository to the directory
- Verify the clone is successful (check that the directory is not empty)
Step 3: Obtain Analysis Requirements
Ask the user for specific analysis requirements, such as:
- "Analyze the overall architecture and module relationships"
- "Check code quality and potential issues"
- "Generate API interface documentation"
- "Analyze security vulnerabilities"
- "Evaluate test coverage"
- Or the user's custom requirements
Step 4: Analyze Repository
Perform in-depth analysis based on user requirements:
Analysis Strategy:
- First explore the repository structure (README, directory structure, main configuration files)
- Identify core modules and entry files
- Conduct in-depth analysis of relevant code according to user requirements
- Record key findings, patterns, and issues
Step 5: Generate Analysis Report
Create the following Markdown documents in the working directory (at the same level as
):
analysis-20240314-123045/
├── repo/ # Cloned repository code
├── reports/ # Analysis report directory
│ ├── 01-Topic1.md
│ ├── 02-Topic2.md
│ ├── 03-Topic3.md
│ └── 04-OtherUserRequestedTopics.md
└── notion-sync.log # Notion synchronization log (if notion sync script is enabled)
Report Content Specifications
01-Project Architecture Overview.md
- Basic project information (name, description, tech stack)
- Directory structure description
- Architecture pattern (MVC, microservices, layered architecture, etc.)
- Key components and their relationships
- Dependency diagram (described in text)
02-Code Quality Analysis.md
- Compliance with code specifications
- Potential bugs or issues
- Complexity analysis
- Test coverage (if available)
- Improvement suggestions
03-Core Module Description.md
- Functional description of main modules/packages
- Purpose of key classes/functions
- Data flow analysis
- Description of important algorithms or business logic
Step 6: Notion Synchronization (Optional)
- If it exists, ask the user whether to synchronize to Notion
- If the user agrees, use the script for synchronization
- Supports single file, directory, recursive directory upload
- Record synchronization logs to
Notion Sync Script Usage Instructions
Feature Characteristics:
- ✅ Single Markdown file upload
- ✅ Batch directory upload (automatically creates parent pages)
- ✅ Recursive directory upload (maintains hierarchical structure)
- ✅ Chunked upload (supports large files with more than 100 blocks)
- ✅ Full Markdown format support (code blocks, headings, lists, quotes, etc.)
- ✅ Query available pages ( command)
- ✅ Get page details ( command)
Usage Method:
bash
# Basic syntax
python3 scripts/notion_sync.py <command> [options]
# List all available pages
python3 scripts/notion_sync.py list
# Search for specific pages
python3 scripts/notion_sync.py list "My Project"
# Get page details
python3 scripts/notion_sync.py info <page_id>
# Upload file or directory
python3 scripts/notion_sync.py upload <path> <parent_page_id> [title]
Command Explanation:
| Command | Description | Example |
|---|
| List all available parent pages | python3 notion_sync.py list
|
| Search for specific pages | python3 notion_sync.py list "Reports"
|
| Get page details | python3 notion_sync.py info abc123...
|
| Upload Markdown file or directory | python3 notion_sync.py upload report.md abc123...
|
Examples:
bash
# 1. List all available pages
python3 scripts/notion_sync.py list
# 2. Search for specific pages
python3 scripts/notion_sync.py list "My Project"
# 3. Get page details
python3 scripts/notion_sync.py info 12345678-1234-1234-1234-123456789abc
# 4. Upload a single file
python3 scripts/notion_sync.py upload reports/01-Architecture.md 12345678-1234-1234-1234-123456789abc
# 5. Upload a single file and specify a title
python3 scripts/notion_sync.py upload reports/01-Architecture.md 12345678-... "Project Architecture Description"
# 6. Upload an entire directory (creates directory parent page, sub-content as sub-pages)
python3 scripts/notion_sync.py upload reports/ 12345678-... "Repository Analysis Report"
# 7. Specify parent page title when uploading directory
python3 scripts/notion_sync.py upload reports/ 12345678-... "My Analysis Reports"
Parameter Explanation:
- : Markdown file path or directory path (required)
- : Notion parent page ID (required)
- : Custom title (optional)
- Single file: Used as page title
- Directory: Used as directory parent page title, defaults to directory name
Notion Page Structure (Directory Upload):
When uploading a directory, the script will create a hierarchical structure:
reports/ # Local directory
├── 01-Architecture.md
├── 02-CodeQuality.md
├── 03-CoreModules.md
└── DetailedAnalysis/ # Subdirectory
├── DatabaseDesign.md
└── APIDesign.md
Notion Structure:
reports (parent page)
├── 01-Architecture (sub-page)
├── 02-CodeQuality (sub-page)
├── 03-CoreModules (sub-page)
└── DetailedAnalysis (sub-page, also parent page)
├── DatabaseDesign (sub-sub-page)
└── APIDesign (sub-sub-page)
Supported Markdown Formats:
- Headings: , , ,
- Code blocks: (auto-detects language)
- Unordered lists: or
- Ordered lists: ,
- Blockquotes:
- Horizontal rules: or
- Regular paragraphs
Chunked Upload Mechanism:
Notion API limits a maximum of 100 blocks per request. For large files, the script will automatically:
- Create an empty page
- Append blocks in batches (up to 100 blocks each time)
- Supports Markdown files of unlimited size
API Configuration:
- API Version:
- Authentication Method: Bearer Token
- Configuration File:
Error Handling:
- API Key does not exist: Returns
{"success": false, "error": "..."}
- Path does not exist: Returns error message
- Single file is not .md format: Returns error
- API call fails: Records to array, continues processing other files
Output Format:
The script returns results in JSON format:
json
{
"success": true,
"synced_files": ["/path/to/file1.md", "/path/to/file2.md"],
"errors": [],
"pages_created": [
{
"type": "directory",
"path": "/path/to/reports",
"notion_page_id": "xxx",
"url": "https://notion.so/xxx"
},
{
"type": "file",
"file": "/path/to/file1.md",
"notion_page_id": "xxx",
"url": "https://notion.so/xxx",
"parent_directory": "reports"
}
]
}
Technical Details:
For script architecture, core function explanations, and extended development guidelines, see
references/notion-sync.md
.
Step 7: Cleanup (Optional)
Ask the user whether to delete the cloned repository:
- If the user chooses to delete, delete the directory but keep
- If the user chooses to keep, inform them of the full path
Important Notes
- Report Storage Location: Analysis reports must be placed in the directory at the same level as , not inside the repository
- Repository Path: Always use the
/github-analysis/analysis-<timestamp>/
structure
- Error Handling:
- If clone fails (network issue, repository does not exist, permission issue), prompt the user and exit
- If analysis tools are unavailable, ask the user whether to use tools from the current session for analysis
- If Notion synchronization fails, record the error but do not interrupt the process
- Large Repository Handling: If the repository has more than 10,000 files, inform the user that analysis may take a long time
- Sensitive Information: If sensitive information such as API keys or passwords is found in the analysis report, remind the user to pay attention
Output Example
After analysis is completed, report to the user:
✅ Repository analysis completed!
📁 Analysis report location: /github-analysis/analysis-20240314-123045/reports/
📄 Generated files:
- 01-Project Architecture Overview.md
- 02-Code Quality Analysis.md
- 03-Core Module Description.md
📊 Analysis Summary:
- Tech Stack: Python/FastAPI + React
- Code Files: 127
- Main Issues: 3 potential issues found, see Code Quality Analysis report for details
🔄 Notion Synchronization: Synced to https://notion.so/xxx (if applicable)
❓ Delete cloned repository? (y/n)
Tool Check
Before starting analysis, check if the following tools are available:
bash
# Check git
command -v git &> /dev/null && echo "git: OK" || echo "git: MISSING"
# Check opencode
command -v opencode &> /dev/null && echo "opencode: OK" || echo "opencode: NOT FOUND"
# Check claude CLI
command -v claude &> /dev/null && echo "claude: OK" || echo "claude: NOT FOUND"
# Check codex
command -v codex &> /dev/null && echo "codex: OK" || echo "codex: NOT FOUND"
# Check Notion API key
[ -f ~/.config/notion/api_key ] && echo "notion: CONFIGURED" || echo "notion: NOT CONFIGURED"