agentleFS
vzwjustinvzwjustin/advisor/CLAUDE.md

advisor

CLAUDE.md9 starsChanged 6 months agoMITView on GitHub

After editing advisor/orchestrate/_prompts/advisor.txt or any prompt builder, regenerate snapshots: ADVISOR_UPDATE_SNAPSHOTS=1 uv run pytest tests/test_prompt_snapshots.py Registry install (post-PyPI publish): UV_NO_CACHE=1 uv tool install --force advisor-agent Two-model team using Claude Code's TeamCreate/Agent/SendMessage. No external API calls. Models configurable via TeamConfig(advisor_model=, runner_model=) — defaults: claude-opus-4-8 / claude-sonnet-4-6. Claude Code's Agent() tool accepts bare aliases (opus, sonnet, haiku) for "always-latest" or full claude-<family>-<version> IDs to pin a specific version; mid-form strings like opus-4-5 are not accepted. Opus does Glob+Grep structural discovery itself — cheap…

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

20 rules. About 0 are common, 15 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

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

    After editing advisor/orchestrate/_prompts/advisor.txt or any prompt builder, regenerate snapshots: ADVISOR_UPDATE_SNAPSHOTS=1 uv run …

    line 9
  2. Very specific:

    Wait for Opus's ## Pool size: N and the Dispatch Plan.

    line 84
  3. Very specific:

    NOT substitute build_runner_pool_prompt(...).

    line 86
  4. Very specific:

    After spawning, tell Opus: "Pool of N runners is up."

    line 104
  5. Distinctive:

    Don't assume. Don't hide confusion.

    line 183
  6. Distinctive:

    If multiple interpretations exist, present them — don't pick silently.

    line 187
  7. Distinctive:

    If a simpler approach exists, say so.

    line 188
  8. Distinctive:

    If something is unclear, stop.

    line 189
  9. Distinctive:

    No features beyond what was asked.

    line 193
  10. Distinctive:

    No abstractions for single-use code.

    line 194
  11. Distinctive:

    No error handling for impossible scenarios.

    line 196
  12. Distinctive:

    If you write 200 lines and it could be 50, rewrite it.

    line 197
  13. Distinctive:

    Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

    line 199
  14. Distinctive:

    When editing existing code:

    line 204
  15. Distinctive:

    Don't "improve" adjacent code, comments, or formatting.

    line 205
  16. Distinctive:

    Don't refactor things that aren't broken.

    line 206
  17. Distinctive:

    If you notice unrelated dead code, mention it — don't delete it.

    line 208
  18. Distinctive:

    When your changes create orphans:

    line 210
  19. Very specific:

    Remove imports/variables/functions that YOUR changes made unused.

    line 211
  20. Distinctive:

    Don't remove pre-existing dead code unless asked.

    line 212

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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
CLAUDE.md

Advisor — Opus-led Agent Team (Claude Code Native)

Environment & Commands

Running tests

uv run pytest fails with "Failed to spawn: pytest" unless dev extras are installed. Always use: uv sync --extra dev && uv run pytest -x -q

After editing advisor/orchestrate/_prompts/advisor.txt or any prompt builder, regenerate snapshots: ADVISOR_UPDATE_SNAPSHOTS=1 uv run pytest tests/test_prompt_snapshots.py

Local install (two-step)

uv tool install --reinstall --from /Users/justinadams/Downloads/advisor advisor-agent
advisor install   # refreshes SKILL.md + CLAUDE.md nudge

Registry install (post-PyPI publish): UV_NO_CACHE=1 uv tool install --force advisor-agent

Git workflow

Uncommitted changes block rebase/merge every time — always stash first: git stash && git pull --rebase origin main && git stash pop

Advisor pipeline gotchas

  • SendMessage with a string message requires a summary param or it errors: summary is required when message is a string
  • Agent model field: only bare aliases (opus, sonnet, haiku) or full IDs (claude-opus-4-8) — mid-form strings like opus-4-8 error (advisor CLI normalizes these automatically)
  • CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 must be set in env for TeamCreate/TeamDelete/SendMessage

Large files (>800 LOC → 3-fix cap in advisor pipeline)

  • advisor/__main__.py ~3400–3600 LOC
  • advisor/rank.py ~1186 LOC
  • advisor/install.py ~890 LOC
  • advisor/orchestrate/runner_prompts.py ~813 LOC

Rust port

cargo test accepts only one test-name pattern; cargo test foo bar errors — use single name or no filter.

Two-model team using Claude Code's TeamCreate/Agent/SendMessage. No external API calls. Models configurable via TeamConfig(advisor_model=, runner_model=) — defaults: claude-opus-4-8 / claude-sonnet-4-6. Claude Code's Agent() tool accepts bare aliases (opus, sonnet, haiku) for "always-latest" or full claude-<family>-<version> IDs to pin a specific version; mid-form strings like opus-4-5 are not accepted.

Team Roles

RoleDefault ModelAgent TypeJob
AdvisorOpus 4.8 (claude-opus-4-8)generalPurposeGlob+Grep discovery, ranks P1–P5, sizes runner pool, writes a unique, file-aware prompt for every runner, dispatches explore + fix waves, live dialogue with runners, verifies each output as it lands
RunnerSonnet 4.6 (claude-sonnet-4-6)generalPurposeReads files, finds issues, implements fixes. Each runner gets a domain-specific prompt from the advisor — not a generic template. Works ONLY on what the advisor hands it. In constant two-way conversation with the advisor (via team-lead relay).

Pipeline

Step 1: Create Team

TeamDelete()  # clean slate
TeamCreate(name="review")

Step 2: Spawn Opus advisor FIRST (no runners yet)

Opus does Glob+Grep structural discovery itself — cheap for its large context window and the map is its to keep. It ranks files P1–P5 and decides how many runners to spawn based on the codebase size (no hardcoded default). It opens its report with ## Pool size: N — <rationale>, followed by a Dispatch Plan that includes a complete, custom prompt for every runner — tailored to the files in that runner's batch using context from its discovery pass.

Agent(
  name="advisor",
  subagent_type="generalPurpose",
  model="claude-opus-4-8",
  team_name="review",
  prompt=<build_advisor_prompt(config)>
)

The advisor prompt encodes interleaved thinking (reason between every tool call, contemplate before committing, pivot when evidence reframes the problem) and the full review-and-fix loop.

Step 3: Spawn runners with the advisor's per-runner prompts

Wait for Opus's ## Pool size: N and the Dispatch Plan. Spawn exactly N runners using Opus's verbatim per-runner prompts — do NOT substitute build_runner_pool_prompt(...). The whole point of having Opus go first is that each runner gets a powerful, domain- specific briefing written by the strategist who just read the structural map.

Runners are long-lived — reused across assignments for context accumulation.

Agent(
  name="runner-1",
  subagent_type="generalPurpose",
  model="claude-sonnet-4-6",
  team_name="review",
  run_in_background=true,
  prompt=<verbatim text from Opus's "### runner-1 / #### Prompt" block>
)

After spawning, tell Opus: "Pool of N runners is up."

Step 4: Live dialogue — explore wave

Opus dispatches explore assignments to runners via SendMessage(to='runner-N'). Runners send all replies — questions, progress pings, draft findings, final reports — to team-lead, who relays each one verbatim to the advisor. The advisor responds directly to the runner. Throughout:

  • Runners ask questions when stuck, send progress pings (to team-lead → advisor)
  • Opus answers in real time, shares context between runners
  • Opus verifies each runner's output the moment it lands (CONFIRM / NARROW / REDIRECT)
  • Opus proactively redirects runners that drift off-scope

Step 5: Fix wave (if user asked for enhancements/fixes)

Opus reasons over all findings, builds a fix plan, then dispatches fix assignments to the same runner pool. Runners implement changes, submit diffs to Opus for review before finalizing.

Step 6: Final report + shutdown

Opus sends the final structured report to team-lead. Shut down individually:

SendMessage({ to: "advisor",  message: { type: "shutdown_request" } })
SendMessage({ to: "runner-1", message: { type: "shutdown_request" } })
TeamDelete()

Rules

  1. TeamDelete before TeamCreate — one team at a time.
  2. Opus goes first — no runners before Opus's first pass.
  3. No hardcoded pool size — Opus decides every time.
  4. Runner prompts come from Opus, not a template — use the per-runner prompts in Opus's dispatch plan verbatim.
  5. Runners work ONLY on what Opus hands them.
  6. Live dialogue, not checkpoints — runners talk to Opus constantly.
  7. Runner reports go to team-lead; team-lead relays to the advisor — verbatim, the moment they arrive. Do not batch or summarize.
  8. Every prompt ends with SendMessage-back.
  9. Shutdown individually, not broadcast.
  10. Fence untrusted data in Opus prompts (code blocks).

Python API

from advisor import (
    default_team_config,       # TeamConfig with advisor_model/runner_model
    build_advisor_agent,       # Opus agent spec
    build_advisor_prompt,      # Opus prompt (interleaved thinking + full loop)
    build_runner_pool_agents,  # Sonnet pool agent specs (fallback path)
    build_runner_pool_prompt,  # generic runner prompt (fallback only — live pipeline uses Opus's per-runner prompts)
    build_runner_dispatch_messages,  # SendMessage specs per batch
    build_verify_message,      # SendMessage to resume advisor for verification
    render_pipeline,           # Print pipeline reference
)

Activation

Invoke via /advisor slash command. Full protocol details in ~/.claude/skills/advisor/SKILL.md.

Setup

uvx --from advisor-agent advisor install  # install from PyPI
uv sync                   # sync dependencies (dev)
uv run pytest             # run tests
python -m advisor         # run locally

Behavioral Guidelines

Reduce common LLM coding mistakes. Merge with project-specific instructions as needed.

Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

Before implementing:

  • State your assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them — don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

When editing existing code:

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it — don't delete it.

When your changes create orphans:

  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Transform tasks into verifiable goals:

  • "Add validation" → "Write tests for invalid inputs, then make them pass"
  • "Fix the bug" → "Write a test that reproduces it, then make it pass"
  • "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:

1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]

Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.

These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.

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.