Quick Start¶
This page shows the fastest path to useful results. In five minutes you will parse code, run static analysis, and mine Git history.
Prerequisites
Make sure both codefang and uast are installed. See Installation if you have not set them up yet.
1. Parse Source Code into a UAST¶
Start by parsing a single file into a Universal Abstract Syntax Tree:
Expected output (truncated)
{
"language": "go",
"file": "main.go",
"root": {
"type": "SourceFile",
"roles": ["File"],
"children": [
{
"type": "PackageClause",
"roles": ["Package", "Declaration"],
"props": { "name": "main" }
},
{
"type": "FunctionDeclaration",
"roles": ["Function", "Declaration"],
"props": { "name": "main" },
"children": [ "..." ]
}
]
}
}
You can parse entire directories, force a language, or read from stdin:
uast parse --all # every source file in the codebase
uast parse -l python script.sh # force Python language detection
cat main.go | uast parse - # read from stdin
2. Static Analysis¶
Run structural analysis on a folder. The codefang run command with static/* analyzers walks the directory, parses every supported file, and computes metrics:
Expected output
Multiple static analyzers
Combine several analyzers in one pass:
3. History Analysis -- Burndown¶
Analyze how code ages and survives over your repository's lifetime:
Expected output (truncated)
Each row in project represents lines added in a given time window; each column shows how many of those lines survive into subsequent windows.
4. Developer Analysis¶
See per-developer contribution statistics with a single commit snapshot:
Expected output (truncated)
The --head flag
--head tells the history pipeline to analyze only the HEAD commit's state rather than walking the full history. It is much faster and useful for snapshot metrics like developer totals.
5. Run Everything at Once¶
Use glob patterns to run all history analyzers (or all analyzers) in a single invocation:
JSON output for scripting
JSON is the default format and the most machine-friendly. Pipe it into jq for quick exploration:
6. Interactive HTML Plots¶
Generate a self-contained HTML report with interactive charts:
This writes an HTML page to stdout. Redirect it to a file and open in your browser:
codefang run -a history/burndown --format plot . > burndown.html
open burndown.html # macOS
xdg-open burndown.html # Linux
7. Pipe into AI (MCP Integration)¶
Codefang ships a built-in Model Context Protocol server so AI agents can query analysis results programmatically:
This starts a JSON-RPC server that tools like Claude Desktop, Cursor, and other MCP-compatible clients can connect to. See the MCP Integration guide for configuration details.
AI-ready output
Any --format json output can also be fed directly to an LLM for summarization or code review:
What's Next?¶
| Goal | Page |
|---|---|
| Understand static vs. history analysis in depth | First Analysis |
| Learn every CLI flag | CLI Reference |
| Tune output formats | Output Formats |
Configure via .codefang.yaml | Configuration |
| Set up CI/CD pipelines | Docker & GitHub Actions |