Requirements traceability for LLM-assisted software development
🌐 Official Website: contextgit.com
Sponsored by: www.cronlytic.com
contextgit is a local-first, git-friendly CLI tool that maintains bidirectional traceability between business requirements, system specifications, architecture decisions, source code, and tests. Designed specifically for integration with Claude Code and similar LLM development assistants.
Traditional requirement management is slow and manual. contextgit makes it 1,355× faster with:
- 🔍 Instant requirement searches (12.5 min → 0.5 sec)
- 🔗 Automatic staleness detection (prevents $1,200-2,000 rework per incident)
- 📊 94% context reduction for LLM prompts (6,000 → 375 tokens)
- ⚡ 5-10× faster PR reviews with structured metadata
- 💰 Time savings: Sub-second searches vs 12+ minutes manual (see methodology)
Based on real-world measurements from dogfooding contextgit on itself.
✨ Core Capabilities
- Traceability Graph: Track relationships from business needs → system specs → architecture → code → tests
- Staleness Detection: Automatically detect when upstream requirements change via checksum comparison
- Precise Context Extraction: Extract only relevant requirements for LLM consumption
- Bidirectional Links: Automatically maintain upstream/downstream relationships
- Impact Analysis: Analyze downstream effects of requirement changes (v1.2+)
- Circular Dependency Detection: Validate link integrity (v1.2+)
🎯 LLM-Optimized
- JSON output for all commands (
--format json) - Sub-second requirement searches
- Extract command for precise context snippets
- Designed for Claude Code workflows
- MCP Server: Native Model Context Protocol integration for Claude Desktop (v1.2+)
🛠️ Developer-Friendly
- Git-Friendly: Metadata in Markdown YAML frontmatter and HTML comments
- Local-First: All data in
.contextgit/requirements_index.yaml- no network calls - Deterministic Output: Sorted YAML for clean git diffs
- Atomic Operations: Never corrupts index file
- Git Hooks: Automatic scanning on commit/merge (v1.2+)
- Watch Mode: Real-time file monitoring (v1.2+)
📁 Multi-Format Support (v1.2+)
- Markdown (.md) - YAML frontmatter and HTML comments
- Python (.py) - Docstrings and comment blocks
- JavaScript/TypeScript (.js, .ts, .jsx, .tsx) - JSDoc blocks
pip install contextgit
# With optional features (v1.2+)
pip install contextgit[watch] # Watch mode (file monitoring)
pip install contextgit[mcp] # MCP server for Claude Desktop
pip install contextgit[all] # All optional featuresgit clone https://github.com/Mohamedsaleh14/ContextGit.git
cd ContextGit
pip install -e .# Download the .deb package from releases
wget https://github.com/Mohamedsaleh14/ContextGit/releases/download/v1.2.0/contextgit_1.2.0_all.deb
# Install
sudo dpkg -i contextgit_1.2.0_all.debcontextgit --help# 1. Initialize a contextgit repository (with LLM integration)
contextgit init --setup-llm
# This creates:
# - .contextgit/config.yaml
# - .contextgit/requirements_index.yaml
# - .contextgit/LLM_INSTRUCTIONS.md ← LLM reads this
# - .cursorrules ← Cursor auto-detects
# - CLAUDE.md ← Claude Code auto-detects
# 2. Add metadata to your Markdown files
cat > docs/requirements.md << 'EOF'
---
contextgit:
id: auto
type: business
title: User authentication
status: active
---
# User Authentication
Users must be able to log in with email and password.
EOF
# 3. Scan files to build the index
contextgit scan docs/ --recursive
# 4. Check repository status
contextgit status
# 5. View requirement details
contextgit show BR-001
# 6. Extract requirement text for LLM
contextgit extract BR-001Next Steps: See the User Guide for complete workflows and examples.
contextgit init # Initialize repository
contextgit init --setup-llm # Initialize + create LLM integration files
contextgit scan docs/ --recursive # Scan for metadata
contextgit scan --dry-run # Preview changescontextgit status # Show project health
contextgit status --stale # Show stale requirements
contextgit show SR-010 # Show node details
contextgit extract SR-010 # Extract requirement text
contextgit relevant-for-file src/auth.py # Find related requirementscontextgit link BR-001 SR-010 --type refines # Create manual link
contextgit confirm SR-010 # Mark as synchronizedcontextgit next-id system # Generate next ID (SR-001)
contextgit fmt # Format index for git
contextgit show SR-010 --format json # JSON output for LLMscontextgit validate docs/ --recursive # Validate metadata without modifying index
contextgit impact SR-010 # Show downstream impact analysis
contextgit impact SR-010 --format json # JSON output for CI/CDcontextgit hooks install # Install git hooks (pre-commit, post-merge)
contextgit hooks status # Check hook installation status
contextgit hooks uninstall # Remove git hooks
contextgit watch docs/ # Watch for file changes (requires watchdog)contextgit mcp-server # Start MCP server for Claude Desktopcontextgit supports two metadata formats in Markdown files:
---
contextgit:
id: auto
type: system
title: User authentication system
status: active
upstream: [BR-001]
downstream: [AR-005, C-020]
tags: [security, auth]
---
# System Requirement: User Authentication
The system shall provide secure user authentication...<!-- contextgit
id: auto
type: system
title: User authentication system
status: active
upstream: [BR-001]
-->
## User Authentication
The system shall provide secure user authentication..."""
contextgit:
id: C-001
type: code
title: Authentication module
upstream: [SR-010]
"""
def authenticate(email: str, password: str) -> bool:
.../**
* @contextgit
* id: C-002
* type: code
* title: Login handler
* upstream: [SR-010]
*/
export function handleLogin(req, res) {
...
}| Type | Prefix | Purpose |
|---|---|---|
business |
BR- | Business requirements, user needs |
system |
SR- | System-level functional specs |
architecture |
AR- | Architecture decisions, ADRs |
code |
C- | Code implementation notes |
test |
T- | Test specifications |
decision |
ADR- | Design decisions |
contextgit is designed for seamless integration with LLM development tools.
contextgit init --setup-llmThis creates all LLM integration files automatically:
| File | Purpose |
|---|---|
.contextgit/LLM_INSTRUCTIONS.md |
Comprehensive guide for any LLM (~5KB) |
.cursorrules |
Cursor IDE auto-detection |
CLAUDE.md |
Claude Code auto-detection |
How it works:
- Cursor reads
.cursorrules→ knows to use contextgit - Claude reads
CLAUDE.md→ knows to use contextgit - Both are directed to
LLM_INSTRUCTIONS.mdfor full details
# Get precise context for implementing a requirement
contextgit extract SR-010 --format json
# Find all requirements affecting a file
contextgit relevant-for-file src/auth.py --format json
# Check for stale requirements before making changes
contextgit status --stale
# After updating code, rescan and confirm synchronization
contextgit scan src/ --recursive
contextgit confirm SR-010All commands support --format json for easy parsing by LLMs.
See: User Guide - LLM Integration | LLM Integration Guidelines
Based on objective measurements from dogfooding:
| Metric | Manual | With contextgit | Improvement |
|---|---|---|---|
| Requirement search | 12.5 min | 0.55 sec | 1,355× faster |
| Staleness detection | 30-60 min | <1 sec | 1,800-3,600× faster |
| PR review time | 3-5 min | 30-60 sec | 5-10× faster |
| Context extraction | Manual copy | Automated | 14-29 min saved/task |
Verified Benefits: 87-90% token reduction, sub-second requirement searches
See: Full Performance Evaluation (includes methodology and assumptions)
- 📖 User Guide - Complete guide with workflows and examples
- 🚀 Quick Start - Get up and running in 5 minutes
- 💡 LLM Integration - Using with Claude Code
- Product Overview - Vision and problem statement
- User Stories - Detailed usage scenarios
- System Requirements - Functional requirements
- Architecture - System design
- Data Model - Schemas and file formats
- CLI Specification - Command reference
- MVP Scope - Current and planned features
- Performance Evaluation - Real-world measurements and ROI
- Implementation Complete - Architecture and modules
-
Python: 3.11 or higher
-
Core Dependencies:
typer>= 0.9.0 (CLI framework)rich>= 13.0.0 (terminal output)ruamel.yaml>= 0.18.0 (YAML handling)
-
Optional Dependencies (v1.2+):
watchdog>= 3.0.0 (watch mode -pip install contextgit[watch])mcp>= 0.1.0 (MCP server -pip install contextgit[mcp])pydantic>= 2.0.0 (MCP schemas - included with mcp)
# Clone repository
git clone https://github.com/Mohamedsaleh14/ContextGit.git
cd ContextGit
# Install in development mode
pip install -e .
# Run import validation
python3 test_imports.py
# Run system verification
python3 verify_system.py
# Check CLI help
python3 -m contextgit --helpcontextgit/
├── cli/ # Typer command definitions
├── handlers/ # Command handlers (InitHandler, ScanHandler, etc.)
├── domain/ # Core domain (IndexManager, MetadataParser, LinkingEngine, etc.)
├── infra/ # Infrastructure (FileSystem, YAMLSerializer, OutputFormatter)
├── models/ # Data models (Node, Link, Index, Config)
├── scanners/ # File format scanners (v1.2+: Markdown, Python, JavaScript)
└── mcp/ # MCP server implementation (v1.2+)
Architecture: 4-layer design (CLI → Handlers → Domain → Infrastructure)
Contributions are welcome! This is an MVP with many opportunities for enhancement.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with clear commit messages
- Push to your fork (
git push origin feature/amazing-feature) - Open a Pull Request
- VS Code extension
- Additional file formats (ReStructuredText, AsciiDoc)
- Performance optimization (daemon mode, lazy loading)
- CI/CD integrations (GitHub Action, GitLab CI template)
- Coverage reporting and analytics
See: MVP Scope and Future Work
- All 10 CLI commands
- Metadata parsing (YAML frontmatter + HTML comments)
- Traceability graph with staleness detection
- JSON output for LLM integration
- Git-friendly YAML output
- Multi-format file support (Python, JavaScript/TypeScript)
- Watch mode for auto-scanning
- Git hooks integration (pre-commit, post-merge, pre-push)
- Metadata validation command
- Impact analysis command
- MCP Server for Claude Desktop integration
- Circular dependency detection
- Enhanced link validation
- VS Code extension
- Daemon mode for performance
- Parallel file scanning
- CI integration (GitHub Action, GitLab CI)
- Coverage reporting
- Team analytics
See: Full Roadmap
MIT License - see LICENSE file for details.
Sponsored by: www.cronlytic.com
If you find contextgit useful, consider supporting its development:
Your support helps maintain and improve contextgit! ☕
Mohamed Saleh
I build tools for developers. contextgit is one of several open-source projects I maintain.
🌐 Visit my website: BySaleh.com
- More open-source projects
- Technical blog posts
- Development tutorials
- Contact information
- Built with Typer for CLI, Rich for terminal output
- Designed specifically for Claude Code integration
- Inspired by the need for better requirements traceability in LLM-assisted development
- Official Website: https://contextgit.com
- PyPI: https://pypi.org/project/contextgit/
- Repository: https://github.com/Mohamedsaleh14/ContextGit
- Issues: https://github.com/Mohamedsaleh14/ContextGit/issues
- Releases: https://github.com/Mohamedsaleh14/ContextGit/releases
- User Guide: USER_GUIDE.md
- Performance Evaluation: PERFORMANCE_EVALUATION.md
If you find this project useful, please consider giving it a ⭐ on GitHub!
Made with ❤️ by Mohamed Saleh
Sponsored by www.cronlytic.com