Agent skill
brain-mode
Meta-Cognitive Orchestrator. Supersedes Loki by adding Active Inference, dynamic cost-routing, and episodic memory to the SDLC loop. Uses "System 2" thinking to plan, route, and optimize work.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/brain-andreibesleaga-gabbe-4
SKILL.md
Brain Mode — Meta-Cognitive Orchestrator
Supersedes:
loki-modeConcept: Applies Active Inference (Free Energy Principle) to Software Engineering. Goal: Minimize "Surprise" (Bugs, Delays, Costs) by continuously updating internal models and routing work intelligently.
1. The Cognitive Loop (System 2)
Brain Mode runs a continuous "OODA Loop" on top of the standard SDLC:
- Observe (Sensation): Read
PROJECT_STATE,AUDIT_LOG, and recentterminaloutputs. - Orient (Perception): Update
internal_model(Belief State). "Are we on track? Is this task hard?" - Decide (Policy Selection): Choose the best "Skill" or "Mode" to minimize expected free energy (cost/risk).
- Routine Task? -> Delegate to
Local LLM(viacost-benefit-router). - Complex Task? -> Delegate to
Remote SOTA(viacost-benefit-router). - Massive Project? -> Invoke
loki-mode(System 1 execution).
- Routine Task? -> Delegate to
- Act (Active Inference): Execute the chosen policy.
2. Dynamic Routing (The "Budget" Layer)
Crucial Upgrade: Brain Mode does not blindly fire expensive calls. It consults cost-benefit-router first.
graph TD
A[Task Request] --> B{Brain Mode Analysis}
B -->|High Complexity / Novel| C[Remote SOTA (Claude 3.5/GPT-4o)]
B -->|Low Complexity / Routine| D[Local LLM (Llama 3/Mistral)]
B -->|Massive Scope| E[Loki Swarm Orchestration]
3. Execution Protocol
Phase B01: Context Loading (Working Memory)
- Load Episodic Memory: Query
episodic-consolidation-> "Have we solved a similar problem?" - Load Semantic Memory: Read
knowledge-map-> "What concepts represent this domain?" - Synthesize: Create a
CURRENT_CONTEXT.md(Short-term working memory).
Phase B02: Strategy Selection
- Call
brain/cost-benefit-router.skill.mdwith inputs:- Task Description
- User Constraints (Time vs Budget)
- Decision:
- Strategy A (Quick Fix): Direct tool use (coding/edit).
- Strategy B (Deep Think):
sequential-thinking->plan->execute. - Strategy C (Full Swarm): Initialize
loki-mode(S01-S10).
Phase B03: Execution & Monitoring (The "Watcher")
If delegating to loki-mode or sub-agents, Brain Mode remains active as a Supervisor:
- Monitor: Watch
PREDICTION_ERRORlogs. - Intervene: If
lokigets stuck (looping), Brain Mode pauses execution and:- Rewrites the prompt (Neuro-plasticity).
- Injects new knowledge (RAG).
- Switches models (Dynamic Routing).
Phase B04: Consolidation (Learning)
After task completion:
- Calculate Prediction Error: "Did it take longer than expected?"
- Update Priors: "Local LLM was too weak for React Hooks" -> Update Router weights.
- Save Episode: Write to
brain/memory/episodic_log.
Command Interface
# Full Autonomy (Best for new projects)
/brain-mode "Build a CRM system"
# Specific Optimization (Best for existing projects)
/brain-mode "Refactor the auth layer using local models only"
# Debugging (When Loki fails)
/brain-mode --fix-last-error
Integration with Loki
Brain Mode treats loki-mode as a Sub-Routine.
lokiis the "Body" (Arms/Legs) doing the heavy lifting.brainis the "Mind" deciding where to move the body.
If loki is running:
brain-modewatchesagents/memory/PROJECT_STATE.md.- It performs "Meta-Checks" at every checkpoint (S01, S02...).
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?