A plug-and-play persistent knowledge graph that gives AI coding tools memory, trust scores, and team awareness.
Track AI-generated code across tools (Cursor, Copilot, Antigravity, Claude), detect anti-patterns, enforce quality gates in CI/CD, and monitor everything from a real-time dashboard.
| Feature | Description |
|---|---|
| Knowledge Graph | SQLite-backed graph of your codebase: files, functions, classes, imports, dependencies |
| AI Attribution | Automatically detects which AI tool generated each piece of code (via git history) |
| Trust Scores | 0β100 trust score per file with letter grades (AβF) |
| Anti-Pattern Detection | 7 built-in checks: hardcoded secrets, SQL injection, eval(), missing error handling, etc. |
| Team Patterns | Learns your team's conventions (type hints, testing frameworks, logging practices) |
| REST API | Local FastAPI server on localhost:7878 β any tool can query context |
| GitHub Actions | Drop-in CI workflow: scan PRs, post quality reports, block low-trust code |
| Web Dashboard | Next.js dashboard with real-time trust scores, anti-pattern charts, AI tool comparison |
| Git Hooks | Auto-installed post-commit + pre-push hooks for continuous tracking |
# Install
pip install ai-code-context # or: pip install -e .
# Initialize in your repo
cd your-project/
ai-context init
# Start the API daemon
ai-context start
# Run analysis
ai-context analyze
# Scan for anti-patterns
ai-context scanAfter ai-context init, the tool will:
- Create
.ai-context/directory withgraph.dbandconfig.yml - Install git hooks (
post-commit,pre-push) - Scan your codebase and build the knowledge graph
- Detect AI tools and scan git history for AI-generated commits
| Command | Description |
|---|---|
ai-context init |
Initialize AI Context in your repository |
ai-context start |
Start the local API daemon (port 7878) |
ai-context stop |
Stop the daemon |
ai-context analyze |
Analyze codebase and build/update the knowledge graph |
ai-context scan |
Scan for anti-patterns and show trust score report |
ai-context score [file] |
Show trust score for a specific file or all files |
ai-context log-decision |
Log an architectural decision to the graph |
ai-context status |
Show current status (graph stats, daemon, detected tools) |
π€ AI Code Quality Report
Repository Trust Score: 74/100 β οΈ
Grade: C | Files: 42 | High Risk: 3
ββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββββ¬βββββββ¬ββββββββββββββββββββββββββββββ
β Severity β Type β File β Line β Message β
ββββββββββββΌβββββββββββββββββββββββΌβββββββββββββββββββΌβββββββΌββββββββββββββββββββββββββββββ€
β HIGH β HARDCODED_SECRET β src/config.py β 12 β Hardcoded secret detected β
β HIGH β SECURITY_VULNERABILITYβ src/utils.py β 45 β eval() usage detected β
β MEDIUM β NO_ERROR_HANDLING β src/api/handler β 23 β Async function without try β
ββββββββββββ΄βββββββββββββββββββββββ΄βββββββββββββββββββ΄βββββββ΄ββββββββββββββββββββββββββββββ
Start the daemon and query context from any tool:
ai-context start| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check with graph stats |
/context?file=path |
GET | Full context bundle for a file |
/scores?file=path |
GET | Trust scores |
/scan |
GET | Full anti-pattern scan |
/commit |
POST | Track a commit (called by git hook) |
/track |
POST | Track an AI-generated change |
/decision |
POST | Log an architectural decision |
/dashboard |
GET | Full dashboard data |
/activity |
GET | Recent activity feed |
/tools |
GET | Detected AI tools |
/analyze |
POST | Trigger full codebase analysis |
curl http://127.0.0.1:7878/context?file=src/auth/login.py{
"file": "src/auth/login.py",
"trust_score": 72,
"ai_sessions": [
{"tool": "cursor", "timestamp": "2024-01-15T10:30:00Z"}
],
"related_files": ["src/auth/utils.py", "src/models/user.py"],
"patterns": ["Type annotations", "Structured logging"]
}Score = 100 β Deductions + Boosts
| Check | Severity | Points |
|---|---|---|
| Hardcoded secrets | HIGH | -30 |
| SQL injection | HIGH | -30 |
| Security vulnerabilities (eval, pickle) | HIGH | -30 |
| Missing error handling | MEDIUM | -15 |
| TODO/FIXME placeholders | MEDIUM | -15 |
| Missing edge case handling | MEDIUM | -15 |
| Generic variable names | LOW | -5 |
| Practice | Points |
|---|---|
| Has tests | +10 |
| Type annotations | +5 |
| Error handling (try/except) | +10 |
| Follows team patterns | +15 |
| Score | Grade |
|---|---|
| 90β100 | A |
| 80β89 | B |
| 70β79 | C |
| 60β69 | D |
| 0β59 | F |
# .github/workflows/ai-quality.yml
name: AI Quality Check
on:
pull_request:
branches: [main]
jobs:
quality:
uses: ./.github/workflows/ai-quality-check.yml
with:
min_trust_score: 60
block_on_failure: true- uses: ai-code-context/action@v1
with:
min-trust-score: 60
block-on-failure: truePR comments will include:
- Overall trust score with letter grade
- Critical issues with fix suggestions
- Low-trust file list
- AI tool attribution
cd dashboard/
npm install
npm run devVisit http://localhost:3001 for the live dashboard.
The dashboard includes:
- Trust Score Overview β repo-wide score with trend
- High-Risk Code β files needing immediate attention
- Anti-Patterns β horizontal bar chart of detected issues
- AI Tool Comparison β side-by-side scores per tool
- Activity Feed β recent commits and AI sessions
- Team Patterns β learned coding conventions
Dashboard auto-connects to the API daemon. Falls back to demo data if the daemon isn't running.
ai-code-context-graph/
βββ ai_code_context/ # Core Python package
β βββ graph/
β β βββ engine.py # SQLite knowledge graph
β β βββ queries.py # High-level graph queries
β βββ analyzers/
β β βββ parser.py # Code analysis engine
β β βββ patterns.py # Team pattern detection
β βββ tracking/
β β βββ git_tracker.py # Git commit tracking + AI attribution
β β βββ ai_detector.py # AI tool detection
β βββ scoring/
β β βββ trust_calculator.py # Trust score algorithm
β β βββ anti_patterns.py # Anti-pattern detection engine
β βββ api/
β β βββ server.py # FastAPI REST API
β βββ cli.py # Click CLI
β βββ config.py # Configuration management
β βββ hooks.py # Git hook installer
βββ dashboard/ # Next.js web dashboard
β βββ app/
β β βββ page.js # Main dashboard page
β β βββ layout.js # Root layout
β β βββ globals.css # Dark theme CSS
β βββ components/ # React components
βββ github-actions/ # GitHub Actions integration
β βββ ai-quality-check.yml # Reusable workflow
β βββ action.yml # Composite action
βββ tests/
β βββ test_core.py # Test suite
βββ pyproject.toml # Python package config
After ai-context init, edit .ai-context/config.yml:
# Scanning
exclude_patterns:
- "*.min.js"
- "vendor/*"
# Trust thresholds
min_trust_score: 60
block_below_score: true
# AI tool markers (customize per team)
ai_tool_markers:
cursor: ["cursor", "Cursor"]
copilot: ["Co-authored-by: GitHub Copilot"]
# API
api_port: 7878
api_host: "127.0.0.1"pip install -e ".[dev]"
pytest tests/ -vMIT