github-repo-analyzer

Original🇨🇳 Chinese
Translated
2 scriptsChecked / no sensitive code detected

Analyze the source code of GitHub open-source repositories and generate structured analysis reports. Supports generating reports such as project architecture overview, code quality analysis, core module description, etc., and optional synchronization to Notion.

2installs
Added on

NPX Install

npx skill4agent add 4444zyf/skills github-repo-analyzer

SKILL.md Content (Chinese)

View Translation Comparison →

GitHub Repository Analyzer

Analyze GitHub open-source repositories, generate structured Markdown analysis reports, and support synchronization to Notion.

Workflow

Initialization: Confirm Role

  • If you are openclaw:
  1. 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.
  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.
  3. 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
  • github.com/user/repo
  • user/repo

Step 2: Clone Repository

  1. Create an analysis working directory in the current directory (named with a timestamp, e.g.,
    analysis-20240314-123045
    )
  2. Create a
    repo/
    subdirectory in this directory to store the cloned code
  3. Execute the
    git clone
    command to clone the repository to the
    repo/
    directory
  4. 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:
  1. First explore the repository structure (README, directory structure, main configuration files)
  2. Identify core modules and entry files
  3. Conduct in-depth analysis of relevant code according to user requirements
  4. 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
repo/
):
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)

Check if
~/.config/notion/api_key
exists:
  • If it exists, ask the user whether to synchronize to Notion
  • If the user agrees, use the
    scripts/notion_sync.py
    script for synchronization
  • Supports single file, directory, recursive directory upload
  • Record synchronization logs to
    notion-sync.log

Notion Sync Script Usage Instructions

Script Location:
scripts/notion_sync.py
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 (
    list
    command)
  • Get page details (
    info
    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:
CommandDescriptionExample
list
List all available parent pages
python3 notion_sync.py list
list <query>
Search for specific pages
python3 notion_sync.py list "Reports"
info <page_id>
Get page details
python3 notion_sync.py info abc123...
upload <path> <page_id>
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:
  • path
    : Markdown file path or directory path (required)
  • parent_page_id
    : Notion parent page ID (required)
  • title
    : 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:
    language ... 
    (auto-detects language)
  • Unordered lists:
    - 
    or
    * 
  • Ordered lists:
    1.
    ,
    2.
  • 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:
  1. Create an empty page
  2. Append blocks in batches (up to 100 blocks each time)
  3. Supports Markdown files of unlimited size
API Configuration:
  • API Version:
    2022-06-28
  • Authentication Method: Bearer Token
  • Configuration File:
    ~/.config/notion/api_key
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
    errors
    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
    repo/
    directory but keep
    reports/
  • If the user chooses to keep, inform them of the full path

Important Notes

  1. Report Storage Location: Analysis reports must be placed in the
    reports/
    directory at the same level as
    repo/
    , not inside the repository
  2. Repository Path: Always use the
    /github-analysis/analysis-<timestamp>/
    structure
  3. 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
  4. Large Repository Handling: If the repository has more than 10,000 files, inform the user that analysis may take a long time
  5. 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"