Enrich Claude Code requests to prevent architectural drift and enforce codebase consistency. Claude Code plugin that works in both the CLI and VS Code extension.
Fellow helps Claude understand your codebase by extracting three types of knowledge:
- Factual Knowledge - What entities, models, and data structures exist
- Procedural Knowledge - How workflows and execution flows work
- Conceptual Knowledge - What the overall architecture and design patterns are
This knowledge enables intelligent coding assistance with:
- Context-aware code suggestions
- Architectural boundary enforcement
- Constraint checking
- Pattern-consistent implementations
Fellow features AST-enhanced extraction enabled by default for massive performance improvements:
- 90% token reduction = 10x lower costs
- 10x faster extraction = seconds instead of minutes
- Multi-language support = Python, JavaScript/TypeScript, Java + fallback for all others
- Zero dependencies = Pure Python stdlib
- 100% compatible = Works with any codebase
It's automatic - just run:
/build-kb # AST-enhanced by default - 90% faster, 90% cheaper!Use --no-ast only if you need traditional extraction for debugging.
See Multi-Language Support for details.
NEW: Phase 2 adds call graph-enhanced workflow extraction for even better code understanding:
- Automatic workflow identification - Traces execution flows from entry points
- 75% token reduction for workflow understanding vs traditional method
- 70% faster procedural knowledge extraction
- Multi-language support - Python (100%), JavaScript/TypeScript (90%), Java (90%)
- Dependency mapping - Identifies external services and components
Enable with --callgraph flag:
/build-kb --callgraph # Best quality workflow extractionHow it works: Extracts call graphs → Identifies entry points → Traces execution flows → Understands semantic meaning
See Phase 2 Documentation for details.
# Step 1: Add as local marketplace
claude plugin marketplace add https://github.com/jingnanzhou/fellow.git
# Step 2: Install from local marketplace
claude plugin install fellow@local_marketplace
# Step 3: Verify installation
claude plugin listWorks in both CLI and VS Code! Fellow automatically works with the Claude Code VS Code extension.
To uninstall Fellow:
# Step 1: Uninstall the plugin
claude plugin uninstall fellow@local_marketplace
# Step 2: Remove the marketplace
claude plugin marketplace remove local_marketplaceSee INSTALLATION.md for comprehensive installation guide.
- Claude Code CLI or VS Code Extension - Fellow works with both!
- Python 3.8+ - For knowledge extraction (standard library only, no packages required)
- Git - Optional, for cloning from source
Fellow works seamlessly with the Claude Code VS Code extension:
- Install Claude Code extension in VS Code
- Install Fellow:
/plugin install fellow - All Fellow features work identically with visual benefits!
See VS Code Integration Guide for details.
After installation:
- Commands Available:
/build-kb,/fellow,/toggle-hooks - Hooks Status: Use
/toggle-hooks statusto check - Cheat Sheet: See docs/CHEAT_SHEET.md for all commands
# Option 1: Build knowledge base first (recommended)
# 🚀 AST-enhanced by default - 90% faster!
/build-kb
# Option 2: Start coding immediately (auto-build)
# Fellow will offer to build KB automatically when needed!
"Add authentication to the user endpoint"
# Check if automatic enrichment is enabled (default: on)
/toggle-hooks status
# Start coding naturally - context is automatically enriched!
"Add validation to the registration form"
# Optional: Use manual enrichment with /fellow
/fellow Add caching to the API
# Optional: Update KB after code changes (incremental, fast with AST)
/build-kb --update✨ New: Auto-Build Feature
If you forget to build the knowledge base, Fellow will:
- Detect it's missing when you make a coding request
- Inform you it will take 2-5 minutes
- Offer to build it automatically
- Then proceed with your request!
No more confusing errors - Fellow guides you through the process.
📖 New to Fellow? Check out the Cheat Sheet for a quick reference guide!
Extract semantic knowledge from a target project:
# Build KB for current project (AST-enhanced by default)
/build-kb
# Build KB for specific project
/build-kb /path/to/project
# Build KB for relative path
/build-kb ../my-project
# Force full re-extraction (ignore existing KB)
/build-kb --full
# Incremental update (only re-analyze changed files)
/build-kb --updateWhat it does:
- Launches three extraction agents in parallel
- Analyzes the target project comprehensively
- Creates
.fellow-data/semantic/directory in target project - Saves three JSON files (for machine consumption):
factual_knowledge.json- Entities and relationshipsprocedural_knowledge.json- Workflows and execution flowsconceptual_knowledge.json- Architecture and design patterns
- Generates comprehensive markdown summary (for human readers):
SEMANTIC_KNOWLEDGE_SUMMARY.md- Human-readable documentation
- Tracks file changes in
extraction_metadata.jsonfor incremental updates
Modes:
- Full Extraction: Analyzes entire codebase (2-5 minutes for typical projects)
- Incremental Update: Only re-analyzes changed files (10-20 seconds, 10-20x faster)
- Detects changes via git diff, file hashes, or modification times
- Merges new knowledge with existing KB
- Perfect for active development workflows
Time:
- Full extraction: 2-5 minutes (first time or with
--full) - Incremental update: 10-20 seconds (subsequent updates)
Fellow automatically enriches your coding requests with semantic knowledge from the knowledge base.
Once you've built a knowledge base with /build-kb, Fellow automatically intercepts coding requests and enriches them with context:
# Simply write your coding request naturally - no special command needed!
Add a POST endpoint for user registration
# Refactor existing code
Refactor the payment processing to use the Strategy pattern
# Add features with constraints
Add caching to the tool listing API with 60-second TTL
# Fix or enhance
Add validation to the user registration formHow it works:
- Hook automatically detects coding requests (keywords: add, create, implement, fix, etc.)
- Loads semantic knowledge from
.fellow-data/semantic/in current directory or parent directories - Enriches your request with:
- Relevant entities (with locations and purposes)
- Relevant workflows (existing patterns to follow)
- Architectural guardrails (constraints that apply)
- Architecture style and design patterns
- Passes enriched context to Claude transparently
- Non-coding requests pass through unchanged
Hook Configuration:
- Enabled by default via
.claude-plugin/hooks.json - Toggle on/off: Use
/toggle-hooks on|off|status - Confidence threshold: 0.7 (configurable)
- Silent mode: false (shows enriched context)
- See Hook Configuration section below for customization
You can also explicitly use the /fellow command:
# Explicit context enrichment
/fellow Add a POST endpoint for user registrationThis is useful when:
- You want to force context enrichment even for ambiguous requests
- The hook doesn't detect your request as a coding task
- You're testing the knowledge base
Guardrails Applied:
- Architecture boundaries (layer dependencies, module isolation)
- Design patterns (follow established patterns)
- Security constraints (auth, validation, sanitization)
- Performance constraints (caching, pooling, optimization)
- Consistency rules (naming, structure, error handling)
The knowledge base is stored in the target project at .fellow-data/semantic/:
{
"metadata": { ... },
"entities": [
{
"name": "User",
"type": "class",
"attributes": [...],
"methods": [...],
"relationships": [...],
"grounding": { "file": "...", "line_start": 10, "line_end": 50 }
}
],
"entity_relationships": [...],
"summary": { ... }
}{
"metadata": { ... },
"workflows": [
{
"name": "user_authentication",
"type": "request_handler",
"entry_point": { "function": "...", "file": "...", "line": 123 },
"steps": [...],
"data_flow": { ... },
"control_flow": { ... }
}
],
"summary": { ... }
}{
"metadata": { ... },
"architecture_style": { "primary": "Layered Architecture", ... },
"layers": [...],
"modules": [...],
"design_patterns": [...],
"design_decisions": [...],
"constraints": [...]
}Comprehensive human-readable documentation including:
- Project Overview - Core capabilities and technology stack
- Architecture Evolution - Transformation story with metrics
- System Architecture - Layered architecture with detailed descriptions
- Core Entities - Key entities with purposes and design patterns
- Key Workflows - Complete workflows with step-by-step flows
- Design Patterns - Patterns used with benefits and trade-offs
- Design Decisions - Major decisions with rationale and alternatives
- Architectural Constraints - Constraints organized by category
- Key Metrics - Code quality, performance, and pattern usage metrics
Use Cases:
- Onboarding new developers to the codebase
- Architecture reviews and documentation
- Understanding design decisions and trade-offs
- Quick reference for codebase structure
Fellow uses Claude Code's hook system to automatically intercept and enrich coding requests.
The hook is defined in .claude-plugin/hooks.json:
{
"hooks": [
{
"name": "fellow-context-enrichment",
"type": "user-prompt-submit",
"description": "Automatically enriches coding requests with semantic knowledge",
"enabled": true,
"script": "./hooks/enrich-context.sh",
"config": {
"detect_coding_requests": true,
"auto_load_kb": true,
"silent_mode": false,
"logging_enabled": true,
"min_confidence": 0.7,
"keywords": [
"add", "create", "implement", "build", "write", "fix", "refactor",
"update", "modify", "change", "enhance", "improve", "optimize",
"delete", "remove", "test", "debug", "validate", "endpoint",
"function", "class", "method", "service", "component", "module"
]
}
}
]
}Enable/Disable Hook:
"enabled": false // Disable automatic enrichmentAdjust Detection Confidence:
"min_confidence": 0.5 // Lower = more aggressive detection (more false positives)
"min_confidence": 0.9 // Higher = conservative detection (may miss some requests)Silent Mode:
"silent_mode": true // Hide enriched context, only apply guardrailsEnable Logging:
"logging_enabled": true // Log all enrichment events to .fellow-data/logs/Add Custom Keywords:
"keywords": [
"add", "create", ...,
"scaffold", "generate", "migrate" // Add your own keywords
]Detected as Coding Request (enriched):
- "Add a new authentication endpoint"
- "Refactor the payment service to use Strategy pattern"
- "Fix the validation bug in user registration"
- "Implement caching for tool listing API"
Not Detected (pass through):
- "What is the architecture of this project?"
- "Show me the user authentication workflow"
- "How does the payment processing work?"
- "List all the design patterns used"
Fellow can log all enrichment events for debugging and analysis.
Log Location:
- Project logs:
.fellow-data/logs/(in target project directory) - Fallback:
fellow/.fellow-data/logs/(in Fellow plugin directory)
Log Files Created:
enrichment_YYYY-MM-DD.jsonl- Machine-readable JSON logs (one line per event)enrichment_YYYY-MM-DD.log- Human-readable logs with full context
Enabling Logging:
Method 1: Edit .claude-plugin/hooks.json:
{
"hooks": [{
"config": {
"logging_enabled": true
}
}]
}Method 2: Environment variable:
export FELLOW_LOGGING=1Log Contents:
Each enrichment event logs:
- Original prompt - User's original coding request
- Detection results - Whether detected as coding request, intent, confidence
- Knowledge base - Whether KB found, path
- Enrichment stats - Number of entities, workflows, constraints found
- Enriched prompt - Full context that was added
- Source - Whether from hook or /fellow command
- Timestamp - When enrichment occurred
Example Log Entry (Human-Readable):
================================================================================
[2026-01-05 18:15:08] HOOK
================================================================================
Original Prompt (42 chars):
Add validation to the OAuth token endpoint
Detection:
- Coding Request: True
- Intent: create
- Confidence: 1.00
Knowledge Base:
- Found: True
- Path: /path/to/project/.fellow-data/semantic
Enrichment:
- Entities: 5
- Workflows: 3
- Constraints: 8
- Enriched Length: 2743 chars
Enriched Prompt:
[full enriched context shown here]
Use Cases:
- Debug why certain entities/workflows were retrieved
- Analyze detection accuracy
- Understand what context is being added
- Track usage patterns
- Troubleshoot hook behavior
Using the Toggle Command (Recommended):
# Check current status
/toggle-hooks status
# Disable automatic enrichment
/toggle-hooks off
# Re-enable automatic enrichment
/toggle-hooks onManual Configuration:
Alternatively, edit .claude-plugin/hooks.json directly:
{
"hooks": [
{
"name": "fellow-context-enrichment",
"enabled": false, // Change to true/false
...
}
]
}When Disabled:
- All requests pass through unchanged
- Use
/fellowcommand for explicit enrichment when needed
Commands (commands/):
build-kb.md- Orchestrates knowledge extraction with incremental updates (Step 1)fellow.md- Manual context-enriched coding (Step 2, optional)toggle-hooks.md- Enable/disable automatic context enrichment hooks
Agents (agents/):
factual-knowledge-extractor- Extracts entities and modelsprocedural-knowledge-extractor- Extracts workflowsconceptual-knowledge-extractor- Extracts architecture
Hooks (hooks/):
enrich-context.sh- Shell wrapper for hook executionenrich-context.py- Automatic coding request detection and enrichment
Documentation (docs/):
INCREMENTAL_UPDATES.md- Incremental update feature documentationCHEAT_SHEET.md- Quick reference guide for all commands and features
Step 1: Knowledge Base Extraction (/build-kb)
- Command Invocation: User runs
/build-kb [path] [--full|--update] - Path Resolution: Determines target project (current dir or specified path)
- Mode Detection: Decides between full extraction or incremental update
- Change Detection (incremental only): Identifies modified files via git/hash/mtime
- Parallel Extraction: Launches three agents simultaneously
- Knowledge Merge (incremental only): Merges new knowledge with existing KB
- Knowledge Storage: Saves JSON to
.fellow-data/semantic/ - Metadata Tracking: Updates
extraction_metadata.jsonwith file hashes - Markdown Generation: Creates comprehensive human-readable summary
- Summary: Reports extraction statistics
Step 2: Context-Enriched Coding (Automatic via Hooks)
- Request Interception: Hook intercepts user prompt before Claude processes it
- Coding Detection: Analyzes prompt for coding keywords and intent
- Knowledge Base Discovery: Searches upward for
.fellow-data/semantic/ - Knowledge Loading: Loads factual, procedural, and conceptual JSON files
- Relevance Scoring: Scores entities and workflows by relevance to prompt
- Constraint Filtering: Identifies applicable architectural constraints
- Context Enrichment: Generates enriched prompt with entities, workflows, guardrails
- Transparent Execution: Passes enriched prompt to Claude for processing
- Pass-Through: Non-coding requests pass through unchanged
Step 2: Context-Enriched Coding (Manual via /fellow)
- Explicit Command: User runs
/fellow <coding request> - Knowledge Loading: Loads semantic KB from
.fellow-data/semantic/ - Intent Analysis: Analyzes the coding request (create, modify, fix, etc.)
- Knowledge Retrieval: Finds relevant entities, workflows, patterns
- Constraint Extraction: Identifies applicable architectural constraints
- Guardrail Generation: Creates specific coding guardrails
- Task Execution: Executes with full architectural awareness
- Non-Invasive: Only reads code, never modifies it
- Language Agnostic: Works with any programming language
- Parallel Processing: Runs extractions concurrently for speed
- Machine Readable: Structured JSON output for programmatic use
- Human Readable: Comprehensive markdown documentation for developers
- Grounded: All knowledge linked to source code locations
- Build semantic knowledge base from any project
- Extract factual, procedural, and conceptual knowledge
- Store as structured JSON and human-readable markdown
- Incremental updates - Only re-analyze changed files (10-20x faster)
- File change tracking via git diff, hashes, or modification times
- Smart merge logic for updated knowledge
- Hook-based automatic enrichment - No manual command needed
- Transparent coding request detection
- Automatic knowledge base discovery
- Relevance-based entity and workflow retrieval
- Constraint filtering by intent type
- Pass-through for non-coding requests
- Optional manual
/fellowcommand for explicit enrichment
- Knowledge base querying (search entities, workflows, patterns)
- Cross-project knowledge sharing
- Custom constraint definitions
- Integration with external documentation systems
- Real-time knowledge synchronization
- Team collaboration features
# Check if hooks are enabled
/toggle-hooks statusOutput:
✅ Fellow hooks are ENABLED
Coding requests will be automatically enriched with context
To disable: /toggle-hooks off
# Temporarily disable for testing
/toggle-hooks offOutput:
❌ Fellow hooks DISABLED
Automatic enrichment is now off
Use /fellow command for explicit enrichment when needed
# Re-enable when ready
/toggle-hooks onOutput:
✅ Fellow hooks ENABLED
Coding requests will now be automatically enriched with context
cd /path/to/my-python-project
/build-kbOutput:
✓ Knowledge base built successfully!
Target Project: /path/to/my-python-project
Extracted Knowledge:
- Factual: 15 entities, 24 relationships
- Procedural: 8 workflows, 3 patterns
- Conceptual: 4 layers, 12 modules, 5 design patterns
Output Location: /path/to/my-python-project/.fellow-data/semantic/
Files Created:
- factual_knowledge.json (machine-readable entities)
- procedural_knowledge.json (machine-readable workflows)
- conceptual_knowledge.json (machine-readable architecture)
- SEMANTIC_KNOWLEDGE_SUMMARY.md (human-readable comprehensive summary)
# While working on project A, analyze project B
/build-kb /path/to/project-bScenario: Working on an e-commerce project
# Step 1: Build knowledge base
cd /path/to/ecommerce-project
/build-kbOutput:
✓ Knowledge base built successfully!
Target Project: /path/to/ecommerce-project
Extracted Knowledge:
- Factual: 24 entities, 38 relationships
- Procedural: 12 workflows, 6 patterns
- Conceptual: 4 layers, 8 modules, 8 design patterns
Output Location: .fellow-data/semantic/
# Step 2: Use context-enriched coding
/fellow Add a POST endpoint for creating orders with items and payment infoOutput:
📋 Context Loaded from Knowledge Base
Relevant Entities: 5 entities found
- Order (core entity with relationships to User, OrderItem, Payment)
- OrderService (service layer, handles order creation workflow)
- PaymentProcessor (handles payment validation and processing)
- ValidationService (input validation)
- AuthService (authentication and authorization)
Relevant Workflows: 2 workflows found
- Order creation workflow (existing pattern to follow)
- Payment processing workflow (integration points)
Applicable Constraints: 6 constraints apply
- Security: Authentication required for order creation
- Validation: Order items must be validated against inventory
- Performance: Use connection pooling for database operations
- Architectural: API layer cannot directly access database
- Data validation: Payment info must be validated and sanitized
- Resource management: Transaction must be properly committed/rolled back
Key Guardrails:
- MUST authenticate user via AuthService before processing
- MUST validate order items using ValidationService
- MUST use OrderService (service layer) - do not access database directly
- MUST handle payment through PaymentProcessor
- MUST use transaction for order and payment (all-or-nothing)
- SHOULD follow existing API response format (Order entity structure)
[Proceeds with implementation following these guardrails...]
Result: The endpoint is implemented following existing patterns, respecting architectural boundaries, and maintaining consistency with the codebase.
📚 Full documentation available at: https://jingnanzhou.github.io/fellow/
The documentation site includes comprehensive guides for installation, usage, best practices, and more.
- Cheat Sheet - Quick reference for all commands, workflows, and troubleshooting
- Incremental Updates Guide - How incremental updates work and performance details
- Docs Quick Reference - Quick commands for deploying documentation
- README.md - Complete overview and usage guide (this file)
- INSTALLATION.md - Complete installation guide
- CONTRIBUTING.md - Contribution guidelines
- LICENSE - Apache 2.0 license
- MkDocs Deployment Guide - Complete guide for regenerating and publishing documentation
- Docs Quick Reference - Quick commands for documentation workflow
Located in commands/:
build-kb.md- Knowledge base extraction command (full + incremental)fellow.md- Manual context enrichment commandtoggle-hooks.md- Hook management command
Located in agents/:
factual-knowledge-extractor.md- Entity extraction agentprocedural-knowledge-extractor.md- Workflow extraction agentconceptual-knowledge-extractor.md- Architecture extraction agent
Fellow is designed to be:
- Extensible: Add new extraction agents easily
- Customizable: Modify extraction logic per project needs
- Composable: Use extracted knowledge in various workflows
See CONTRIBUTING.md for contribution guidelines.
Apache License 2.0 - See LICENSE for details.
Created by Jingnan Zhou, 2026.
2.1.0 - Automatic enrichment, incremental updates, and logging (Current)
- Hook-based automatic context enrichment - No
/fellowcommand needed - Automatic coding request detection (keywords, entities, imperative mood)
- Transparent knowledge base discovery and loading
- Pass-through for non-coding requests
- Incremental knowledge base updates - 10-20x faster
- Change detection via git diff, file hashes, or modification times
- Smart merge logic for updated entities and workflows
- File registry tracking in
extraction_metadata.json - Comprehensive logging system - Logs all enrichment events
- Logs original prompts, enriched context, detection results, KB stats
- Both JSON and human-readable log formats
- Optional manual
/fellowcommand for explicit enrichment /toggle-hookscommand for easy enable/disable
2.0.0 - Context-enriched coding
- Added
/fellowcommand for context-enriched coding - Intent analysis (create, modify, fix, validate, test, document)
- Knowledge retrieval from KB (entities, workflows, patterns)
- Constraint extraction and guardrail generation
- Architectural awareness during implementation
1.0.0 - Knowledge base extraction
- Initial release with
/build-kbcommand - Parallel extraction of factual, procedural, and conceptual knowledge
- JSON output for machine consumption
- Markdown summary for human readers