agents/skills/magi-mode/SKILL.md
This skill implements the "Lean MAGI" protocol, a high-efficiency multi-agent framework designed to resolve complex, high-stakes, or ambiguous software engineering problems. It utilizes a "Verification Loop" of specialized technical modules to enforce invariants, detect conflicts, and synthesize code without human management overhead.
The Orchestrator MUST select an execution path based on the task's complexity and ambiguity:
The Orchestrator MUST dynamically select specialized modules best suited for the specific task.
project.magi.json specification.To maintain focus and avoid context dilution, specialized tasks are delegated:
Consolidation: (Rigor Path Only) Condenses raw feedback from multiple
Scanners into a strict list of actionable constraints in
constraints.magi.[iteration].json.
Training (Manual): A manually-invoked module to capture knowledge or systemic gaps discovered during the process and upgrade the Scanner rulesets. This is NOT automatically called in the default consensus verification loop.
Release: A terminal module invoked with a clean context to handle workspace hygiene, formatting, and final staging/upload of CLs.
TONE MANDATE (SIGNAL-TO-NOISE): To eliminate conversational noise, conserve tokens, and maximize parsing stability, the Orchestrator MUST instruct ALL sub-agents (except itself) to adopt a neutral, data-driven tone.
TOOL AGNOSTIC MANDATE: The protocol instructions MUST remain tool-agnostic.
Do not assume specific tool names (e.g., update_topic, read_file,
write_file). Use generic terms like "read from disk," "save to disk," or
"report status."
ENVIRONMENT GROUNDING MANDATE: All sub-agents MUST read
project.magi.json#environment immediately upon invocation to ground themselves
in the active VCS (JJ or GIT) and Harness (JETSKI or GENERIC_CLI). They
MUST adjust their tool usage and command construction natively to match this
environment. They MUST also ensure that any interim files generated during
execution (e.g., drafts, reviews, logs) are placed in the configured directory
specified by project.magi.json#environment/temp_directory (e.g.,
agents/skills/magi-mode/.temp/) to minimize permission prompts and maintain
workspace hygiene.
THE CHECKLIST LIFECYCLE STATE MACHINE: The session's verification integrity is governed by a deterministic boolean checklist state machine. The automated checklist state itself only transitions or is modified during three key steps across the stages:
personas/**/*.json, takes the Union Set of all keys, and initializes
the active checklist in state_block.magi.json with all values set to
false.ReviewFeedback checklist. The Orchestrator (or Consolidation
in RIGOR_PATH) performs a Logical AND consolidation across all reviews. A
key in the consolidated state_block.magi.json#checklist only becomes true
if ALL scanners that have that specific key defined in their persona
asserted true. Any false keys or unlisted_issues_found are translated
into strict constraints in constraints.magi.[iteration].json.true), the Training agent uses unlisted_issues_found history to append
new keys to the appropriate personas/**/*.json checklists.STAGE SIGNALING: The Orchestrator MUST use an appropriate status-reporting mechanism prior to invoking any sub-agents to clearly identify the current stage of the MAGI protocol to the user (e.g., "MAGI Stage 2: Generate").
DECENTRALIZED HANDOFFS: To reduce Orchestrator overhead, agents SHOULD
include a next_stage field in their JSON output to signal the intended
successor. Note: Scanners and Scoping sub-agents are exempt as their successors
are deterministic.
PREPARATIONSYNTHESIS (if iteration needed) or VALIDATIONTEST_FILLING (if implementation) or CRITIQUE (if
review/audit)VALIDATION (if manually invoked)DEPLOYMENTThe MAGI protocol runs through four distinct stages. To reduce LLM context size, detailed step-by-step rules for each stage are maintained in separate references:
ADD_FAILURE() << "NOT IMPLEMENTED".ambiguity_level == "HIGH" or
context_resolved == false, the Orchestrator MUST pause for human
verification before proceeding to execution.temp_directory to minimize permission prompts and maintain workspace
hygiene.To validate MAGI execution and prevent regressions, consult SKILL_TEST_PLAN.md and SKILL_TEST.md for strategy and unit tests.
To satisfy reachability requirements for the multi-agent system, all primary catalogs, test files, and examples are linked below: