ai-doc-gen
AI-powered multi-agent system that automatically analyzes codebases and generates comprehensive documentation. Features GitLab integration, concurrent processing, and multiple LLM support for better code understanding and developer onboarding.
Install / Use
npx skills add divar-ir/ai-doc-genInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
AutomationSupported Platforms
Our assessment of ai-doc-gen
ai-doc-gen scores 86/100 on our quality scale, 1783rd of 2,866 Automation skills we index.
Its SKILL.md is 8.8 KB long, well organised into 34 sections with 11 code examples: a thorough specification that gives an agent plenty to work with.
It has 769 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated about 4 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
- Our last check on 2026-10-18 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 98/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands (1 minor note below). An AI review of the same text found nothing harmful.
- noteInstalls by piping a downloaded script into a shellline 65
curl -LsSf https://astral.sh/uv/install.sh | sh
AI review by kimi-k2.7-code on 2026-09-24. Automated pattern scan on 2026-09-24. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
ai-doc-gen compared with similar skills
All 4 of these similar skills score higher than ai-doc-gen; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| ai-doc-gen (this skill)by divar-ir | 86 | 769 | 4mo ago | SKILL.md |
| Agent-Reachby Panniantong | 100 | 109.2k | today | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 78.9k | today | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 97.9k | today | MCP Server |
| crawl4aiby unclecode | 100 | 87.0k | 1d ago | MCP Server |
Frequently asked questions
- How do I install ai-doc-gen?
- Run
npx skills add divar-ir/ai-doc-gen. The install tabs above show the steps for each supported agent. - Which AI agents does ai-doc-gen work with?
- It is written for Claude Code, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is ai-doc-gen safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands (1 minor note below). An AI review of the same text found nothing harmful. It is MIT-licensed and scores 98/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is ai-doc-gen still maintained?
- The repository was last updated about 4 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
Skill content
View source on GitHubAI Documentation Generator
An AI-powered code documentation generator that automatically analyzes repositories and creates comprehensive documentation using large language models. The system employs a multi-agent architecture: five specialized analysis agents run concurrently to map a codebase's structure, dependencies, data flow, request flow, and APIs, and generation agents turn those analyses into a polished README.md and AI assistant configuration files (CLAUDE.md, AGENTS.md, .cursor/rules/). A GitLab cronjob mode discovers active projects and opens merge requests with fresh analysis automatically.
📝 Blog Posts
Read the full story behind this project:
- 🇺🇸 English: Docs That Don’t Rot: How Multi-Agent AI Rewrote Our Workflow
- 🇮🇷 از دستیار کدنویس تا همکار هوشمند؛ گام اول: کابوس مستندسازی
Table of Contents
Features
- Multi-Agent Analysis: Five specialized AI agents for code structure, data flow, dependency, request flow, and API analysis, writing reusable analysis documents to
.ai/docs/ - Automated Documentation: Generates comprehensive README files with configurable sections
- AI Assistant Configuration: Generates
CLAUDE.md,AGENTS.md, and.cursor/rules/*.mdcfiles for AI coding assistants - Claude Code Plugin & Skills: Ships as an installable Claude Code plugin with
analyze-codebase,generate-readme, andgenerate-ai-rulesskills (.claude-plugin/,skills/) - GitLab Integration: Cronjob mode discovers recently active GitLab projects, runs analysis, and opens merge requests
- Concurrent Processing: Parallel agent execution with a configurable worker pool (
ANALYZER_MAX_WORKERS, 0 = auto-detect CPU count) - Flexible Configuration: Layered configuration — Pydantic defaults,
.ai/config.yaml, then CLI flags - Multiple LLM Support: Works with any OpenAI-compatible API (OpenAI, Anthropic-compatible gateways, OpenRouter, local models, etc.), with per-agent model/endpoint settings
- Resilience: Agent-level retries plus an HTTP retry client with exponential backoff and
Retry-Aftersupport (handles 429s) - Observability: OpenTelemetry tracing via logfire with optional Langfuse integration
Installation
Using Skills (Claude Code)
This repository doubles as a Claude Code plugin — the easiest way to use it, no API keys or Python setup required. Install it from within Claude Code:
/plugin marketplace add divar-ir/ai-doc-gen
/plugin install ai-doc-gen@divar
This adds three skills that Claude Code invokes directly:
analyze-codebase— multi-agent analysis producing.ai/docs/documentsgenerate-readme— README generation from analysis or direct explorationgenerate-ai-rules—CLAUDE.md,AGENTS.md, and Cursor rules generation
Prerequisites
- Python 3.13
- Git
- API access to an OpenAI-compatible LLM provider
- Clone the repository:
git clone https://github.com/divar-ir/ai-doc-gen.git
cd ai-doc-gen
- Install using uv (recommended):
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
- Or install with pip:
pip install -e .
A Dockerfile and a Helm chart (k8s/helm/) are also provided for containerized and scheduled (Kubernetes CronJob) deployments.
Quick Start
- Set up your environment and configuration:
# Copy and edit environment variables (LLM API keys, base URLs, etc.)
cp .env.sample .env
# Copy and edit configuration
mkdir -p .ai
cp config_example.yaml .ai/config.yaml
- Run analysis and generate documentation:
# Analyze your repository
uv run src/main.py analyze --repo-path .
# Generate README documentation
uv run src/main.py generate readme --repo-path .
# Generate AI assistant configuration files (CLAUDE.md, AGENTS.md, .cursor/rules/)
uv run src/main.py generate ai-rules --repo-path .
Analysis documents are saved to .ai/docs/, and generated documentation and AI configuration files are placed in your repository root.
Usage
Available Commands
# Analyze codebase (structure, data flow, dependencies, request flow, APIs)
uv run src/main.py analyze --repo-path <path>
# Generate README documentation
uv run src/main.py generate readme --repo-path <path>
# Generate AI assistant configuration files
uv run src/main.py generate ai-rules --repo-path <path>
# Run cronjob (GitLab batch analysis)
uv run src/main.py cronjob analyze
The package also installs an ai-doc-gen console script exposing the same CLI.
Advanced Options
Analysis Options:
# Analyze with specific exclusions
uv run src/main.py analyze --repo-path . --exclude-code-structure --exclude-data-flow
# Limit concurrent analyzer agents
uv run src/main.py analyze --repo-path . --max-workers 2
# Use custom configuration file
uv run src/main.py analyze --repo-path . --config /path/to/config.yaml
README Generation Options:
# Generate with specific section exclusions
uv run src/main.py generate readme --repo-path . --exclude-architecture --exclude-c4-model
# Use existing README as context
uv run src/main.py generate readme --repo-path . --use-existing-readme
AI Rules Generation Options:
# Skip overwriting existing files
uv run src/main.py generate ai-rules --repo-path . \
--skip-existing-claude-md \
--skip-existing-agents-md \
--skip-existing-cursor-rules
# Customize detail level and line limits
uv run src/main.py generate ai-rules --repo-path . \
--detail-level comprehensive \
--max-claude-lines 600 \
--max-agents-lines 150
Cronjob Options:
# Only process projects with commits in the last N days
uv run src/main.py cronjob analyze --max-days-since-last-commit 14
Configuration
The tool automatically looks for configuration in .ai/config.yaml or .ai/config.yml in your repository. Precedence: Pydantic defaults < YAML file < CLI flags.
Configuration Options
- Exclude specific analyses: Skip code structure, data flow, dependencies, request flow, or API analysis
- Tune concurrency:
analyzer.max_workerscaps concurrent analyzer agents (0 = auto-detect CPU count) - Customize README sections: Control which sections appear in generated documentation
- AI rules behavior: Skip existing files, choose detail level (
minimal/standard/comprehensive), set line limits - Configure cronjob settings: Working path and commit recency filter
See config_example.yaml for all available options and .env.sample for environment variables (per-agent LLM models, timeouts, retry behavior, GitLab credentials, Langfuse keys).
Architecture
The system uses a multi-agent architecture with specialized AI agents for different types of code analysis and generation:
- CLI Layer (
src/main.py): argparse-based entry point; CLI flags are auto-generated from Pydantic config models - Handler Layer (
src/handlers/): command-specific orchestration implementing anAbstractHandlerinterface (analyze, generate readme, generate ai-rules, cronjob analyze) - Agent Layer (
src/agents/): pydantic-ai agents with YAML/Jinja2 prompt templatesAnalyzerAgent: coordinates 5 analysis agents through a worker poolDocumenterAgent: generates README.md from analysis documentsAIRulesGeneratorAgent: generates markdown rules (CLAUDE.md + AGENTS.md) and Cursor rules concurrently
- Tool Layer (
src/agents/tools/):FileReadTool(ranged file reading) andListFilesTool(filtered recursive listing) registered with every agent
Technology Stack
- Python 3.13 with pydantic-ai for AI agent orchestration
- OpenAI-compatible APIs for LLM access (
OpenAIChatModel+OpenAIProviderwith configurable base URL) - GitPython & python-gitlab for repository operations and GitLab automation
- logfire / OpenTelemetry & Langfuse for observability
- YAML + Jinja2 + Pydantic for prompts and configuration management
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with pydantic-ai for AI agent orchestration
- Supports multiple LLM providers through OpenAI-compatible APIs (including OpenRouter)
- Uses Langfuse for LLM observability
Related Skills
Agent-Reach
109.2kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
78.9kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Scrapling
97.9k🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
crawl4ai
87.0kOfficial Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
