agentleFS
supportersimulatorsupportersimulator/3-surgeons/skills/using-3-surgeons/SKILL.md

using-3-surgeons

Skill2 starsChanged 9 months agoMITView on GitHub

Bootstrap skill — teaches the 3-Surgeons multi-model consensus philosophy, surgeon roles, tool access, and when to invoke other skills

  • Reads credentials

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All 3-Surgeons operations are available through two interfaces:

    line 36
  2. Very specific:

    When the MCP server is running (python -m three_surgeons.mcp.server), the same operations are available as typed MCP tools:

    line 60
  3. Distinctive:

    If you think there is even a 1% chance an invariance gate should fire, you ABSOLUTELY MUST invoke it.

    line 78
  4. Distinctive:

    When the review-loop skill auto-selects mode, it evaluates these dimensions.

    line 175
  5. Distinctive:

    If the surgeons aren't configured yet, invoke the setup-team skill.

    line 233
  6. Very specific:

    All cross-examinations, cost tracking, A/B results, and learnings are persisted to ~/.3surgeons/evidence.db (SQLite with FTS5).

    line 249

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Using 3-Surgeons

Philosophy

"The value is in the disagreements, not the agreements."

Three LLMs with different training, different biases, and different blind spots cross-examine each other on critical decisions. Claude may confabulate confidently where GPT hedges. A local 4B model catches patterns that API models miss due to token limits. When all three agree, confidence is high. When they disagree, you have found the exact spot that needs human judgment.

The Three Surgeons

SurgeonModelRoleCost
Atlas (Head Surgeon)Claude (this session)Synthesizes, decides, implements$0 (session)
CardiologistGPT-4.1-mini (OpenAI API)External perspective, cross-examination, evidence review~$0.40-1.60/1M tokens
NeurologistQwen3-4B (local Ollama/MLX)Pattern recognition, corrigibility checks, classification$0 (local)

Atlas is always available -- it is the Claude session itself. The Cardiologist and Neurologist are external models accessed via the 3s CLI or MCP tools.

Constitutional Physics

These principles outrank all other preferences:

  1. Preserve Determinism -- same inputs must produce the same outputs. If not, enter safe mode.
  2. No Discovery at Injection -- injection is retrieval + assembly only. No learning or promotion during injection.
  3. Evidence Over Confidence -- outcomes determine truth. Confidence tracks empirical rates, not feelings.
  4. Prefer Reversible Actions -- checkpoint before risk, canary before rollout.
  5. Minimalism -- maximum value density. Scalpel, not axe.

Tool Access

All 3-Surgeons operations are available through two interfaces:

CLI (3s command)

3s probe                        # Health check all surgeons
3s cross-exam "topic"           # Full cross-examination (uses config default mode)
3s cross-exam "topic" --mode iterative  # Cross-exam with explicit review depth
3s consult "topic"              # Quick parallel query
3s consensus "claim"            # Confidence-weighted vote
3s sentinel "content"           # Complexity vector scan
3s gains-gate                   # Infrastructure health gate
3s ab-propose PARAM A B "hyp"   # Propose A/B test
3s mode                         # Show current review depth + auto-depth setting
3s mode continuous              # Set default review depth
3s mode iterative --duration 7d # Set mode with expiry (session|7d|30d|permanent)
3s review-weights               # Show learned mode weights
3s review-weights show          # Same as above
3s review-weights export -o weights.json  # Export outcomes for sharing
3s review-weights import weights.json     # Import outcomes from another machine

MCP Tools

When the MCP server is running (python -m three_surgeons.mcp.server), the same operations are available as typed MCP tools:

MCP ToolCLI Equivalent
probe3s probe
cross_examine3s cross-exam
consult3s consult
consensus3s consensus
sentinel_run3s sentinel
gains_gate3s gains-gate
ab_propose3s ab-propose
ab_start(lifecycle management)
ab_measure(lifecycle management)
ab_conclude(lifecycle management)

Invariance Gate System

<EXTREMELY-IMPORTANT> If you think there is even a 1% chance an invariance gate should fire, you ABSOLUTELY MUST invoke it. This is not optional. </EXTREMELY-IMPORTANT>

Signal-Based Trigger Table

These signals map to required skills. When ANY signal is present, invoke the corresponding skill BEFORE proceeding:

SignalRequired SkillPriority
Architectural decision, new subsystem, restructurearchitectural-gateHARD-GATE
>3 files will changearchitectural-gateHARD-GATE
Security/auth/crypto code touchedarchitectural-gateHARD-GATE
New dependency or external integrationarchitectural-gateHARD-GATE
Database schema changearchitectural-gateHARD-GATE
API surface change (new/modified endpoints)architectural-gateHARD-GATE
Config/infrastructure changearchitectural-gateHARD-GATE
About to implement a plan (writing-plans done)pre-implementation-reviewHARD-GATE
About to claim "done" or "complete"post-implementation-verificationHARD-GATE
High confidence + low evidencecounter-positionHARD-GATE
Single surgeon dominates consensuscounter-positionHARD-GATE
Sentinel risk >= highcross-examination + counter-positionEscalation
Cross-exam starting (any trigger)review-loopHARD-GATE
Every 10 gate invocationsinvariance-healthAutomatic
Gate override rate >30%invariance-healthAutomatic

Existing Skills

SituationSkill to InvokeWhy
Cross-exam about to startreview-loopSelects review depth (single/iterative/continuous) based on risk
First run, surgeons not configuredsetup-teamHead surgeon guides team assembly
Session start, after infra changesprobeVerify all surgeons are reachable
Validating a claim or assumptionconsensusQuick confidence-weighted vote
Before critical operationssentinelScan for complexity risks
Between major phasesquality-gates (gains-gate)Verify infrastructure health
Before risky/destructive actionsquality-gates (corrigibility)Check action against safety invariants
Quality degradation detectedquality-gates (cardio-gate)Rate-limited quality review chain
Optimizing prompts or parametersab-testingControlled experiments with safety rails

Decision Flowchart

Any signal from trigger table?
  YES -> Invoke the required skill (HARD-GATE — blocks until gate passes)
  NO  -> Is this a critical decision?
    YES -> Does it affect >3 files or core architecture?
      YES -> cross-examination (full 3-phase)
      NO  -> consensus (quick weighted vote)
    NO  -> Is this a health/infra check?
      YES -> probe (connectivity) or gains-gate (full health)
      NO  -> Is this a complexity/risk assessment?
        YES -> sentinel (vector scan)
        NO  -> Proceed without surgeon consultation

Invariance Workflow Chain

The full workflow when an architectural signal fires:

Signal detected
  → architectural-gate (risk stratification → Light/Standard/Full)
    → review-loop (selects depth: single/iterative/continuous)
      → [brainstorming] (superpowers skill)
        → [writing-plans] (superpowers skill)
          → pre-implementation-review (HARD-GATE before coding)
            → [executing-plans] (superpowers skill)
              → post-implementation-verification (HARD-GATE before "done")
                → completion

Every 10 gates: invariance-health retrospective (metacognition)

This chain integrates with superpowers' process invariance. 3-Surgeons adds epistemological invariance (truth calibration) on top of superpowers' workflow discipline.

Review Loop Modes

Cross-examinations support three review depth modes that control how many iteration passes the surgeons make. The review-loop skill (see skills/review-loop/SKILL.md) fires as a HARD-GATE before every cross-exam to select the appropriate depth.

Modes

ModeMax IterationsWhen to Use
single1Config changes, docs, small fixes, <=2 files changed
iterativeup to 3Multi-file changes, new features, refactors (3-10 files)
continuousup to 5Security, schema, API, architecture changes, >10 files

Mode Resolution Order

The mode used for a cross-exam is determined by (highest priority first):

  1. CLI --mode flag -- 3s cross-exam "topic" --mode continuous
  2. Config default -- review.depth in .3surgeons.yaml or ~/.3surgeons/config.yaml
  3. Adaptive weights -- when auto_review_depth: auto, learned weights from past outcomes influence mode selection

Risk Stratification Reference

When the review-loop skill auto-selects mode, it evaluates these dimensions. The highest-risk dimension wins:

Dimensionsingleiterativecontinuous
Files changed1-23-10>10
ReversibilityFully reversiblePartially reversibleHard to reverse
Security exposureNoneInternalExternal/auth
Data impactRead-onlySchema-preservingSchema-changing
External couplingNoneInternal APIsPublic APIs

Exit Conditions

  • Consensus >= 0.7 on "all issues addressed" -- exits the loop early
  • Max iterations reached without consensus -- escalates to human with unresolved summary
  • User override at any point -- respected immediately

Conversational Mode Switching

Users can set review depth through natural language. The agent maps intent to mode:

User SaysMaps To
"quick review", "just a glance"single
"thorough review", "check carefully"iterative
"loop until satisfied", "full depth", "keep going"continuous
"3-surgeons full"continuous

Managing Modes via CLI

# Show current mode and auto-depth setting
3s mode

# Set default depth (permanent unless --duration specified)
3s mode continuous
3s mode iterative --duration session   # Reverts after session ends
3s mode single --duration 7d           # Reverts after 7 days

# View learned weights from past review outcomes
3s review-weights

# Share weights across machines
3s review-weights export -o weights.json
3s review-weights import weights.json

Auto-Depth Behavior

Controlled by the auto_review_depth config setting:

SettingBehavior
offAlways uses config default or CLI flag. No adaptation.
suggestRecommends a mode with reasoning, waits for confirmation before proceeding.
autoApplies learned weights from past outcomes. User can override anytime.

First-Run Setup

If the surgeons aren't configured yet, invoke the setup-team skill. It guides the user through assembling their team conversationally — detecting local backends, configuring API keys securely, and verifying connectivity. Low pressure, practical, gets the team running in under a minute.

Configuration

Config lives in ~/.3surgeons/config.yaml or .3surgeons.yaml in the project root. Run 3s init for interactive setup, or use the setup-team skill for a guided experience. See config/3surgeons.example.yaml for the full schema.

Config merges across tiers: defaults → ~/.3surgeons/config.yaml → .3surgeons.yaml. Each layer only overrides what it explicitly sets — unset fields inherit from the layer below. This means a project config only needs to specify what's different from your user-level config.

Key settings:

  • surgeons.cardiologist -- endpoint, model, API key env var, optional fallbacks list
  • surgeons.neurologist -- endpoint, model, optional fallbacks list
  • budgets.daily_external_usd -- daily spend cap (default $5, enforced before external calls)
  • budgets.autonomous_ab_usd -- per-test cost cap (default $2)

Evidence Store

All cross-examinations, cost tracking, A/B results, and learnings are persisted to ~/.3surgeons/evidence.db (SQLite with FTS5). This provides institutional memory across sessions -- the system learns from its own decisions.

Supported Providers

Any endpoint implementing the OpenAI /v1/chat/completions API works with zero code changes.

ProviderEndpointModelsAPI Key EnvCost
OpenAIhttps://api.openai.com/v1gpt-4.1-mini, gpt-4.1, o3OPENAI_API_KEY$0.10-8.00/1M
Anthropichttps://api.anthropic.com/v1claude-sonnet-4, claude-haiku-4.5ANTHROPIC_API_KEY$0.80-15.00/1M
Googlehttps://generativelanguage.googleapis.com/v1beta/openaigemini-2.5-pro, gemini-2.5-flashGOOGLE_API_KEY$0.15-10.00/1M
DeepSeekhttps://api.deepseek.com/v1deepseek-chat, deepseek-reasonerDEEPSEEK_API_KEY$0.27-2.19/1M
Groqhttps://api.groq.com/openai/v1llama-3.3-70b, llama-3.1-8bGROQ_API_KEY$0.05-0.79/1M
xAI (Grok)https://api.x.ai/v1grok-2, grok-2-miniXAI_API_KEY$0.30-10.00/1M
Mistralhttps://api.mistral.ai/v1mistral-large, mistral-smallMISTRAL_API_KEY$0.10-6.00/1M
Coherehttps://api.cohere.com/v2command-r-plus, command-rCOHERE_API_KEY$0.15-10.00/1M
Perplexityhttps://api.perplexity.aisonar-pro, sonarPERPLEXITY_API_KEY$1.00-15.00/1M
Togetherhttps://api.together.xyz/v1Llama-3.3-70B, Llama-3.1-8BTOGETHER_API_KEY$0.18-0.88/1M
Ollamahttp://localhost:11434/v1Any pulled modelnone$0 (local)
LM Studiohttp://localhost:1234/v1Any loaded modelnone$0 (local)
vLLMhttp://localhost:8000/v1Any served modelnone$0 (local)

Quick Provider Swap Examples

DeepSeek as Neurologist (cheap API, no local LLM needed):

neurologist:
  provider: deepseek
  endpoint: https://api.deepseek.com/v1
  model: deepseek-chat
  api_key_env: DEEPSEEK_API_KEY

Groq as Cardiologist (ultra-fast inference):

cardiologist:
  provider: groq
  endpoint: https://api.groq.com/openai/v1
  model: llama-3.3-70b-versatile
  api_key_env: GROQ_API_KEY

Grok as Cardiologist (xAI alternative):

cardiologist:
  provider: xai
  endpoint: https://api.x.ai/v1
  model: grok-2
  api_key_env: XAI_API_KEY

Cardiologist with automatic failover (try OpenAI, fall back to DeepSeek):

cardiologist:
  provider: openai
  endpoint: https://api.openai.com/v1
  model: gpt-4.1-mini
  api_key_env: OPENAI_API_KEY
  fallbacks:
    - provider: deepseek
      endpoint: https://api.deepseek.com/v1
      model: deepseek-chat
      api_key_env: DEEPSEEK_API_KEY

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.