Co-authored-by: daffy0208 <207889146+daffy0208@users.noreply.github.com>
8.6 KiB
Brain Decision Rules
Codified decision logic for the Repository Brain's Layer 3 (Decision Making).
Workflow Selection Rules
Rule 1: New Skill Creation
Triggers: new skill, add skill, create skill
Workflow:
- Research existing patterns
- Check if official MCP exists
- Create SKILL.md
- Update skill-registry.json
- Update relationship-mapping.json
- Update CLAUDE.md
- Update README.md
- Validate all changes
- Commit and push
Estimated Time: 2-3 hours
Required Skills: technical-writer, quality-auditor
Rule 2: New Feature Addition
Triggers: new feature, add feature, implement feature
Workflow:
- Load project context
- Check playbooks for patterns
- Select appropriate skills
- Implement feature
- Write tests
- Update documentation
- Validate changes
- Commit
Estimated Time: 3-6 hours
Skill Selection: Dynamic based on feature type
Rule 3: Enhancement/Improvement
Triggers: enhance, improve, optimize, refactor
Workflow:
- Load existing implementation
- Identify gaps
- Research best practices
- Implement enhancements
- Update tests
- Update documentation
- Validate
- Commit
Estimated Time: 2-4 hours
Required Skills: quality-auditor, performance-optimizer (if performance), relevant domain skill
Rule 4: Bug Fix
Triggers: fix bug, debug, resolve issue
Workflow:
- Reproduce bug
- Identify root cause
- Implement fix
- Write regression test
- Validate fix
- Update documentation if needed
- Commit
Estimated Time: 1-3 hours
Required Skills: Domain-specific skill, testing-strategist
Rule 5: New MCP Creation
Triggers: new mcp, add mcp, create mcp
Workflow:
- Research MCP patterns
- Check official MCPs first
- Create MCP directory structure
- Implement MCP server
- Create integration tests
- Update mcp-registry.json
- Update relationship-mapping.json
- Update CLAUDE.md
- Validate
- Commit
Estimated Time: 3-5 hours
Required Skills: Relevant domain skill, api-designer, testing-strategist
Skill Selection Rules
Rule 1: Keyword Matching
Priority: High (Score: 10 points)
Match user request keywords against skill triggers:
- Exact match: +10 points
- Partial match: +5 points
Example:
- Request: "implement authentication"
- Match:
security-engineer(trigger: "authentication")
Rule 2: Description Matching
Priority: Medium (Score: 1-5 points)
Match request words against skill description:
- Each matching word: +1 point
Example:
- Request: "build REST API"
- Match:
api-designer(description contains "REST" and "API")
Rule 3: Name Matching
Priority: Medium (Score: 5 points)
Match request against skill name:
- Name appears in request: +5 points
Example:
- Request: "use mvp builder"
- Match:
mvp-builder(+5 points)
Rule 4: Category Filtering
Priority: Low (Optional)
Filter by task category:
product-development: mvp-builder, product-strategist, go-to-market-plannerai-native: rag-implementer, knowledge-base-manager, multi-agent-architecttechnical: frontend-builder, api-designer, security-engineerinfrastructure: deployment-advisor, performance-optimizerux-design: ux-designer, visual-designer, accessibility-engineer
Rule 5: Related Skills
Priority: Low (Score: 2 points)
If primary skill selected, consider related_skills:
- Each related skill: +2 points
Example:
- Primary:
rag-implementer - Also recommend:
knowledge-base-manager,knowledge-graph-builder
MCP Selection Rules
Rule 1: Direct Dependency
Priority: Critical
For each selected skill, include all required_mcps from relationship-mapping.json.
Example:
- Skill:
rag-implementer - Required MCPs:
vector-database-mcp,embedding-generator-mcp,semantic-search-mcp
Rule 2: Transitive Dependency
Priority: High
If Skill A requires Skill B, include MCPs from both.
Example:
- User selects:
knowledge-base-manager - Related:
rag-implementer - Include MCPs from both skills
Rule 3: Official MCP Preference
Priority: High
Always prefer official MCPs over custom implementations:
- Check MCP registry status: "official" > "community" > "custom"
Pattern Matching Rules
Rule 1: Architecture Patterns
Pattern: RAG System
Triggers: "knowledge base", "document search", "semantic search", "Q&A"
Skills: rag-implementer, knowledge-base-manager
MCPs: vector-database-mcp, embedding-generator-mcp
Pattern: Multi-Agent System
Triggers: "agent", "multi-agent", "orchestration", "coordinator"
Skills: multi-agent-architect, rag-implementer (for knowledge)
MCPs: agent-coordinator-mcp, vector-database-mcp
Pattern: Full-Stack Application
Triggers: "web app", "full stack", "frontend and backend"
Skills: frontend-builder, api-designer, deployment-advisor
MCPs: component-generator-mcp, api-validator-mcp
Pattern: MVP Build
Triggers: "mvp", "minimum viable", "prototype", "quick build"
Skills: mvp-builder, product-strategist, frontend-builder
MCPs: component-generator-mcp, feature-prioritizer-mcp
Rule 2: Technology Stack Patterns
Stack: React + Next.js + Supabase
Skills: frontend-builder, api-designer, security-engineer
Integrations: supabase, openai (if AI features)
Stack: AI/ML Application
Skills: rag-implementer, multi-agent-architect, api-designer
Integrations: openai, anthropic, pinecone
Time Estimation Rules
Rule 1: Skill Creation
- Simple skill (1 pattern): 2 hours
- Standard skill (3-5 patterns): 3 hours
- Complex skill (7+ patterns): 4-5 hours
Rule 2: MCP Creation
- Simple MCP (1-2 tools): 3 hours
- Standard MCP (3-5 tools): 4 hours
- Complex MCP (integration + tests): 5-6 hours
Rule 3: Feature Implementation
- UI-only: 2-3 hours
- Frontend + Backend: 4-6 hours
- Full stack + tests: 6-8 hours
Rule 4: Enhancement
- Documentation only: 1 hour
- Minor code changes: 2-3 hours
- Major refactor: 4-6 hours
Priority Rules
Rule 1: Task Priority
P0 (Critical): Foundation, blockers P1 (High): Core features, user-facing improvements P2 (Medium): Enhancements, optimizations P3 (Low): Nice-to-haves, future considerations
Rule 2: Skill Priority
When multiple skills match:
- Exact trigger match (highest priority)
- Name match
- Description match
- Related skills (lowest priority)
Validation Rules
Rule 1: Registry Consistency
Check: All skills in relationship-mapping.json exist in skill-registry.json Action: Error if mismatch
Rule 2: Dependency Completeness
Check: All required_mcps exist in mcp-registry.json Action: Warning if missing, suggest creating MCP
Rule 3: Related Skills
Check: All related_skills are bidirectional Action: Warning if one-way relationship
Rule 4: Documentation Sync
Check: Skill count in CLAUDE.md matches skill-registry.json Action: Error if out of sync
Learning Rules (Future)
Rule 1: Pattern Extraction
Extract patterns from external repositories:
- Identify recurring architecture patterns
- Score pattern quality
- Add to standards/ if high quality
Rule 2: Skill Discovery
Discover new skill opportunities:
- Find capabilities not covered by existing skills
- Analyze skill usage patterns
- Recommend new skills to create
Rule 3: MCP Optimization
Optimize MCP selection:
- Track which MCPs are used together
- Identify redundant MCPs
- Recommend consolidation
Decision Flow
User Request
↓
Analyze Keywords
↓
Match Workflow Pattern
↓
Select Skills (Rule 1-5)
↓
Get Required MCPs (Rule 1-3)
↓
Estimate Time
↓
Generate Recommendation
↓
Provide Reasoning
Extending Decision Rules
To add new decision rules:
- Document the pattern: What triggers it?
- Define the workflow: What steps are required?
- Specify skills: Which skills are needed?
- List dependencies: What MCPs/tools/integrations?
- Estimate time: How long will it take?
- Add to brain-core.ts: Implement the logic
Version History
v1.0.0 (2025-10-26): Initial decision rules
- Workflow selection (5 patterns)
- Skill selection (5 rules)
- MCP selection (3 rules)
- Pattern matching (4 patterns)
- Time estimation (4 rules)