Intercept coding requests and enrich with semantic knowledge from the knowledge base
Enriches coding requests with semantic knowledge from your codebase for architecture-aware implementations.
/plugin marketplace add jingnanzhou/fellow/plugin install jingnanzhou-fellow@jingnanzhou/fellowCoding request or task descriptionExecute coding requests with intelligent context from the semantic knowledge base. Automatically retrieves relevant entities, workflows, patterns, and constraints to ensure architecture-consistent implementations.
Transform a user's coding request into a context-enriched task by:
.fellow-data/semantic/Goal: Set up logging for this enrichment session
Actions:
Create a Python script to initialize logging:
import sys
sys.path.insert(0, './hooks')
from logger import get_logger
logger = get_logger()
# Store logger for use in final phase
Store the original user request for logging later
Note: Logging is enabled if logging_enabled: true in .claude-plugin/hooks.json or if FELLOW_LOGGING environment variable is set.
Goal: Load and validate the semantic knowledge base, auto-building if necessary
Actions:
Check if knowledge base exists at .fellow-data/semantic/
If NOT found (first time use):
Output informative message to the conversation (so it appears in chat):
ā ļø **Fellow Knowledge Base Not Found**
This appears to be the first time using Fellow on this project.
To enable context enrichment, Fellow needs to extract semantic knowledge
from your codebase.
**This will take 2-5 minutes** (one-time process).
I can build the knowledge base now and then proceed with your request.
Would you like me to build it?
Important: This message must appear in the chat interface, not just logs
The message is part of your response to the user
Wait for user confirmation before proceeding
If user agrees to build:
/build-kb command automatically:
šØ Building knowledge base for this project...
[Launch /build-kb command]
ā Knowledge base built successfully!
Proceeding with your original request: "{user's request}"
If user declines:
ā¹ļø Knowledge base build cancelled.
To use Fellow later:
1. Run `/build-kb` to extract knowledge (2-5 minutes)
2. Then use `/fellow` or enable automatic enrichment
Your request will proceed without enrichment.
If KB found - Proceed with loading:
factual_knowledge.json - Entities and relationshipsprocedural_knowledge.json - Workflows and execution flowsconceptual_knowledge.json - Architecture and design patternsValidate loaded knowledge:
Error Handling:
/build-kb to regenerate."/build-kb."Goal: Understand what the user wants to accomplish
Actions:
Parse the user's request ($ARGUMENTS)
Identify the primary intent category:
Extract key components from the request:
Determine scope:
Output: Structured intent analysis with category, components, and scope
Goal: Retrieve relevant knowledge from the KB based on intent
Actions:
Search for entities mentioned in the request:
For each matched entity, extract:
Retrieve related entities:
Search for workflows related to the request:
For each matched workflow, extract:
Identify applicable design patterns:
Extract relevant design decisions:
Extract architectural layers:
Identify constraints that apply to this request:
For each applicable constraint, extract:
Output: Structured knowledge package with entities, workflows, patterns, and constraints
Goal: Generate specific coding guardrails based on retrieved knowledge
Actions:
Architectural Guardrails:
Pattern Guardrails:
Constraint Guardrails:
Consistency Guardrails:
Output: Structured guardrails organized by category
Goal: Create enriched context for the coding task
Actions:
Build Context Document with the following sections:
A. Task Summary
B. Relevant Entities
C. Relevant Workflows
D. Applicable Design Patterns
E. Architectural Context
F. Coding Guardrails
G. Related Design Decisions
Format Context for clarity:
Output: Complete enriched context document
Goal: Execute the coding task with full context
Actions:
Present Context to User (summary):
š Context Loaded from Knowledge Base
Relevant Entities: X entities found
Relevant Workflows: Y workflows found
Applicable Constraints: Z constraints apply
Design Patterns: P patterns to follow
Key Guardrails:
- [List 3-5 most critical guardrails]
Execute with Context:
Validation:
Completion Report:
ā Task completed with architectural awareness
Implementation Details:
- Entities modified: [list]
- Patterns applied: [list]
- Constraints verified: [list]
- Files changed: [list]
Goal: Log the enrichment event for analysis and debugging
Actions:
Create a logging script using the Fellow logger:
import sys
import os
sys.path.insert(0, './hooks')
from logger import get_logger
logger = get_logger()
# Log the enrichment event
logger.log_enrichment_event(
original_prompt="$ARGUMENTS",
is_coding_request=True,
intent="[detected intent category]",
confidence=1.0, # Manual command = 100% confidence
kb_found=True,
kb_path=".fellow-data/semantic/",
entities_found=[count of entities retrieved],
workflows_found=[count of workflows retrieved],
constraints_found=[count of constraints applied],
enriched_prompt="[full enriched context that was used]",
source="command"
)
Store logs in .fellow-data/logs/ (or Fellow plugin logs if project logs unavailable)
Log files created:
enrichment_YYYY-MM-DD.jsonl - Machine-readable JSON logsenrichment_YYYY-MM-DD.log - Human-readable logs with full contextNote: Logging is enabled if logging_enabled: true in .claude-plugin/hooks.json or if FELLOW_LOGGING=1 environment variable is set.
The command expects knowledge base files in this structure:
.fellow-data/semantic/
āāā factual_knowledge.json
ā āāā metadata
ā āāā entities[]
ā ā āāā name, type, category, purpose
ā ā āāā attributes[], methods[]
ā ā āāā relationships[]
ā ā āāā invariants[], business_rules[]
ā ā āāā grounding (file, line_start, line_end)
ā āāā entity_relationships[]
ā
āāā procedural_knowledge.json
ā āāā metadata
ā āāā workflows[]
ā āāā name, type, purpose
ā āāā entry_point (file, line, function)
ā āāā steps[] (with file/line references)
ā āāā data_flow, control_flow
ā āāā error_handling
ā āāā pattern
ā
āāā conceptual_knowledge.json
āāā metadata
āāā architecture_style
āāā layers[]
ā āāā name, responsibility
ā āāā components, dependencies
ā āāā constraints
āāā modules[]
ā āāā name, path, responsibility
ā āāā patterns_used[], dependencies[]
ā āāā complexity
āāā design_patterns[]
ā āāā pattern, usage, locations
ā āāā rationale, benefits, trade_offs
ā āāā examples[]
āāā design_decisions[]
ā āāā decision, rationale
ā āāā alternatives_considered[]
ā āāā trade_offs, impact
ā āāā evidence_location
āāā constraints[]
āāā type, constraint
āāā rationale, enforcement
āāā violations
/fellow Add a POST endpoint for user registration with email and password
Context Retrieved:
Guardrails Applied:
/fellow Refactor the payment processing to use the Strategy pattern
Context Retrieved:
Guardrails Applied:
/fellow Add caching to the tool listing API with 60-second TTL
Context Retrieved:
Guardrails Applied:
ā Knowledge base not found
The semantic knowledge base is required for context-enriched coding.
To create the knowledge base, run:
/build-kb
This will analyze the codebase and extract:
- Entities and relationships
- Workflows and patterns
- Architecture and constraints
ā Knowledge base corrupted or incomplete
File: .fellow-data/semantic/[file].json
Issue: [description]
To regenerate the knowledge base, run:
/build-kb
ā ļø Limited context available
No directly relevant entities or workflows found in the knowledge base.
Proceeding with general architectural guidance:
- Architecture style: [from KB]
- Design principles: [from KB]
- General constraints: [from KB]
Entity Matching:
Workflow Matching:
Constraint Filtering:
Priority Levels:
Formatting:
/build-kb to be run first/build-kb