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 for the latest commit:
Expected output (truncated)
codefang (v2):
version: 0
hash: <unknown>
history/devs:
aggregate:
total_commits: 1
total_lines_added: 2
total_lines_removed: 0
total_developers: 1
active_developers: 1
developers:
- id: 0
name: alice
email: alice@example.com
commits: 1
lines_added: 2
lines_removed: 0
lines_changed: 0
net_lines: 2
languages:
- language: Go
added: 2
removed: 0
changed: 0
The --head flag
--head analyzes exactly one commit — HEAD, diffed against its first parent — and ignores --limit and --since. It is the same window --limit 1 selects, so the two produce identical reports. Use it for a fast snapshot of the latest change; drop it to walk the full history.
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:
-o names the output directory (required with --format plot). It receives index.html, one page per analyzer (burndown.html, devs.html) and report.json. Open the index in your browser:
7. Pipe into AI¶
Any --format json output is machine-friendly and can be fed to an LLM or an agent. Codefang also provides a Model Context Protocol server (codefang mcp) so agents can query analysis results programmatically; see the MCP Integration guide for how to wire it up.
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 |