Developer Tools Documentation 1 vues

FSoft-AI4Code/CodeWiki: Automated Documentation for Large Codebases

M
Mohamed IDBRAHIM
Auteur
FSoft-AI4Code/CodeWiki: Automated Documentation for Large Codebases

FSoft-AI4Code/CodeWiki: Automated Documentation for Large Codebases

Documentation is the first thing to rot in a growing codebase and the last thing teams want to write. For repositories spanning hundreds of thousands of lines across multiple languages, the problem becomes existential: new engineers struggle to onboard, architectural decisions get buried in commit history, and cross-module dependencies become tribal knowledge. FSoft-AI4Code/CodeWiki attacks this directly with an open-source framework for repository-level documentation generation that handles nine programming languages and produces both textual analysis and visual artifacts.

What is FSoft-AI4Code/CodeWiki?

FSoft-AI4Code/CodeWiki is an open-source Python↗ Bright Coding Blog framework (1,382 GitHub stars, 213 forks) developed by FPT Software's AI4Code research group. It was introduced in a 2025 paper accepted at ACL 2026 and targets a specific gap in developer tooling: automated generation of holistic documentation that captures not just individual functions but cross-file, cross-module, and system-level interactions.

The tool sits at the intersection of static analysis, LLM orchestration, and multi-modal output generation. Unlike simpler docstring generators or API documentation tools, CodeWiki performs hierarchical decomposition of entire repositories—tested on codebases from 86K to 1.4M lines of code—then dispatches adaptive multi-agent processes to document each module with architectural context preserved.

CodeWiki's relevance is tied to a genuine industry pain point. As organizations accumulate polyglot codebases—Python microservices calling Java libraries, TypeScript frontends communicating with C++ backends—the cost of maintaining accurate documentation scales poorly. Manual approaches fail; simple LLM prompts over individual files miss the forest for trees. CodeWiki's explicit design goal is preserving architectural context across decomposition boundaries, which is where naive approaches collapse.

The project is actively maintained with its last commit dated July 13, 2026. It carries an MIT license per its README badge, though the repository stats list the license as "Not specified"—a minor discrepancy developers should note when evaluating for enterprise use.

Key Features

Hierarchical Decomposition. CodeWiki uses dynamic programming-inspired algorithms to partition repositories into coherent modules. This isn't simple directory traversal; the system evaluates multiple granularity levels to preserve architectural relationships that would be severed by naive file-by-file processing. The --max-depth parameter (default: 2) controls decomposition depth, with deeper levels for more complex codebases.

Recursive Multi-Agent Processing. The system deploys adaptive agents with dynamic delegation capabilities. When a module exceeds token thresholds—configurable via --max-token-per-module (default: 36,369) and --max-token-per-leaf-module (default: 16,000)—the agent can spawn sub-tasks rather than truncating or hallucinating. This maintains documentation quality at repository scale where single-context LLM approaches fail.

Multi-Modal Output. Documentation includes Mermaid architecture diagrams, data flow visualizations, dependency graphs, and sequence diagrams alongside textual analysis. The --github-pages flag generates an interactive HTML viewer suitable for hosting. CodeWiki documents itself this way—its own generated docs are browseable at the project's GitHub Pages site.

Broad Language Support. Nine languages: Python, Java, JavaScript↗ Bright Coding Blog, TypeScript, C, C++, C#, Kotlin, and PHP↗ Bright Coding Blog. This polyglot coverage is unusual; most documentation tools specialize in one ecosystem.

Flexible LLM Backend. Supports OpenAI-compatible APIs, Anthropic, Azure OpenAI, AWS↗ Bright Coding Blog Bedrock, Atlas Cloud, and subscription modes via Claude Code and Codex CLIs. The latter routes calls through local claude/codex binaries using the caw library, enabling usage on existing subscriptions without per-token API costs.

Incremental Generation. The --update flag regenerates only changed modules since the last run, with --compare-to <commit-hash> for CI/CD scenarios with squashed commits.

Use Cases

Onboarding Acceleration. New engineers at organizations with 500K+ LOC codebases spend weeks building mental models. CodeWiki's generated overviews and cross-module interaction analysis compress this to days. The architecture diagrams and sequence diagrams specifically address the "how do these systems actually talk?" questions that consume senior engineer time.

Legacy Code Archaeology. Teams inheriting undocumented or poorly documented repositories—common in acquisitions or long-running projects—can generate baseline documentation to guide refactoring decisions. The --focus flag targets specific modules for deeper analysis while still generating high-level context for the full system.

Open Source Project Maintenance. Maintainers of popular libraries can offer CodeWiki-generated documentation as a starting point for contributors. The tool's self-documenting capability—CodeWiki generates its own docs—demonstrates this pattern.

Compliance and Audit Preparation. Organizations needing to document system architecture for security audits or regulatory requirements can use the --doc-type architecture output as a foundation, supplemented with --instructions for domain-specific emphasis.

CI/CD Integration. The --compare-to flag enables documentation checks in pull request pipelines: fail builds if merged code introduces undocumented public APIs or architectural changes.

Installation & Setup

CodeWiki requires Python 3.12+ and Node.js (for Mermaid diagram validation). Git is needed for branch creation features.

Install from source:

# Install from source
pip install git+https://github.com/FSoft-AI4Code/CodeWiki.git

# Verify installation
codewiki --version

Configure your LLM provider. The README documents seven provider configurations. Here are the most common:

# OpenAI-compatible (works with many providers)
codewiki config set \
  --provider openai-compatible \
  --api-key YOUR_API_KEY \
  --base-url https://api.anthropic.com \
  --main-model claude-sonnet-4 \
  --cluster-model claude-sonnet-4 \
  --fallback-model glm-4p5

# Anthropic direct
codewiki config set \
  --provider anthropic \
  --api-key YOUR_API_KEY \
  --base-url https://api.anthropic.com \
  --main-model claude-sonnet-4 \
  --cluster-model claude-sonnet-4 \
  --fallback-model glm-4p5

# Azure OpenAI
codewiki config set \
  --provider azure-openai \
  --api-key YOUR_AZURE_KEY \
  --base-url https://YOUR_RESOURCE.openai.azure.com \
  --azure-deployment YOUR_DEPLOYMENT \
  --main-model gpt-4o \
  --cluster-model gpt-4o

# Subscription mode: Claude Code (no API key needed)
# Requires `claude` CLI installed and logged in
codewiki config set \
  --provider claude-code \
  --main-model claude-sonnet-4-6 \
  --cluster-model claude-sonnet-4-6

Critical note on subscription mode: Model names are forwarded directly to claude --model / codex --model—use bare CLI names like gpt-5.4, not openai/gpt-5.4 or anthropic/claude-sonnet-4-6. If switching from openai-compatible, re-run config set for both --main-model and --cluster-model to clear stale prefixes; config set only updates keys you pass.

Validate configuration:

codewiki config validate

Real Code Examples

Basic Documentation Generation

Navigate to your project and generate documentation:

# Navigate to your project
cd /path/to/your/project

# Generate documentation
codewiki generate

# Generate with HTML viewer for GitHub Pages
codewiki generate --github-pages --create-branch

The --github-pages flag produces an interactive HTML viewer; --create-branch isolates documentation commits. Output lands in ./docs/ with overview.md as the entry point.

Customized Generation for Specific File Types

For a C# project, restrict analysis to .cs files and exclude test directories:

# C# project: only analyze .cs files, exclude test directories
codewiki generate --include "*.cs" --exclude "Tests,Specs,*.test.cs"

Important behavior: --include replaces default patterns entirely—*.cs means only .cs files. --exclude merges with defaults, so Tests,Specs adds to existing ignores like .git, node_modules, __pycache__. This distinction matters for predictable behavior.

Persistent Agent Configuration

Save preferred patterns as defaults to avoid repeating flags:

# Set include patterns for C# projects
codewiki config agent --include "*.cs"

# Exclude test projects by default (merged with default excludes)
codewiki config agent --exclude "Tests,Specs,*.test.cs"

# Set focus modules
codewiki config agent --focus "src/core,src/api"

# Set default documentation type
codewiki config agent --doc-type architecture

# View current agent settings
codewiki config agent

# Clear all agent settings
codewiki config agent --clear

This separates project-specific defaults from per-run overrides. The configuration stores API keys in system keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service) with fallback to ~/.codewiki/credentials.json in containers.

Incremental Update in CI/CD

# Incremental update (only regenerate changed modules since last run)
codewiki generate --update

# Override stored commit hash for squashed PRs
codewiki generate --compare-to <commit-hash>

The --compare-to flag is essential for CI pipelines where git merge --squash destroys the stored metadata commit reference.

Advanced Usage & Best Practices

Token Budgeting. The default --max-tokens 32768 suits Claude Sonnet 4 and GPT-4o class models. For smaller context windows or cost control, reduce to 16384. Increase --max-token-per-module (default: 36,369) for repositories with few large files; decrease for many small files to reduce clustering overhead.

Depth Tuning. Default --max-depth 2 handles most codebases. Increase to 3 for deeply nested monorepos; decrease to 1 for flat structures to reduce generation time.

Provider Selection. Atlas Cloud's coding plan offers budget-friendly access to 300+ models behind a single OpenAI-compatible endpoint. For teams already paying for Claude Pro/Max or Codex, subscription mode eliminates per-token costs entirely—though latency may increase due to local CLI invocation.

Mermaid Validation. Node.js dependency enables server-side diagram validation, catching syntax errors before deployment. Ensure node is in PATH; the README doesn't document offline fallback behavior.

Security Note. API keys default to system keychain. In CI/CD or containers, set CODEWIKI_NO_KEYRING=1 to force file-based storage and mount credentials appropriately.

Comparison with Alternatives

Tool Scope Languages Visual Output LLM Flexibility Open Source
FSoft-AI4Code/CodeWiki Repository-level 9 (Python, Java, JS, TS, C, C++, C#, Kotlin, PHP) Mermaid diagrams, HTML viewer Multiple providers + subscription mode Yes (MIT)
DeepWiki (GitHub-native) Repository-level Limited by GitHub Copilot support Basic GitHub Copilot only No
Sphinx + autodoc API-level Python primarily No N/A Yes
TypeDoc API-level TypeScript No N/A Yes

CodeWiki's distinctive advantages are repository-level scope (not just API surface), multi-language support, and visual artifact generation. Trade-offs: it requires active LLM usage (costs or subscription), Node.js for diagram validation, and Python 3.12+ which may exceed enterprise LTS distributions. DeepWiki offers tighter GitHub integration but lacks architectural analysis and provider flexibility. Traditional tools like Sphinx provide deterministic, cost-free output but cannot infer cross-module relationships or generate diagrams.

FAQ

What Python version is required? Python 3.12 or higher. The README explicitly states this; earlier versions are unsupported.

Is there a Docker↗ Bright Coding Blog deployment? Yes, documented at docker/DOCKER_README.md in the repository.

What license applies? The README badge states MIT, though repository metadata lists "Not specified." Verify LICENSE file directly for enterprise compliance.

Can I use this without API costs? Yes, via subscription mode with Claude Code or Codex CLI, routing through existing subscriptions.

How does incremental generation work? --update compares against stored commit hash in metadata.json; --compare-to overrides this for CI scenarios.

Does it support private repositories? The tool analyzes local filesystems; repository privacy is irrelevant to operation.

What is CodeWikiBench? The companion benchmark for evaluating repository-level documentation quality, available at FSoft-AI4Code/CodeWikiBench.

Conclusion

FSoft-AI4Code/CodeWiki addresses a genuine and underserved need: automated, architecture-aware documentation for large, polyglot codebases. Its hierarchical decomposition and recursive multi-agent design distinguish it from simpler docstring generators, while multi-modal output (text plus Mermaid diagrams) serves both quick reference and deep understanding.

The tool best suits teams with 100K+ LOC codebases in multiple languages, engineering organizations with documentation debt, and open-source maintainers seeking to lower contribution barriers. The requirement for LLM access—whether API or subscription—creates ongoing costs that smaller projects should weigh against benefits.

For teams already struggling with onboarding friction or architectural knowledge loss, CodeWiki offers a credible, research-backed approach. The self-documenting repository demonstrates the tool's capabilities directly.

Explore the code, read the ACL 2026 paper, and try it on your own codebase at https://github.com/FSoft-AI4Code/CodeWiki.


For related approaches to AI-assisted development workflows, see [INTERNAL_LINK: AI code review tools].

Commentaires 0

Aucun commentaire pour l'instant. Soyez le premier à réagir !

Laisser un commentaire