Skip to content

feat: extract grand-admiral skill, candy economy, adversarial roles - #30

Merged
lklimek merged 7 commits into
mainfrom
feat/grand-admiral-skill
Apr 29, 2026
Merged

feat: extract grand-admiral skill, candy economy, adversarial roles#30
lklimek merged 7 commits into
mainfrom
feat/grand-admiral-skill

Conversation

@lklimek

@lklimek lklimek commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Grand-admiral skill extraction: Move ~175 lines of multi-agent orchestration doctrine (spawning, worktree isolation, team coordination, scaling, recovery, anti-patterns, planning, crew roster, skills reference) from the claudius agent prompt into a dedicated skills/grand-admiral/SKILL.md skill. The agent prompt drops from 206 to ~30 lines — personality and role focus only — improving resilience to context compaction.
  • Agent reuse doctrine: Add SendMessage reuse pattern (prefer messaging running agents over spawning fresh ones for follow-up work) with corresponding anti-pattern feat: add GitHub MCP server integration #10.
  • Bilby vs Marvin adversarial split: Clarify the builder/breaker contract in the crew roster — Bilby builds and fixes, Marvin proves code wrong and never fixes. Add fix-routing pattern note.
  • Candy economy formalization: Dedicated section with per-agent candy rules — Marvin earns for confirmed bugs, Bilby earns for false positives, all others earn for confirmed findings. Add Mindset sections to Bilby, Nagatha, Trillian, and Diziet agents.
  • MemCan Context Injection strengthened: Expand the vague one-liner into a concrete 5-step procedure — extract keywords, search with MCP tool, filter by score >= 0.7, inject as ## Prior Knowledge block in agent prompts, skip only for trivial tasks. Add "Prior knowledge" as item docs: add explicit Skills sections to all agents with skill references #9 in Agent Prompt Requirements checklist.
  • Agent audit: Verify all agents have candy motivation and correct role descriptions.

Context (MemCan injection change)

Analytics of 4,534 Claude Code sessions showed 78% of agent sessions never use memcan despite having tools configured. Root cause: coordinator didn't consistently inject search results into agent prompts. The new procedure makes injection mandatory with a concrete template and score threshold.

Test plan

  • Validate plugin structure: claude plugin validate .
  • Verify grand-admiral skill loads correctly when claudius agent is invoked
  • Confirm claudius agent prompt is minimal (personality + role only, ~30 lines)
  • Spot-check that all orchestration knowledge (spawning, worktree, teams, scaling) is in the skill, not the agent
  • Verify agent .md files have Mindset sections with candy motivation
  • Test a multi-agent workflow to confirm crew roster, skill references, and delegation still work end-to-end
  • Verify MemCan Context Injection procedure is followed when spawning agents

🤖 Co-authored by Claudius the Magnificent AI Agent

lklimek and others added 5 commits April 8, 2026 10:07
… agent

Move ~150 lines of multi-agent orchestration doctrine (spawning, worktree
isolation, team coordination, scaling, recovery, anti-patterns) plus
planning, crew roster, skills reference, and programme management patterns
into a dedicated `grand-admiral` skill. The claudius agent prompt drops
from 206 to 55 lines — personality + session protocol only — improving
resilience to context compaction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dmiral skill

Further slim the claudius agent to personality + role/focus only (30 lines).
Session protocol (Always section), documentation conventions, and attribution
rules now live in the grand-admiral skill alongside all other orchestration
knowledge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add "Agent Reuse" subsection under Spawning: prefer SendMessage to
running agents over spawning fresh ones for follow-up work in the same
scope. Add corresponding anti-pattern #10 to reinforce the pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update Crew Roster roles to make the builder/breaker contract explicit:
Bilby builds and fixes code, Marvin proves code wrong and never fixes.
Add explanatory note after the roster table with the fix-routing pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add dedicated "Candy Economy" section to grand-admiral skill with
per-agent candy rules: Marvin earns for confirmed bugs, Bilby earns
for false positives, all others earn for confirmed findings in their
domain. Coordinator validates all awards.

Add Mindset sections to Bilby, Nagatha, Trillian, and Diziet agents
with candy motivation. Marvin, Smythe, and Adams already had candy
mindset — no changes needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the plugin’s multi-agent orchestration guidance by extracting coordinator doctrine from the claudius agent prompt into a dedicated grand-admiral skill, while also formalizing “candy economy” incentives and clarifying builder/breaker responsibilities across the crew.

Changes:

  • Added a new skills/grand-admiral/SKILL.md containing coordinator session protocol, spawning/worktree/team patterns, scaling/recovery, and anti-patterns.
  • Slimmed agents/claudius.md to personality + focus, and ensured it always loads grand-admiral.
  • Added/updated “Mindset” (candy motivation) sections across selected agents and bumped plugin version + changelog.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
skills/grand-admiral/SKILL.md New orchestration doctrine skill (spawning, worktrees, teams, reuse, candy economy, programme management).
agents/claudius.md Loads grand-admiral and removes inlined orchestration doctrine to reduce prompt size.
agents/developer-bilby.md Adds Mindset section describing candy incentive for false positives.
agents/architect-nagatha.md Adds Mindset section describing candy incentive for architecture findings.
agents/technical-writer-trillian.md Adds Mindset section describing candy incentive for doc findings.
agents/ux-designer-diziet.md Adds Mindset section describing candy incentive for UX/accessibility findings.
CHANGELOG.md Adds entries for versions 3.11.0–3.12.0 documenting the extraction and new doctrine.
.claude-plugin/plugin.json Bumps plugin version to 3.12.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +95
# Spawn 3 review agents into team, each with different file scope
# Each agent: TaskCreate for findings -> claim via TaskUpdate(owner=...) -> fix

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Team Example comment, "each agent ... -> fix" conflicts with the documented crew contract that some agents (notably qa-engineer-marvin) never fix code. Consider changing this example to describe reporting findings / implementing only for builder agents (e.g., Bilby), or split into reviewer vs implementer tasks so the example doesn't imply all review agents should apply fixes.

Suggested change
# Spawn 3 review agents into team, each with different file scope
# Each agent: TaskCreate for findings -> claim via TaskUpdate(owner=...) -> fix
# Spawn review agents with different file scopes to inspect and report findings
# Review agents: TaskCreate for findings -> claim via TaskUpdate(owner=...) -> report results
# Builder agents (for example, Bilby): claim implementation tasks via TaskUpdate(owner=...) -> fix

Copilot uses AI. Check for mistakes.
Comment on lines +164 to +166
**Award rules** (coordinator validates all awards — agents do not self-award):
- **Marvin** (QA): earns a candy for each confirmed real issue (bug, logic error, edge case, spec mismatch)
- **Bilby** (Dev): earns a candy for each false positive reported by other agents (incentivizes clean code AND keeps reviewers honest)

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Candy Economy section says "agents do not self-award", but later expects the coordinator to collect each agent's "candy count" from their reports. To avoid contradictory instructions (and inconsistency with existing agent docs that ask for a candy tally), consider clarifying that agents should report finding counts by severity and the coordinator converts/validates those into candy awards, rather than agents reporting candies directly.

Copilot uses AI. Check for mistakes.
Comment thread agents/ux-designer-diziet.md
Comment thread agents/architect-nagatha.md
lklimek and others added 2 commits April 8, 2026 16:10
- Expand one-liner into concrete 5-step procedure with score threshold
- Add Prior Knowledge prompt template for agent context injection
- Add prior knowledge to Agent Prompt Requirements checklist

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lklimek
lklimek marked this pull request as ready for review April 29, 2026 11:44
@lklimek
lklimek merged commit c823593 into main Apr 29, 2026
@lklimek
lklimek deleted the feat/grand-admiral-skill branch April 29, 2026 11:44
lklimek pushed a commit that referenced this pull request Jul 16, 2026
If /ci-dance itself is delegated to a non-lead teammate, its named
Agent() stream spawns fail outright ("teammates cannot spawn other
teammates" - flat team roster). Document the fallback: unnamed
background subagents + rely on Step 3 merge-time reconciliation
instead of the claim/completion SendMessage protocol.

Found by a concurrent session running ci-dance on lklimek/memcan
PR #30 (2026-07-16); folded into PR #71 per user request since both
are claudius-side hardening in the same area.
lklimek added a commit that referenced this pull request Jul 16, 2026
…odex-crew commit-doctrine update (#71)

* fix(agent-watchdog): bound Codex job scan, cover untested branches

- CodexScanner.scan(): add a 6-hour terminal-job retention window so
  per-poll jobs/*.json enumeration and state tracking stay bounded on
  long sessions; active jobs are retained regardless of age; existing
  mtime cache and one-time slow-glob warning preserved.
- tests: add a real `git init` fixture exercising git_toplevel()/
  resolve_workspace() Source-D resolution; cover _task_dir, relative
  _worktrees (the default production path), _subagent_dirs autodetect,
  and member_transcripts() fallback/ambiguity branches.
- grand-admiral/SKILL.md: note that a TaskStop success response for a
  Monitor-wrapped background process doesn't prove the OS process
  actually died.

exit-144 startup crash (separate TODO) could not be reproduced after
multiple attempts (real + synthetic team dirs, strace, direct launch);
left open, no speculative fix applied.

Verified: python3 -m pytest tests/test_agent_watchdog.py -v -> 63
passed, 0 failed. ruff check / ruff format --check clean.

* docs(codex-crew): Codex can now commit in linked worktrees; bump 5.9.0

Empirically verified 2026-07-16 (commit f2639aa, this repo): Codex
successfully ran git add/git commit inside a linked worktree, no
approval prompt. This reverses codex-crew's prior hard-block guidance.
writable_roots was unchanged at test time (still excludes repo .git),
so the likely enabling lever is approval_policy="on-request" + the
project's trust_level="trusted", not a sandbox-path change - not
independently confirmed. Coordinator-commits kept as documented
fallback if the old read-only/index.lock error resurfaces.

Bump plugin.json to 5.9.0 and update CHANGELOG per repo versioning
policy (this PR touches plugin content: scripts/agent-watchdog.py
fixes, grand-admiral doc note, codex-crew doc correction).

* docs(codex-crew): fix stale git-commit cross-references after rule 2 reversal

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-5 <noreply@openai.com>

* docs(changelog): correct 5.9.0 claim about bounded job-scan enumeration

Per-poll jobs/*.json enumeration was never bounded by the retention
window — only the tracked/returned record set is. Enumeration cost
still scales with total accumulated terminal job files on disk since
nothing prunes them, which is why the slow-glob warning is retained.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(ci-dance): document flat-roster fallback for delegated invocations

If /ci-dance itself is delegated to a non-lead teammate, its named
Agent() stream spawns fail outright ("teammates cannot spawn other
teammates" - flat team roster). Document the fallback: unnamed
background subagents + rely on Step 3 merge-time reconciliation
instead of the claim/completion SendMessage protocol.

Found by a concurrent session running ci-dance on lklimek/memcan
PR #30 (2026-07-16); folded into PR #71 per user request since both
are claudius-side hardening in the same area.

* fix(agent-watchdog): warn on silent Codex job workspaceRoot mismatch

CodexScanner.scan() discovers a job under a candidate's state_dir/jobs/
but then requires the job's self-reported workspaceRoot to canonical-
match the candidate's resolved path before considering it further.
Every other skip path in this function (bad state shape, unsupported
version, unsafe job id, unknown status) warns before discarding - this
one didn't, so a job whose workspaceRoot pointed elsewhere (e.g. the
main repo cwd instead of its actual worktree) vanished with zero trace,
invisible to every CODEX_* event.

Add a warn-once diagnostic naming both paths so this failure mode is
observable instead of requiring manual job-file archaeology. Matching
behavior itself is unchanged - relaxing the equality check risks
misattributing jobs across workspaces, a correctness concern, not just
an observability one.

Root-caused from a separate session's incident report (dash-evo-tool-2,
2026-07-16) where this exact silent skip caused a completed/failed
Codex job to go permanently unreported.

Verified: python3 -m pytest tests/test_agent_watchdog.py -v -> 64
passed, 0 failed. ruff check / ruff format --check clean.

* docs(codex-crew): commit-in-worktree is inconsistent, not fixed

Same day, same repo, two dispatches: one committed cleanly (f2639aa),
the next hit the exact old read-only .git/index.lock error and had to
be committed by the coordinator instead (7c2d3e8). writable_roots was
unchanged across both, so whatever gates this isn't a static setting.

Reframe coordinator-commit as the reliable default, not a fallback for
a regression - always verify independently after a Codex dispatch
rather than trusting its self-reported commit success.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(codex-crew): fix stale commit-status wording flagged by Copilot review

Rule 2 and sandbox-and-recovery.md already say commit-in-worktree is
inconsistent (b418844), but three other spots in SKILL.md still said
"now lifted" / "CAN commit ... won't do so unasked" / "(now working)" -
stale confident phrasing that contradicted rule 2 and could lead a
coordinator to skip the required independent-verify step.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(agent-watchdog): warn when Codex has no candidates

Make teamless Codex monitoring's empty candidate blind spot explicit while preserving existing discovery behavior.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* docs(changelog): add zero-candidates Codex warning entry

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(agent-watchdog): scope workspace-mismatch warning to plausible sessions, escape job filename

CodexScanner.scan()'s new workspace-mismatch warning fired for every
job in a candidate's jobs/ dir before session filtering ran, so a job
belonging to a completely unrelated, never-trackable session still
tripped "may be silently invisible to CODEX_* events" - noise that
undermines the diagnostic's own purpose. Gate the warning on whether
the job's sessionId is missing or plausibly matches effective_session
(via the existing _prefix_matches helper); the job is still discarded
unconditionally either way, matching semantics unchanged.

Also escape job_path.name (externally-influenced, written by the
external Codex Companion process) with !r in the stderr-bound message,
matching the existing workspaceRoot escaping - it was the one
un-escaped token reaching print(..., file=sys.stderr).

Corrected the existing mismatch test, which used codex_store()'s
default sessionId backfill and so accidentally exercised the
matching-session path instead of the missing-sessionId path it
claimed to cover. Added two new tests for the prefix-matching and
unrelated-session cases.

Verified: python3 -m pytest tests/test_agent_watchdog.py -> 66
passed, 0 failed. ruff check / ruff format --check clean.

Found via grumpy-review iteration 2 (security + QA reviewers,
independently confirmed with a repro).

Co-Authored-By: Codex Sol <noreply@openai.com>

* docs(changelog,codex-crew): fix dangling SHA citation and overstated commit-reliability framing

CHANGELOG.md and sandbox-and-recovery.md both cited commit 963db57 as
the Dispatch-2 coordinator-commit; it's a dangling, unreachable orphan
(same message as 7c2d3e8, a pre-rebase ghost) that git show fails on
in a fresh clone. SKILL.md's Rule 2 already cited only 7c2d3e8 - the
three docs disagreed with each other. Drop 963db57, cite 7c2d3e8
consistently.

CHANGELOG.md's workspace-mismatch bullet claimed the new warning
closed "the one exception" among scan()'s skip paths - false: two
more silent continues (corrupt job file, missing workspaceRoot) sit
right next to it, still unwarned. This repo already had to correct
an identical overclaim once (5567cbf). Reworded to describe the
specific gap closed without claiming exclusivity.

skills/codex-crew/SKILL.md's intro, routing bullet, and Additional
Resources line still said "now lifted" / "CAN commit" / "now working"
about linked-worktree git commit, contradicting Rule 2's accurate
"confirmed inconsistent - treat coordinator-commit as the reliable
default." A coordinator skimming only those spots (common skim
points) would land on the wrong takeaway. Reworded all three to
match Rule 2's framing; CHANGELOG's lead clause got the same fix.

Found via grumpy-review iteration 2 (project-consistency + technical-
writer reviewers, independently verified against git history).

Co-Authored-By: Codex Sol <noreply@openai.com>

* fix(agent-watchdog): stop blaming zero Codex candidates on a missing team

The codex-zero-candidates warning hardcoded "no team config" as the cause
whenever codex_candidates was empty, and prescribed "dispatch at least one
NAMED teammate to create a team". Both are false when a team config exists
but yields no cwd: parse_team treats the lead cwd and member cwd as optional
and drops members that are not isActive, so a valid, session-matched team
whose teammates have completed produces zero candidates. poll_once's own
`if team.lead_cwd:` / `if member.cwd` guards show the state is anticipated.

The warning then denied the existence of a team that select_team had just
matched, and suggested creating one that was already there -- a false-premise
diagnostic in the same class as the silent-skip gaps this branch exists to
close.

Branch cause and remedy on team presence. The teamless message is unchanged
byte-for-byte, so its exact-stderr test still passes untouched; only the
team-present branch is new. Changelog reworded to describe both shapes
instead of only the teamless one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(agent-watchdog): apply terminal-job retention before session disambiguation

CodexScanner.scan() folded every job's sessionId into the disambiguation
set before the terminal-job retention cutoff was applied, so an aged-out
terminal job's session could still count as an ambiguity candidate for
_session() — spuriously disabling Source D (or steering selection) long
after the job should have been aged out of "downstream state tracking"
per the retention window's own stated purpose.

Move the cutoff check before jobs/sessions population; active jobs are
still retained unconditionally, matching existing behavior.

Copilot review finding on PR #71 (review 4713623583, agent-watchdog.py:996).

Co-Authored-By: Claudius Agent <noreply@anthropic.com>

---------

Co-authored-by: Claudius Agent <noreply@anthropic.com>
Co-authored-by: Codex GPT-5 <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants