FeatureGraph ⚡
AST-indexed feature topology maps for AI coding agents: exact line spans, inferred call edges, and a contract gate for changes. Zero runtime dependencies.
🎯 The Problem
- No caller visibility: An AI coding agent editing a function cannot see who calls it across files. Unreferenced-looking helpers and security gates get deleted, and downstream callers break.
- Context spend: Pasting whole files every turn costs tokens and pushes relevant code out of the window.
- Coarse graphs: Many graph tools produce file-level nodes, so the agent still has to open the file.
- No change gate: Nothing tells the agent which endpoints, auth boundaries, invariants, and tests a change touches.
FeatureGraph addresses these with a small index of named features, exact line ranges, deterministic call edges, and two commands built for the edit loop: impact and check.
⚡ How It Works
AI Coding Agent / Developer
│
▼
[1. Read .featuregraph/manifest.json] ──> Tier-1: category -> feature names
│
▼
[2. Read categories/<category>.json] ──> Tier-2: exact #Lstart-Lend per feature
│
▼
[3. Edit only that span] ──> impact <id> first, impact --diff after
│
▼
[4. Commit] ──> pre-commit hook rescans the index
The index is generated in two passes:
- Symbol indexing: parse every supported file, map tagged declarations to feature IDs, and assign deterministic symbol IDs (bare when unique, path-qualified on collision).
- Dependency inference: walk each feature's span, collect call sites, decorators, class bases, dependency-injection arguments, imports, JSX tags, and inheritance, then wire
depends_on/called_by.
Inference is textual/AST based, not a full type-checker. It resolves names by path affinity (same file > same directory > longest shared path); equally-near candidates are all kept rather than dropping the edge.
📦 Index Layout
| Artifact | Contents |
|---|---|
.featuregraph/manifest.json |
Tier-1 directory: category -> feature IDs and names, plus _meta |
.featuregraph/categories/<category>.json |
Tier-2 map: locations (file, lines), dependencies, contract tags |
.featuregraph/index.json |
Full graph (features + _meta) |
.featuregraph/graph.md |
Markdown table and Mermaid dependency diagram |
.featuregraph/unindexed.json |
Files that failed to parse (Python AST syntax errors, brace-unbalanced JS/TS files, or read errors) |
AGENTS.md |
Agent short-circuit directive (read the manifest first) |
.git/hooks/pre-commit |
Rescans and stages .featuregraph/ when it is not gitignored |
_meta.tree_hash is a SHA-256 over sorted (relative path, file bytes) plus .featureignore. Content hashing means a touch or a checkout without edits is a no-op, and a same-size edit is still detected. query/search refuse stale results unless --force is passed.
_meta.status is ok (everything parsed), partial (some files yielded no named symbols), or empty (no features). A Python AST syntax error or a brace-unbalanced JS/TS file is the only thing that makes the manifest unreliable, reported as unparsed_syntax_errors > 0. Files indexed at file granularity (tests, scripts, configs) are reported separately as _meta.file_level_files and do not invalidate the manifest.
🧠 Dependency Resolution
- Python: AST call sites, decorator references, class bases, and dependency-injection wrappers (
Depends,Security,Body,Header,Cookie). Import aliases (import x as y,from m import a as b) resolve to the original symbol. - TypeScript / JavaScript: call sites, JSX component tags,
extends/implements, ESimportbindings, and CommonJSrequire()bindings from the code-only view (strings and comments masked). - Other languages: call sites, inheritance, and route patterns from a lexed code-only view.
- Manual edges:
@depends [ID]/@depends_on [ID]add explicit edges; dangling references are reported asunresolved_depends. - Containment guard: a tagged method inside a tagged class does not create a fake class <-> method cycle from overlapping spans alone.
Isolated features (no dependencies, no callers) are listed in graph.md for dead-code review.
🏷️ Tag Rules & Coverage
Tags count only on a real comment line. Every parser, the annotator, and dependency inference share one lexical mask, so a tag inside a string, template literal, or Python docstring can never create a feature. Real comment lines are honoured in every language, including //, #, and /* ... */.
| Language | Tag placement | Symbol window |
|---|---|---|
| Python | Comment above def / class |
6 lines above |
| TypeScript / JS | Comment above the export | 6 lines below the tag |
| Go, Rust, Java, C#, PHP, Ruby, Swift, Dart, Shell | Comment above the declaration | 6 lines below the tag |
Line spans
- Python: exact, from the AST (
lineno..end_lineno). - TypeScript / JS: the tag attaches to the export within 6 lines below it. The end line is found by brace-matching from the declaration's opening brace on the masked view, so braces in strings, comments, and template literals cannot close the block early.
const X = () => (JSX arrows track balanced parentheses the same way. A fixed 35-line fallback is used only when no block brace is found (single-line or unbraced expressions). - Other languages: brace matching (or
def/endcounting for Ruby) from the declaration.
Untagged coverage
| Source | Auto feature IDs |
|---|---|
Untagged .js |
CJS-<path>-<symbol> for classes, functions, arrow functions, class/prototype methods, and exports/module.exports members |
Untagged .ts / .tsx / .jsx |
TS-<path>-<symbol> for exported declarations |
Untagged Django models.py (or any class with a Django model base) |
MODEL-<path>-<symbol> |
Untagged Django settings.py (UPPER_CASE names) |
CONFIG-<path>-<symbol>; sensitive key names (SECRET, PASSWORD, TOKEN, API_KEY, PRIVATE_KEY, DATABASE_URL, CREDENTIAL) are redacted and never emit values |
| Any supported file with no named symbols | FILE-<path> file-level entry (counted in _meta.file_level_files) |
Tagged files keep tag-only behavior, so adding explicit tags never churns existing IDs or inferred edges.
featuregraph annotate suggests tags for un-annotated symbols, refuses insertion points that are not code, writes atomically, and re-parses every write; a tag that would not round-trip restores the original file.
🔐 Contract Tags & Anti-Slop Workflow
Three additional comment-only tags describe the contracts a change must not break:
# @feature [BILLING-CHARGE] Charge endpoint
# @boundary [auth, tenant]
# @invariant Amounts stay in integer cents; never charge twice for one idempotency key.
# @test tests/test_billing.py::test_charge_is_idempotent, tests/test_billing.py::test_amount_rounding
@router.post("/charge")
def charge(...):
...
@boundary [a, b]— security boundary the feature sits behind. Normalised lowercase, stored asboundaries.@invariant <text>— repeatable rule to preserve. Stored underinvariants.@test <path>::<nodeid>— repeatable test selector (single value or comma/space separated list). Stored undertests.
Empty values are omitted from the JSON. featuregraph impact reports them; featuregraph check --strict enforces boundaries on endpoints.
Before editing shared code:
featuregraph impact <feature_id> # callers, endpoints, boundaries, invariants, tests
After editing:
featuregraph impact --diff # verify the blast radius of the change
featuregraph check --strict
Prints touched features, transitive downstream callers, affected_endpoints, boundaries crossed, invariants to preserve, and tests to run. Add --json for agents, or --staged to inspect staged changes instead of the working tree.
Before declaring a task complete:
featuregraph check --strict
Exit 0 = pass, exit 1 = fail. Always fails when the index is missing, corrupt, or stale, or when there are syntax errors, unresolved @depends, or duplicate feature IDs. --strict also fails on dependency cycles and on any endpoint (ROUTE-* / type: endpoint) with no @boundary and no dependency on an auth/admin/tenant/internal guarded feature. Mark intentionally public routes @boundary [public].
🚨 Scan Warnings
Warnings are aggregated to one line each per scan:
⚠ 6 file(s) with no parseable features (untagged, unreadable, or syntax error): src/legacy.py, … (+3 more)
⚠ 1 unresolved @depends reference(s) — no such feature: DANGLE-01 → GHOST-77
Symbol IDs & collisions
A tagged location's symbol ID is its bare symbol when unique (validate_token) and a deterministic path prefix on collision (web.app.layout vs web.app.docs.layout; if the directory still repeats, the full path is used). Explicit @feature [ID] tags remain the canonical feature ID.
query, search, and impact accept a feature ID, a qualified symbol ID, or an unambiguous bare symbol. An ambiguous bare name exits 1 and lists the candidate qualified IDs.
⚡ Fast AST Feature Search
featuregraph search "parser"
# Output gives exact file paths and surgical #Lstart-Lend ranges:
# • featuregraph/core/parser_py.py #L10-L95 (PythonFeatureParser)
featuregraph query web.app.docs.layout # qualified symbol ID
featuregraph query layout # ambiguous -> exit 1 + candidate IDs
🚀 Installation & Quickstart
1. Install via pip / uv (PyPI)
pip install featuregraph-cli
# Or install as an isolated CLI tool:
uv tool install featuregraph-cli
# Or run without installing:
uvx --from featuregraph-cli featuregraph check --rescan --strict
2. Initialize in Your Repository
cd your-project
featuregraph init
This command:
- scans the codebase and writes
.featuregraph/manifest.json,.featuregraph/categories/,.featuregraph/index.json,.featuregraph/graph.md - creates or extends the
AGENTS.mdshort-circuit directive - installs the workspace agent skill at
.agents/skills/featuregraph/SKILL.md - installs
.git/hooks/pre-commitwhen no foreign pre-commit hook exists
The hook rescans on commit, skips when unstaged or untracked changes are present, and stages .featuregraph/ only when git check-ignore says it is not ignored. It never force-adds a gitignored directory.
3. Install Global Agent Skills
featuregraph skill --global
Targets: ~/.agents, ~/.gemini/config, ~/.claude/skills, ~/.cursor/skills, ~/.config/opencode/skills.
🌐 Multi-Language Support
| Language | Extensions | Comment style |
|---|---|---|
| Python | .py |
# @feature [ID] Name |
| TypeScript / JavaScript | .ts, .tsx, .js, .jsx |
// @feature [ID] Name |
| Go | .go |
// @feature [ID] Name |
| Rust | .rs |
// @feature [ID] Name |
| Java / Kotlin | .java, .kt, .kts |
// @feature [ID] Name |
| C# / .NET | .cs |
// @feature [ID] Name |
| C / C++ | .c, .cpp, .cc, .h, .hpp |
// @feature [ID] Name |
| PHP | .php |
// @feature [ID] Name |
| Ruby | .rb |
# @feature [ID] Name |
| Swift / Dart | .swift, .dart |
// @feature [ID] Name |
| Shell | .sh, .bash, .zsh |
# @feature [ID] Name |
Go double-quoted strings honour backslash escapes; backtick raw strings do not. The lexer handles both, so \" inside a Go string never leaks a fake comment.
🛠️ CLI Reference
featuregraph --help
# Initialize repo, pre-commit hook, AGENTS.md directive and workspace skill
featuregraph init
# Auto-suggest and write @feature tags for un-annotated symbols
featuregraph annotate --dry-run
featuregraph annotate --yes
featuregraph annotate --dir ./src --limit 50 --yes
# Scan codebase, infer call edges, rebuild the 2-tier index
featuregraph scan
featuregraph scan --dir ./my-project --json index.json --md GRAPH.md --quiet
# Query exact lines and dependencies for a feature or symbol ID
featuregraph query AUTH-01
featuregraph query AUTH-01 --json
featuregraph search "parser" --dir ./app --json
# Blast radius: impact <feature_id> before editing, impact --diff after
featuregraph impact AUTH-01
featuregraph impact --diff
featuregraph impact --staged --json
# Enforcement gate (exit 0 = pass, 1 = fail)
featuregraph check
featuregraph check --strict
featuregraph check --strict --rescan --json
# Agent skills
featuregraph skill --install
featuregraph skill --global
featuregraph skill --show
# Pre-commit hook
featuregraph hook --install
featuregraph hook --uninstall
🤖 AI Agent Integration Protocol
- Auto-discovery: agents find the
/featuregraphskill in.agents/skills/or their global config. - Short-circuit directive:
AGENTS.mdtells the agent to read.featuregraph/manifest.jsoninstead of walking the tree. - Exact slices: the agent reads only the target
#Lstart-Lendspan. - Impact before and after edit:
featuregraph impact <feature_id>names the callers, endpoints, boundaries, invariants, and tests at risk before editing;featuregraph impact --diffverifies the blast radius afterwards. - Gate before done:
featuregraph check --strictplus the reported tests.
🔄 CI Gate (GitHub Actions)
Drop FeatureGraph into pull requests to block stale indexes, broken @depends, cycles, and unguarded endpoints:
- name: FeatureGraph security gate
run: |
pip install featuregraph-cli
featuregraph check --rescan --strict
Want to try impact and check --strict in 10 seconds? See examples/fastapi-react-demo/.
📄 License
MIT © ProximaLink / Pakheria
Metadata
Release files for featuregraph-cli 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| featuregraph_cli-0.1.1.tar.gz | 82.3 kB | Without provenance | Details for featuregraph_cli-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| featuregraph_cli-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for featuregraph_cli-0.1.1-py3-none-any.whl |
Total release size: 143.8 kB
Release files / featuregraph_cli-0.1.1.tar.gz
| Download URL | featuregraph_cli-0.1.1.tar.gz |
|---|---|
| Size | 82.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eebf79ef40c117639ef15a64f2ea552b04d51ff674bd194c080ebbf418733b05
|
|
BLAKE2b-256 checksum How to use checksums |
3812287e337fee2f0b168ff0a50326a77e74b72fa252f728c0d5f5d245988649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / featuregraph_cli-0.1.1-py3-none-any.whl
| Download URL | featuregraph_cli-0.1.1-py3-none-any.whl |
|---|---|
| Size | 61.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f10143636a2c67491e90c00ef21455f2619cade70b32c637de209aa60b6884c7
|
|
BLAKE2b-256 checksum How to use checksums |
a82ae9a5bb49791be3613c7cd0e5e377d53af7b3f4fdc916ca820a635c6d887e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for featuregraph-cli 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.