@hybridlabor-api/aos 4.13.2 → 4.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/AGENTS.md +8 -0
- package/.agents/nodes.json +5 -2
- package/.claude/hooks/conventional-commits.mjs +14 -15
- package/.claude/hooks/env-file-protection.mjs +14 -15
- package/.claude/hooks/go-gate.mjs +152 -10
- package/.claude/hooks/go-token.mjs +55 -0
- package/.claude/hooks/memb-inject.mjs +75 -62
- package/.claude/hooks/trail-autostart.mjs +27 -0
- package/.claude/hooks/trail-relay.mjs +1 -0
- package/.claude/settings.json +22 -4
- package/.claude/workflows/startcycle-dispatch.mjs +11 -4
- package/.opencode/plugins/bdb-aos.js +98 -121
- package/.opencode/plugins/lib/trail-autostart.js +38 -0
- package/CLAUDE.md +1 -1
- package/README.de.md +6 -6
- package/README.md +6 -6
- package/README.pt.md +6 -6
- package/THIRD_PARTY_NOTICES.md +19 -3
- package/assets/header-v5.png +0 -0
- package/bin/aos-acp.mjs +211 -0
- package/bin/aos-doctor.mjs +1 -1
- package/bin/aos-uninstall.mjs +2 -2
- package/docs/master-session-acp.md +51 -0
- package/installer.js +314 -42
- package/mcps/mcsc/packages/mcp/server.js +6 -7
- package/package.json +4 -3
- package/scripts/validate-skills.mjs +76 -0
- package/skills/basic/bdbmediastorm/SKILL.md +1 -1
- package/skills/basic/godmode-shipping/SKILL.md +3 -0
- package/skills/basic/master-session/SKILL.md +89 -0
- package/skills/basic/startcycle/SKILL.md +1 -1
- package/skills/basic/startcycle-graph/SKILL.md +2 -2
- package/skills/basic/startcycle-graph-user/SKILL.md +1 -1
- package/skills/basic/teamwork-preview/SKILL.md +1 -1
- package/skills/bdbrainstorm/SKILL.md +7 -1
- package/skills/global_config/agentic-harness-patterns/SKILL.md +257 -0
- package/skills/global_config/agentic-harness-patterns/metadata.json +10 -0
- package/skills/global_config/agentic-harness-patterns/references/agent-orchestration-pattern.md +97 -0
- package/skills/global_config/agentic-harness-patterns/references/bootstrap-sequence-pattern.md +106 -0
- package/skills/global_config/agentic-harness-patterns/references/context-engineering/compress-pattern.md +78 -0
- package/skills/global_config/agentic-harness-patterns/references/context-engineering/isolate-pattern.md +82 -0
- package/skills/global_config/agentic-harness-patterns/references/context-engineering/select-pattern.md +86 -0
- package/skills/global_config/agentic-harness-patterns/references/context-engineering-pattern.md +29 -0
- package/skills/global_config/agentic-harness-patterns/references/hook-lifecycle-pattern.md +111 -0
- package/skills/global_config/agentic-harness-patterns/references/memory-persistence-pattern.md +109 -0
- package/skills/global_config/agentic-harness-patterns/references/permission-gate-pattern.md +111 -0
- package/skills/global_config/agentic-harness-patterns/references/skill-runtime-pattern.md +104 -0
- package/skills/global_config/agentic-harness-patterns/references/task-decomposition-pattern.md +92 -0
- package/skills/global_config/agentic-harness-patterns/references/tool-registry-pattern.md +101 -0
- package/skills/global_config/agenttrail/SKILL.md +8 -0
- package/skills/global_config/agenttrail/bin/agenttrail.mjs +14 -0
- package/skills/global_config/agenttrail/bin/ensure.mjs +118 -0
- package/skills/global_config/aos-setup/scripts/aos-doctor.mjs +1 -1
- package/skills/global_config/bdb-visual-edit/SKILL.md +51 -0
- package/skills/global_config/bdb-visual-edit/references/vite-react-source-attr.md +59 -0
- package/skills/global_config/bdb-visual-edit/scripts/pick-snippet.js +27 -0
- package/skills/global_config/bdb-visual-edit/scripts/sanitize-element.mjs +123 -0
- package/skills/global_config/factory-collect/SKILL.md +74 -0
- package/skills/global_config/factory-human-digest/SKILL.md +92 -0
- package/skills/global_config/factory-lookback/SKILL.md +95 -0
- package/skills/global_config/factory-review-prs/SKILL.md +63 -0
- package/skills/global_config/git-pr-review/SKILL.md +3 -0
- package/skills/global_config/grilling/SKILL.md +2 -0
- package/skills/global_config/mcsc/SKILL.md +1 -1
- package/skills/global_config/plan-arbiter/SKILL.md +125 -0
- package/skills/global_config/plan-canvas/SKILL.md +62 -5
- package/skills/global_config/plan-canvas/scripts/lib/loopback-guard.js +19 -3
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/README.md +285 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/agent-trail.js +129 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/board-client.js +124 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/demo-plan/canvas.mdx +19 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/demo-plan/plan.mdx +18 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/recap-demo/plan.mdx +72 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/README.md +29 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/architecture.json +30 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/builder/00_architecture.html +14950 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/builder/canvas.mdx +511 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/builder/plan.mdx +208 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/recap/plan.mdx +102 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/showcase/standard/plan.md +136 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/signup-storyboard/canvas.mdx +124 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/examples/signup-storyboard/plan.mdx +37 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/index.js +188 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/kit.js +123 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/mdx.js +411 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/render.js +1291 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/architecture/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/architecture/plan.mdx +195 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/architecture/standard.md +95 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/bugfix/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/bugfix/plan.mdx +105 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/bugfix/standard.md +76 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/canvas.mdx +81 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/plan.mdx +145 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/feature/standard.md +76 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/migration/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/migration/plan.mdx +172 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/migration/standard.md +100 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap/plan.mdx +67 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap/standard.md +49 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/canvas.mdx +63 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/plan.mdx +49 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-board/standard.md +39 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-review/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-review/plan.mdx +118 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/recap-review/standard.md +57 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/release/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/release/plan.mdx +173 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/release/standard.md +96 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/research/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/research/plan.mdx +91 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/research/standard.md +54 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/canvas.mdx +53 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/meta.json +1 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/plan.mdx +225 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/templates/show-control/standard.md +111 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/theme.css +472 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-builder/trail.js +216 -0
- package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/markdown.js +1 -1
- package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/server.js +37 -4
- package/skills/global_config/plan-canvas/scripts/lib/plan-canvas/ui.js +125 -29
- package/skills/global_config/plan-canvas/scripts/plan-canvas.js +196 -8
- package/skills/global_config/pr-recap/SKILL.md +47 -0
- package/skills/global_config/pr-recap/scripts/pr-recap.mjs +200 -0
- package/skills/global_config/quick-recap/SKILL.md +55 -0
- package/skills/global_config/stay-within-limits/SKILL.md +85 -0
- package/skills/global_config/triage/SKILL.md +3 -0
- package/skills/global_config/visual-edit/README.md +96 -0
- package/skills/global_config/visual-edit/SKILL.md +615 -0
- package/skills/global_config/visual-plan/README.md +93 -0
- package/skills/global_config/visual-plan/SKILL.md +544 -0
- package/skills/global_config/visual-plan/references/canvas.md +139 -0
- package/skills/global_config/visual-plan/references/connection.md +51 -0
- package/skills/global_config/visual-plan/references/document-quality.md +186 -0
- package/skills/global_config/visual-plan/references/exemplar.md +62 -0
- package/skills/global_config/visual-plan/references/local-files.md +99 -0
- package/skills/global_config/visual-plan/references/wireframe.md +319 -0
- package/skills/global_config/visual-recap/README.md +103 -0
- package/skills/global_config/visual-recap/SKILL.md +560 -0
- package/skills/global_config/visual-recap/references/connection.md +51 -0
- package/skills/global_config/visual-recap/references/local-files.md +99 -0
- package/skills/global_config/visual-recap/references/wireframe.md +319 -0
- package/skills/playbooks/pb-ci-fix/SKILL.md +49 -0
- package/skills/playbooks/pb-event-tracker/SKILL.md +45 -0
- package/skills/playbooks/pb-meeting-actions/SKILL.md +42 -0
- package/skills/playbooks/pb-project-new/SKILL.md +48 -0
- package/skills/playbooks/pb-week-plan/SKILL.md +45 -0
- package/assets/header-v4.jpg +0 -0
|
@@ -241,6 +241,45 @@ function checkSkillRefs(text, file, known, self, findings) {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
// Playbooks are skills with `kind: playbook`; skills without `kind` are untouched.
|
|
245
|
+
const PB_REQUIRED = ['trigger', 'inputs', 'requires', 'go_points', 'outputs', 'verify', 'difficulty', 'est_time', 'disable-model-invocation'];
|
|
246
|
+
const DIFFICULTY = new Set(['beginner', 'intermediate', 'advanced']);
|
|
247
|
+
const EXTERNAL = ' (external)';
|
|
248
|
+
|
|
249
|
+
export function checkPlaybook(byKey, known) {
|
|
250
|
+
const out = [];
|
|
251
|
+
if (!byKey.has('kind')) return out;
|
|
252
|
+
const add = (code, msg, key) => out.push({ level: 'error', code, line: byKey.get(key)?.line, msg });
|
|
253
|
+
const kind = unquote(byKey.get('kind').value);
|
|
254
|
+
if (kind !== 'playbook') {
|
|
255
|
+
add('E-PB01', `\`kind: ${kind}\` is unknown — the only defined kind is \`playbook\``, 'kind');
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
258
|
+
for (const k of PB_REQUIRED) if (!byKey.has(k)) add('E-PB03', `playbook is missing required key \`${k}\``, 'kind');
|
|
259
|
+
|
|
260
|
+
const req = byKey.get('requires');
|
|
261
|
+
if (req) {
|
|
262
|
+
const m = /(?:^|\s)skills:\s*\[([^\]]*)\]/.exec(req.value);
|
|
263
|
+
if (!m) add('E-PB05', '`requires.skills` must be a flow-style list, e.g. `skills: [github, ci-pipeline]`', 'requires');
|
|
264
|
+
else {
|
|
265
|
+
for (const raw of m[1].split(',').map((e) => unquote(e)).filter(Boolean)) {
|
|
266
|
+
if (!raw.endsWith(EXTERNAL) && !known.has(raw)) {
|
|
267
|
+
add('E-PB02', `requires skill \`${raw}\`, which is not a skill in this repo — fix the name or mark it \`${raw}${EXTERNAL}\``, 'requires');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const diff = byKey.get('difficulty');
|
|
273
|
+
if (diff && !DIFFICULTY.has(unquote(diff.value))) {
|
|
274
|
+
add('E-PB04', `\`difficulty: ${unquote(diff.value)}\` is not one of: ${[...DIFFICULTY].join(', ')}`, 'difficulty');
|
|
275
|
+
}
|
|
276
|
+
const dmi = byKey.get('disable-model-invocation');
|
|
277
|
+
if (dmi && unquote(dmi.value) !== 'true') {
|
|
278
|
+
add('E-PB06', 'playbooks are user-invoked only — set `disable-model-invocation: true`', 'disable-model-invocation');
|
|
279
|
+
}
|
|
280
|
+
return out;
|
|
281
|
+
}
|
|
282
|
+
|
|
244
283
|
function validate() {
|
|
245
284
|
const { skills, strays } = collect();
|
|
246
285
|
const known = new Set(skills.map((f) => basename(dirname(f))));
|
|
@@ -311,6 +350,8 @@ function validate() {
|
|
|
311
350
|
}
|
|
312
351
|
}
|
|
313
352
|
|
|
353
|
+
for (const f of checkPlaybook(byKey, known)) findings.push({ ...f, file: rel });
|
|
354
|
+
|
|
314
355
|
checkLeakedPaths(text, rel, findings);
|
|
315
356
|
checkLocalRefs(text, dir, rel, findings);
|
|
316
357
|
checkSkillRefs(text, rel, known, dirName, findings);
|
|
@@ -461,6 +502,41 @@ function selftest() {
|
|
|
461
502
|
assert.ok(isValidSkillName('a'.repeat(NAME_MAX)), 'a 64-char name is at the limit and valid');
|
|
462
503
|
assert.ok(!isValidSkillName('a'.repeat(NAME_MAX + 1)), 'a 65-char name is over the limit');
|
|
463
504
|
|
|
505
|
+
// Playbook frontmatter (kind: playbook).
|
|
506
|
+
const pb = (over = {}, drop = []) => {
|
|
507
|
+
const base = {
|
|
508
|
+
name: 'pb-x', description: 'd', category: 'bdb-core', kind: 'playbook',
|
|
509
|
+
trigger: '["a"]', inputs: '[repo]',
|
|
510
|
+
requires: '\n skills: [github, gh (external)]\n agents: []\n mcps: []\n store: []',
|
|
511
|
+
go_points: '[]', outputs: '["x"]', verify: '"x"', difficulty: 'beginner',
|
|
512
|
+
est_time: '5 min', 'disable-model-invocation': 'true', ...over,
|
|
513
|
+
};
|
|
514
|
+
const lines = Object.entries(base).filter(([k]) => !drop.includes(k)).map(([k, v]) => `${k}: ${v}`);
|
|
515
|
+
const fm = scanFrontmatter(['---', ...lines, '---'].join('\n'));
|
|
516
|
+
return new Map(fm.keys.map((k) => [k.key, k]));
|
|
517
|
+
};
|
|
518
|
+
const known = new Set(['github', 'ci-pipeline']);
|
|
519
|
+
assert.deepEqual(checkPlaybook(pb(), known), [], 'valid playbook is clean');
|
|
520
|
+
const miss = checkPlaybook(pb({}, ['go_points']), known);
|
|
521
|
+
assert.equal(miss.length, 1);
|
|
522
|
+
assert.equal(miss[0].code, 'E-PB03');
|
|
523
|
+
assert.match(miss[0].msg, /go_points/);
|
|
524
|
+
assert.equal(checkPlaybook(pb({ difficulty: 'expert' }), known)[0].code, 'E-PB04');
|
|
525
|
+
const unk = checkPlaybook(pb({ requires: '\n skills: [github, nope-skill, gh (external)]' }), known);
|
|
526
|
+
assert.equal(unk.length, 1);
|
|
527
|
+
assert.equal(unk[0].code, 'E-PB02');
|
|
528
|
+
assert.match(unk[0].msg, /nope-skill/);
|
|
529
|
+
const kind = checkPlaybook(pb({ kind: 'recipe' }), known);
|
|
530
|
+
assert.equal(kind.length, 1);
|
|
531
|
+
assert.equal(kind[0].code, 'E-PB01');
|
|
532
|
+
assert.equal(checkPlaybook(pb({ requires: '\n skills:\n - github' }), known)[0].code, 'E-PB05');
|
|
533
|
+
assert.equal(checkPlaybook(pb({ 'disable-model-invocation': 'false' }), known)[0].code, 'E-PB06');
|
|
534
|
+
assert.deepEqual(checkPlaybook(pb({}, ['kind', 'trigger', 'inputs', 'requires', 'go_points', 'outputs', 'verify', 'difficulty', 'est_time', 'disable-model-invocation']), known).length, 0, 'no kind, no playbook rules');
|
|
535
|
+
assert.deepEqual(
|
|
536
|
+
checkPlaybook(pb({ requires: '\n skills: ["gh (external)", github,]' }), known), [],
|
|
537
|
+
'quoted item and trailing comma survive',
|
|
538
|
+
);
|
|
539
|
+
|
|
464
540
|
console.log('✓ selftest passed');
|
|
465
541
|
}
|
|
466
542
|
|
|
@@ -76,7 +76,7 @@ Define hardware and software nodes as strict bounded contexts:
|
|
|
76
76
|
|
|
77
77
|
## 5. Mandatory — Plan Canvas Review
|
|
78
78
|
|
|
79
|
-
Before this session concludes, run `aos-plan-canvas open <file>` against `signal-flow.md` (or the combined show-control spec), then `aos-plan-canvas await <file>` and leave it running. The user reviews the signal flow diagram, hardware topology, and failover matrix in the browser (Mermaid renders live, click-to-annotate, chat rail). Do not consider the show architecture finalized before an `approve` verdict. A `request_changes` verdict means revise the artifact and reopen — it live-reloads. This is a plain CLI tool, identical regardless of which agent harness runs this skill. See the `plan-canvas` skill. If a build follows the approve, Trigger A starts the live map (`agenttrail` skill); `aos-archify` can render the signal flow as a workflow or architecture diagram for the review.
|
|
79
|
+
Before this session concludes, choose the planning mode by running `aos-plan-canvas modes` and presenting available modes to the user (see the "Planning mode choice" section in the `plan-canvas` skill). Then run `aos-plan-canvas open <file> --mode <choice>` against `signal-flow.md` (or the combined show-control spec), then `aos-plan-canvas await <file>` and leave it running. The user reviews the signal flow diagram, hardware topology, and failover matrix in the browser (Mermaid renders live, click-to-annotate, chat rail). Do not consider the show architecture finalized before an `approve` verdict. A `request_changes` verdict means revise the artifact and reopen — it live-reloads. This is a plain CLI tool, identical regardless of which agent harness runs this skill. See the `plan-canvas` skill. If a build follows the approve, Trigger A starts the live map (`agenttrail` skill); `aos-archify` can render the signal flow as a workflow or architecture diagram for the review.
|
|
80
80
|
|
|
81
81
|
---
|
|
82
82
|
|
|
@@ -41,6 +41,9 @@ This Godmode extends beyond standard software development. It STRICTLY governs c
|
|
|
41
41
|
* **MediaStorm Deployments:** When executing `/bdbmediastorm` for TouchDesigner, Unreal Engine, or Adobe Suite workflows, you must enforce rigorous release management for `.tox` files, Unreal Blueprints, and showfiles.
|
|
42
42
|
* **Show-Ready Validation:** Never push a creative-tech update to a live production environment (e.g., a running installation or live show) without a verified fallback or backup showfile.
|
|
43
43
|
|
|
44
|
+
## Visual recap
|
|
45
|
+
After the gates pass, `/pr-recap` can build a Plan Builder recap page of the diff with the Verified and Not verified checks. It is informational and does not gate the release. Posting it anywhere stays a human decision.
|
|
46
|
+
|
|
44
47
|
## Universal Agent Harness Integration
|
|
45
48
|
This Godmode is universally compatible and governs all extensions, including the BDB Creator Engine.
|
|
46
49
|
* **Cursor:** Auto-injected via `.cursor/rules/godmode-shipping.mdc`.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: master-session
|
|
3
|
+
description: Use when one Claude Code session must supervise several others on this machine — adopting sessions the user started by hand, or spawning workers itself. Covers roster, status requests, a GO board, idle notices, and the GO-token protocol. Works with AOS alone; the AO daemon is optional.
|
|
4
|
+
category: bdb-core
|
|
5
|
+
risk: safe
|
|
6
|
+
tools:
|
|
7
|
+
- claude-code
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# `/master-session` — Supervise Other Sessions
|
|
11
|
+
|
|
12
|
+
One session is the **master**: it keeps the overview, asks workers for status, and relays the human's decisions. It never does the workers' jobs and never decides for the human. Needs Claude Code with cross-session messaging (`ListAgents`, `SendMessage`). Nothing here requires the AO daemon.
|
|
13
|
+
|
|
14
|
+
## Modes
|
|
15
|
+
|
|
16
|
+
- **Adopt** — supervise sessions the human already started by hand. `ListAgents` is the source of truth; message them with `SendMessage`.
|
|
17
|
+
- **Spawn** — start the workers yourself. AO is optional; without it:
|
|
18
|
+
- Claude: `claude --bg --name <name> --permission-mode auto "<prompt>"`, or over ACP as below.
|
|
19
|
+
- Codex / OpenCode / Claude over ACP: `aos-acp <codex|opencode|claude> --name <name> --cwd <worktree> --prompt "<task>" --go-wait 600 &` (one process per worker; run it in the background and read its log). Details: `docs/master-session-acp.md`.
|
|
20
|
+
- agy: no sanctioned ACP adapter (`antigravity-acp` breaches Google's Antigravity terms). Adopt agy sessions or delegate via the `mcsc` skill.
|
|
21
|
+
- If AO is installed, `ao-orchestrator` may run the same workers; it adds nothing the token protocol needs.
|
|
22
|
+
|
|
23
|
+
### `aos-acp` in one paragraph
|
|
24
|
+
|
|
25
|
+
`bin/aos-acp.mjs` is a zero-dependency ACP client: it spawns the adapter (`npx -y @agentclientprotocol/codex-acp`, `opencode acp`, `npx -y @agentclientprotocol/claude-agent-acp`), runs `initialize` → `session/new` → `session/prompt`, streams the worker's text to stdout and logs every event to `~/.aos/acp/<name>.jsonl`. A `session/request_permission` for a guarded command (the go-gate list) is answered `allow_once` only with a valid GO token for `<name>`; with `--go-wait <sec>` the request is parked (log event `permission_pending`, show it as `GO needed`) until the token appears or the wait ends. Everything else follows `--allow-default deny|allow` (deny by default). ACP workers are not in `ListAgents`: the roster lists them from the logs.
|
|
26
|
+
|
|
27
|
+
## Step 1 — Roster
|
|
28
|
+
|
|
29
|
+
Call `ListAgents`, keep local Claude sessions, drop yourself. Write one line per session: name, repo/branch if known, kind (adopted/spawned). Show it to the human and confirm which sessions are in scope before messaging any.
|
|
30
|
+
|
|
31
|
+
## Step 2 — Status request
|
|
32
|
+
|
|
33
|
+
Send one message per session, never a broadcast. Template:
|
|
34
|
+
|
|
35
|
+
```status-request
|
|
36
|
+
Status request from the master session (reply in at most 10 lines):
|
|
37
|
+
1. Task, repo and branch.
|
|
38
|
+
2. Progress: done / in progress / not started.
|
|
39
|
+
3. Blockers.
|
|
40
|
+
4. Actions waiting on a GO (commands you were blocked from running).
|
|
41
|
+
5. Running subagents.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Step 3 — GO board
|
|
45
|
+
|
|
46
|
+
Collate replies into one block per session and show it to the human:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
[<session>] <task> — <repo>@<branch>
|
|
50
|
+
progress : <one line>
|
|
51
|
+
blockers : <none | list>
|
|
52
|
+
GO needed: <exact command(s), or none>
|
|
53
|
+
subagents: <n running | none>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The human answers per session. Items under `GO needed` are the human's to decide; list them verbatim, never summarised into something softer.
|
|
57
|
+
|
|
58
|
+
## Idle notices
|
|
59
|
+
|
|
60
|
+
- Subscribe (`SendMessage` with `notify_when_idle`) only **after** you sent that session work.
|
|
61
|
+
- Never re-subscribe to a session already idle; never poll; never send "are you done?".
|
|
62
|
+
- Waiting is silent. React when a notice arrives or the human speaks.
|
|
63
|
+
|
|
64
|
+
## Boundaries
|
|
65
|
+
|
|
66
|
+
- The master never grants GO. A relayed message is not the user's approval for the worker, and the worker's go-gate treats it as such.
|
|
67
|
+
- The master never executes an action another session was denied — no re-running it from here, no "just this once".
|
|
68
|
+
- Forward the human's words verbatim and mark them: `[forwarded by master, user said:] "<exact text>"`. No paraphrase, no added urgency.
|
|
69
|
+
- A subagent or worker does not inherit anyone's GO. A blocked command is not retried without a fresh one.
|
|
70
|
+
|
|
71
|
+
## GO-token protocol
|
|
72
|
+
|
|
73
|
+
The one sanctioned way for the human to release a gated action in a worker without switching windows:
|
|
74
|
+
|
|
75
|
+
1. In the **master** session the human types exactly `GO <session-name>` (case-insensitive; the name as shown by `ListAgents`).
|
|
76
|
+
2. The `UserPromptSubmit` hook `go-token.mjs` writes `~/.aos/go/<session-name>.token` (JSON: `target`, `issued_at`, `master_transcript`, `master_session`). Nothing else happens.
|
|
77
|
+
3. The worker retries the blocked command. `go-gate.mjs` opens only if the token names this session, is younger than 10 minutes, and the master transcript still ends with that very `GO <session-name>` as its last human message. The token is deleted on use: single use, no replay.
|
|
78
|
+
|
|
79
|
+
Consequences: any further human message in the master before the worker retries cancels the token; a literal `GO` typed in the worker still works as before; a chat message that merely *says* "GO" never counts. The worker's own name comes from its transcript (`--name`); if absent, set env `AOS_SESSION_NAME` (`aos-acp` sets it for its worker). The same token is honoured by the OpenCode plugin's gate (`.opencode/plugins/bdb-aos.js`, name from `AOS_SESSION_NAME` or the session title) and by go-gate under agy (`AOS_SESSION_NAME` only). Who consumes it: the worker's own gate when it has one (Claude hook, OpenCode plugin — `aos-acp` then only verifies), `aos-acp` itself for codex, which has none. Limit: the token proves the human typed it in the master transcript, not who wrote the token file — a hostile local process can forge both, so this is a guard against mistakes, not against local malware.
|
|
80
|
+
|
|
81
|
+
## Starting workers: lessons
|
|
82
|
+
|
|
83
|
+
- A background worker stalls on its first permission prompt unless started with `--permission-mode auto`. Always pass it.
|
|
84
|
+
- `--disallowedTools` is variadic and swallows a trailing prompt. Put the prompt before it, or end the flag list with `--`, and check the worker actually received the task.
|
|
85
|
+
- Name every worker (`--name`) so the token and `ListAgents` agree.
|
|
86
|
+
|
|
87
|
+
## Handover file
|
|
88
|
+
|
|
89
|
+
At session end write `docs/sessions/master-<date>.md` (or `$HOME/.aos/handover/` outside a repo): roster, last GO board, open GO items, what is waiting on whom, and the next command. A fresh master reads it first.
|
|
@@ -74,7 +74,7 @@ A straight-line run through the BDB agent roster. Whoever invokes this skill inv
|
|
|
74
74
|
|
|
75
75
|
### 3. Build (parallel, stream-selective)
|
|
76
76
|
|
|
77
|
-
**Trigger B — start the live map:** `aos-trail
|
|
77
|
+
**Trigger B — start the live map:** `aos-trail --ensure` (safe to run twice: it reuses a map already running for this repo). Put the live-map link in your reply (the autostart hook also adds it as context when active). Inside AO (env var `AO_BROWSER_CAPABILITY` set) also run `ao preview <url>`. Tell each build agent to mark its tasks `[~]` before starting work, `[x]` when done, `[!]` when stuck, with an indented `by: <agent>` line, saving the plan file immediately after each change. See the `agenttrail` skill.
|
|
78
78
|
|
|
79
79
|
Run only the streams the goal actually needs. A plain backend feature does not need step 3a or 3c; a pure copy change does not need 3b. Each stream's `skills:` frontmatter already lists what it should reach for — the invoker passes that list through rather than restating it here.
|
|
80
80
|
|
|
@@ -111,9 +111,9 @@ Reviewer, and no quality gate ever running).
|
|
|
111
111
|
When the build phase begins, the dispatcher starts the aos-trail live map
|
|
112
112
|
(Trigger B) with the command below; it is safe to run twice, since
|
|
113
113
|
`aos-trail` reuses a map already running for this repo:
|
|
114
|
-
`aos-trail
|
|
114
|
+
`aos-trail --ensure`
|
|
115
115
|
(it prints a URL, default http://localhost:5330; inside AO, where
|
|
116
|
-
`AO_BROWSER_CAPABILITY` is set, also run `ao preview <url>`). Agents follow
|
|
116
|
+
`AO_BROWSER_CAPABILITY` is set, also run `ao preview <url>`). Put the live-map link in your reply (the autostart hook also adds it as context when active). Agents follow
|
|
117
117
|
the status-mark rules from the `agenttrail` skill: `[~]` before starting,
|
|
118
118
|
`[x]` when done, `[!]` when stuck, with `by: <agent>`, saving the plan file
|
|
119
119
|
immediately.
|
|
@@ -69,7 +69,7 @@ subagent exists:
|
|
|
69
69
|
|
|
70
70
|
| CLI | Plugin subagent (preferred) | Raw fallback |
|
|
71
71
|
|---|---|---|
|
|
72
|
-
| agy | `antigravity:
|
|
72
|
+
| agy | `antigravity:delegate` | `agy-job start --tier flash [--yolo] "<task>"` |
|
|
73
73
|
| opencode | `opencode:opencode-rescue` | the CLI's own session primitive |
|
|
74
74
|
| codex | `codex:codex-rescue` | the Codex CLI's task-delegation surface |
|
|
75
75
|
|
|
@@ -195,7 +195,7 @@ Seek explicit approval from the user before triggering execution.
|
|
|
195
195
|
|
|
196
196
|
Once approved by the user:
|
|
197
197
|
|
|
198
|
-
Before delegating, start the live map (Trigger B) so the user can follow the team: `aos-trail
|
|
198
|
+
Before delegating, start the live map (Trigger B) so the user can follow the team: `aos-trail --ensure` (add `--plan <plan-file>` if the plan path is explicit) (safe to run twice: it reuses a map already running for this repo). Put the live-map link in your reply (the autostart hook also adds it as context when active). Inside AO (env var `AO_BROWSER_CAPABILITY` set) also run `ao preview <url>`. See the `agenttrail` skill.
|
|
199
199
|
|
|
200
200
|
### 1. In Antigravity Harness
|
|
201
201
|
If running in Google Antigravity with native subagent support:
|
|
@@ -36,11 +36,17 @@ You are strictly required to enforce the following 6 pillars in your process:
|
|
|
36
36
|
|
|
37
37
|
### 6. Shipping Godmode & Pipeline Hand-off
|
|
38
38
|
- Before the brainstorm concludes, verify that the plan satisfies the `godmode-shipping` rules (Spec-Driven Development, feature flags, rollback strategies).
|
|
39
|
-
- **Mandatory — Plan Canvas review.** Write the aligned plan to a file
|
|
39
|
+
- **Mandatory — Plan Canvas review.** Write the aligned plan to a file. Choose the planning mode by running `aos-plan-canvas modes` and presenting available modes to the user (see the "Planning mode choice" section in the `plan-canvas` skill). Then run `aos-plan-canvas open <file> --mode <choice>` followed by `aos-plan-canvas await <file>` and leave it running. The user reviews and annotates in the browser (Mermaid diagrams render live, click-to-annotate, chat rail); do not write `state.goal` or hand off to `/startcycle-graph` before an `approve` verdict comes back. A `request_changes` verdict means revise the plan file and reopen the session — it live-reloads. This runs identically regardless of which agent harness is executing this skill; it is a plain CLI, not a Claude-Code-specific mechanism. See the `plan-canvas` skill.
|
|
40
40
|
- Write the plan in the agenttrail component convention (`## Name {#id}` components with `needs:` / `files:` lines, tasks as `- [ ] ... {#id}`) and render the architecture with `aos-archify` so the canvas review includes the diagram; after the `approve` verdict, Trigger A starts the live map. See the `agenttrail` and `archify` skills.
|
|
41
41
|
- Present the aligned plan and hand off to `/startcycle-graph` for execution — write `state.goal` from this session's output and let `/startcycle-graph`'s dispatcher take it from there (see `.agents/graph.md`). This skill does not invoke `/startcycle-graph`'s agents itself; it produces the goal they read.
|
|
42
42
|
- For a recurring quality goal, run `/design-control-loop` after shipping (manual, opt-in; not part of the graph).
|
|
43
43
|
|
|
44
|
+
## Competing Plans
|
|
45
|
+
|
|
46
|
+
If the brainstorm yields two viable directions, have two different agents each
|
|
47
|
+
write a plan file and compare them with the `plan-arbiter` skill before
|
|
48
|
+
handing off to `/startcycle-graph`. Review the arbiter's memo in `plan-canvas`.
|
|
49
|
+
|
|
44
50
|
## Execution Rules
|
|
45
51
|
1. **Never skip the debate:** Ideas must be contested by subagents and the user before finalization.
|
|
46
52
|
2. **Never build alone:** Always use subagents for implementation.
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentic-harness-patterns
|
|
3
|
+
description: >-
|
|
4
|
+
Harness patterns for coding agents — memory, permissions, context
|
|
5
|
+
engineering, delegation, skills, hooks, bootstrap.
|
|
6
|
+
when_to_use: >-
|
|
7
|
+
Triggers on: harness engineering, tool safety, permission pipeline,
|
|
8
|
+
agent memory, memory persistence, delegation pattern, context budget,
|
|
9
|
+
bootstrap sequence, skill runtime, hook lifecycle, tool orchestration,
|
|
10
|
+
agent harness, context engineering.
|
|
11
|
+
category: engineering-method
|
|
12
|
+
metadata:
|
|
13
|
+
version: "1.0.0"
|
|
14
|
+
origin: keli-wen/agentic-harness-patterns-skill
|
|
15
|
+
license: MIT
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<!-- Source: keli-wen/agentic-harness-patterns-skill skills/agentic-harness-patterns/SKILL.md — MIT, see THIRD_PARTY_NOTICES.md -->
|
|
19
|
+
|
|
20
|
+
# Agentic Harness Patterns
|
|
21
|
+
|
|
22
|
+
Production AI coding agents are not just an LLM calling tools in a loop. The **harness** — memory, skills, safety, context control, delegation, and extensibility — is what separates a demo from a production system.
|
|
23
|
+
|
|
24
|
+
**For:** Engineers building or extending coding-agent runtimes, custom agents, or advanced multi-agent workflows.
|
|
25
|
+
**Not for:** Prompt engineering, model selection, generic software architecture, or LLM API basics.
|
|
26
|
+
|
|
27
|
+
All principles are distilled from production runtime decisions. Claude Code is used as grounding evidence, not as the only possible implementation.
|
|
28
|
+
|
|
29
|
+
## Choose Your Problem
|
|
30
|
+
|
|
31
|
+
| If you want to... | Read |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Make the agent remember and improve over time | [Memory](#1-memory) |
|
|
34
|
+
| Package reusable workflows and expertise | [Skills](#2-skills) |
|
|
35
|
+
| Let the agent use tools powerfully but not dangerously | [Tools and Safety](#3-tools-and-safety) |
|
|
36
|
+
| Give the agent the right context at the right cost | [Context Engineering](#4-context-engineering) |
|
|
37
|
+
| Split work across multiple agents without losing control | [Multi-agent Coordination](#5-multi-agent-coordination) |
|
|
38
|
+
| Extend behavior with hooks, background tasks, or startup logic | [Lifecycle and Extensibility](#6-lifecycle-and-extensibility) |
|
|
39
|
+
|
|
40
|
+
**Before you start building:** Read the [Gotchas](#gotchas) — these are the non-obvious failure modes that cost the most time.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 1. Memory
|
|
45
|
+
|
|
46
|
+
**User problem:** "My agent forgets corrections and project rules between sessions."
|
|
47
|
+
|
|
48
|
+
**Golden rule:** Separate what the agent *knows* (instruction memory) from what the agent *learns* (auto-memory) from what the agent *extracts* (session memory). Each layer has different persistence, trust, and review needs.
|
|
49
|
+
|
|
50
|
+
**When to use:** Any agent that operates across multiple sessions or needs to accumulate project-specific knowledge over time.
|
|
51
|
+
|
|
52
|
+
**How it works:**
|
|
53
|
+
|
|
54
|
+
- **Instruction memory** is curated, hierarchical configuration injected into system context in priority order (org-wide → user → project → local; local wins). This is where project conventions, coding standards, and behavioral rules live. It is human-authored and stable.
|
|
55
|
+
- **Auto-memory** is agent-written persistent knowledge with a type taxonomy (user / feedback / project / reference) and a capped index. Saving is two-step: write a topic file, then update the index. The cap prevents unbounded growth — without cleanup, recent entries silently disappear.
|
|
56
|
+
- **Session extraction** runs as a background agent at session end. It directly writes to auto-memory — topic file then index — following the same two-step save invariant. A mutual-exclusion guard ensures that if the main agent already wrote memory during the turn, the extractor skips entirely. This is the autonomous learning loop.
|
|
57
|
+
- **Review and promotion** audits across all memory layers and proposes cross-layer moves (auto-memory → project conventions, personal instructions, or team memory). It never applies changes autonomously — proposals require explicit user approval.
|
|
58
|
+
|
|
59
|
+
**Start here:** Define your memory layers (instruction, auto, extraction). Implement the two-step save invariant (topic file, then index). Add background extraction only after the core write path is stable.
|
|
60
|
+
|
|
61
|
+
> **In Claude Code:** Use `/remember` to audit and promote auto-memory entries across layers.
|
|
62
|
+
|
|
63
|
+
**Tradeoffs:**
|
|
64
|
+
|
|
65
|
+
- More memory layers = richer recall but higher maintenance burden. Without periodic pruning, index caps cause silent data loss.
|
|
66
|
+
- Session extraction adds latency at session end but dramatically improves cross-session learning.
|
|
67
|
+
|
|
68
|
+
**Go deeper:** [references/memory-persistence-pattern.md](references/memory-persistence-pattern.md)
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 2. Skills
|
|
73
|
+
|
|
74
|
+
**User problem:** "I want my agent to reuse workflows and domain knowledge without re-explaining them every time."
|
|
75
|
+
|
|
76
|
+
**Golden rule:** Skills are lazy-loaded instruction sets, not eagerly injected prompts. Discovery must be cheap (metadata only); the full body loads only on activation.
|
|
77
|
+
|
|
78
|
+
**When to use:** Any agent that needs reusable, composable workflows activating on matching user intent.
|
|
79
|
+
|
|
80
|
+
**How it works:**
|
|
81
|
+
|
|
82
|
+
- **Discovery** is budget-constrained: the agent sees a compact listing of all available skills (name, description, and when-to-use hint concatenated per entry), each hard-capped at a fixed character limit, with the total capped at roughly 1% of the context window. Front-load your trigger language — tails get truncated.
|
|
83
|
+
- **Loading** is lazy: only metadata enters the always-on context. The full skill body loads only when the skill activates, keeping idle token cost near zero.
|
|
84
|
+
- **Execution** can be inline (shared context) or isolated (forked sub-agent with its own token budget). Isolation prevents a heavy skill from exhausting the parent's context.
|
|
85
|
+
- **Sources** can be bundled, user-installed, or dynamically loaded from plugins. Deduplication by canonical path prevents the same skill from appearing twice across overlapping source directories.
|
|
86
|
+
|
|
87
|
+
**Start here:** Choose a metadata format (frontmatter recommended). Implement two-phase discovery: cheap listing at startup, lazy body loading on invocation. Set a per-entry character cap before your catalog grows.
|
|
88
|
+
|
|
89
|
+
**Tradeoffs:**
|
|
90
|
+
|
|
91
|
+
- Lazy loading saves tokens but adds one round-trip of latency on first activation.
|
|
92
|
+
- Forked execution provides isolation but loses access to the parent's accumulated context.
|
|
93
|
+
|
|
94
|
+
**Go deeper:** [references/skill-runtime-pattern.md](references/skill-runtime-pattern.md)
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 3. Tools and Safety
|
|
99
|
+
|
|
100
|
+
**User problem:** "I want my agent to use tools powerfully, but not dangerously."
|
|
101
|
+
|
|
102
|
+
**Golden rule:** Default to fail-closed. Tools are serial and gated unless explicitly marked safe for concurrency and approved by the permission pipeline.
|
|
103
|
+
|
|
104
|
+
**When to use:** Any agent runtime that needs tool registration, concurrency control, or permission gating.
|
|
105
|
+
|
|
106
|
+
**How it works:**
|
|
107
|
+
|
|
108
|
+
- **Registration** uses fail-closed defaults: tools are non-concurrent and non-read-only unless the developer opts in. This prevents accidental parallel execution of state-mutating operations.
|
|
109
|
+
- **Concurrency classification** is per-call, not per-tool: the same tool can be safe for some inputs and unsafe for others. The runtime partitions a batch of tool calls into consecutive groups — safe calls run in parallel, any unsafe call starts a serial segment.
|
|
110
|
+
- **Permission pipeline** evaluates rules from multiple sources in strict priority order spanning settings files (user, project, local, flag, and policy), CLI arguments, command-scoped rules, and session grants. The evaluator is stateful — it tracks denials, transforms modes, and updates state as a side effect.
|
|
111
|
+
- **Handler dispatch** varies by execution environment: interactive (human prompt), automated (coordinator), or async (swarm agent). The same permission rules feed different approval surfaces.
|
|
112
|
+
|
|
113
|
+
**Start here:** Route every tool call through one permission gate. Default to fail-closed (deny/ask). Add bypass-immune rules for protected paths before shipping any auto-approve mode.
|
|
114
|
+
|
|
115
|
+
> **In Claude Code:** Use `/update-config` to configure permission rules and hooks.
|
|
116
|
+
|
|
117
|
+
**Tradeoffs:**
|
|
118
|
+
|
|
119
|
+
- Fail-closed defaults mean new tools are safe out of the box, but developers must actively opt into concurrency — forgetting to flag a read-only tool as concurrent-safe silently degrades throughput.
|
|
120
|
+
- Multi-source permission layering is powerful but hard to debug when rules from different sources conflict.
|
|
121
|
+
|
|
122
|
+
**Go deeper:** [references/tool-registry-pattern.md](references/tool-registry-pattern.md) | [references/permission-gate-pattern.md](references/permission-gate-pattern.md)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 4. Context Engineering
|
|
127
|
+
|
|
128
|
+
**User problem:** "My agent either sees too much, too little, or the wrong thing."
|
|
129
|
+
|
|
130
|
+
**Golden rule:** Treat context as a budget, not a dump. Every token in the window should earn its place through one of four operations: select, write, compress, or isolate.
|
|
131
|
+
|
|
132
|
+
**When to use:** Any agent whose performance degrades in long sessions, whose delegated work pollutes the parent context, or whose startup is slow due to eager context loading.
|
|
133
|
+
|
|
134
|
+
**How it works:**
|
|
135
|
+
|
|
136
|
+
- **Select** — Load context just-in-time, not all-at-once. Use progressive disclosure with three tiers: metadata (always present, cheap), instructions (loaded on activation), resources (loaded on demand). Memoize expensive context builders and invalidate only at known mutation points — not reactively.
|
|
137
|
+
- **Write** — Context is not read-only. The agent writes back to persistent storage: auto-memory entries, background extraction outputs, task state, permission rules. The write-back loop is what turns a stateless agent into a learning system.
|
|
138
|
+
- **Compress** — Long sessions exhaust the window. Reactive compaction summarizes older turns mid-session, preserving recent context while reclaiming budget. Mark snapshot data as snapshots so the model knows to re-fetch for current state.
|
|
139
|
+
- **Isolate** — Delegated work must not pollute the parent's context. Coordinator workers start with zero context inheritance (only the explicit prompt). Fork children inherit full context but are single-level (no recursive forks). Filesystem-level isolation (worktrees) gives an agent its own working copy.
|
|
140
|
+
|
|
141
|
+
**Start here:** Audit your current context cost per turn. Apply hard caps to every variable-length block. Add truncation recovery pointers (tell the model which tool to call for full output) before enabling any compression.
|
|
142
|
+
|
|
143
|
+
**Tradeoffs:**
|
|
144
|
+
|
|
145
|
+
- Aggressive caching reduces latency but creates staleness risk — every mutation point must explicitly clear the cache, or the model operates on stale data for the remainder of the session.
|
|
146
|
+
- Progressive disclosure saves tokens but means the model can't reason about a skill's full capabilities until it's activated.
|
|
147
|
+
|
|
148
|
+
**Go deeper:** [references/context-engineering-pattern.md](references/context-engineering-pattern.md) (index) | [select](references/context-engineering/select-pattern.md) | [compress](references/context-engineering/compress-pattern.md) | [isolate](references/context-engineering/isolate-pattern.md)
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 5. Multi-agent Coordination
|
|
153
|
+
|
|
154
|
+
**User problem:** "I want parallelism, specialization, and coordination without chaos."
|
|
155
|
+
|
|
156
|
+
**Golden rule:** The coordinator must synthesize, not delegate understanding. "Based on your findings, fix it" is an anti-pattern — the coordinator should digest worker results into precise specs before dispatching implementation.
|
|
157
|
+
|
|
158
|
+
**When to use:** When a task is too large for a single agent, when you need parallel exploration, or when you want persistent specialized teammates.
|
|
159
|
+
|
|
160
|
+
**How it works:**
|
|
161
|
+
|
|
162
|
+
Three delegation patterns serve different task shapes:
|
|
163
|
+
|
|
164
|
+
| Pattern | Context sharing | Best for |
|
|
165
|
+
|---------|----------------|----------|
|
|
166
|
+
| **Coordinator** | None — workers start fresh | Complex multi-phase tasks (research → synthesize → implement → verify) |
|
|
167
|
+
| **Fork** | Full — child inherits parent history | Quick parallel splits sharing loaded context |
|
|
168
|
+
| **Swarm** | Peer-to-peer via shared task list | Long-running independent workstreams |
|
|
169
|
+
|
|
170
|
+
Key constraints:
|
|
171
|
+
|
|
172
|
+
- Fork is single-level only — recursive forks would multiply context cost exponentially.
|
|
173
|
+
- Swarm teammates cannot spawn other teammates — the roster is flat to prevent uncontrolled growth.
|
|
174
|
+
- Results arrive asynchronously; fire-and-forget registration returns an ID immediately so the parent can continue working.
|
|
175
|
+
|
|
176
|
+
**Start here:** Pick one delegation pattern and implement it fully before mixing patterns. Write every sub-agent prompt as a self-contained document. Add a synthesis step between research and implementation workers — this is where the orchestrator adds value.
|
|
177
|
+
|
|
178
|
+
**Implementation checklist for the coordinator pattern:**
|
|
179
|
+
|
|
180
|
+
1. Define phased workflow: research → synthesize → implement → verify
|
|
181
|
+
2. Write self-contained prompts for each worker (no "based on your findings")
|
|
182
|
+
3. Filter each worker's tool set to only what it needs
|
|
183
|
+
4. Decide continue-vs-spawn policy: continue if context overlaps, spawn fresh for verification
|
|
184
|
+
|
|
185
|
+
**Tradeoffs:**
|
|
186
|
+
|
|
187
|
+
- Coordinator mode is safest but slowest — each phase waits for the previous one.
|
|
188
|
+
- Fork is fastest but limited to one level and shares the parent's full context cost.
|
|
189
|
+
- Swarm is most flexible but hardest to coordinate — peers communicate only through a shared task list.
|
|
190
|
+
|
|
191
|
+
**Go deeper:** [references/agent-orchestration-pattern.md](references/agent-orchestration-pattern.md)
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 6. Lifecycle and Extensibility
|
|
196
|
+
|
|
197
|
+
**User problem:** "I need hooks, background tasks, and a clean startup sequence."
|
|
198
|
+
|
|
199
|
+
**Golden rule:** Extensibility is an injection point, not an inheritance hierarchy. Hooks attach side effects at lifecycle moments; tasks track async work with strict state machines; bootstrap layers initialization sequentially with memoized stages.
|
|
200
|
+
|
|
201
|
+
**When to use:** When you need to extend agent behavior without modifying core code, track long-running background work, or structure initialization across multiple entry modes.
|
|
202
|
+
|
|
203
|
+
**How it works:**
|
|
204
|
+
|
|
205
|
+
- **Hooks** extend behavior by attaching side effects at defined lifecycle moments (pre/post tool execution, prompt submission, agent start/end). Trust is all-or-nothing: if the workspace is untrusted, all hooks skip — not just suspicious ones. Session-scoped hooks are ephemeral and cleaned on session end.
|
|
206
|
+
- **Long-running work** is tracked via typed state machines. Each work unit gets a typed, prefixed ID, a strict lifecycle (running → completed / failed / killed), and disk-backed output. Eviction is two-phase: disk output cleaned eagerly at terminal state, in-memory records cleaned lazily after the parent has been notified.
|
|
207
|
+
- **Bootstrap** structures initialization as dependency-ordered, memoized stages. The trust boundary — the point where the user grants consent — is the critical inflection: security-sensitive subsystems (telemetry, secret environment variables) must not activate before trust is established. Multiple entry modes (CLI, server, SDK) share the same bootstrap path with different entrypoints.
|
|
208
|
+
|
|
209
|
+
**Start here:** Route all hooks through a single dispatch point. Implement the trust gate before adding any external hook type. Register cleanup handlers during init, not at usage sites.
|
|
210
|
+
|
|
211
|
+
> **In Claude Code:** Use `/update-config` to configure hooks (pre/post tool execution, prompt submission).
|
|
212
|
+
|
|
213
|
+
**Tradeoffs:**
|
|
214
|
+
|
|
215
|
+
- All-or-nothing hook trust is simple but coarse — one untrusted hook disables the entire extension system.
|
|
216
|
+
- Disk-backed task output keeps memory constant but adds I/O latency proportional to concurrent work units.
|
|
217
|
+
|
|
218
|
+
**Go deeper:** [references/hook-lifecycle-pattern.md](references/hook-lifecycle-pattern.md) | [references/task-decomposition-pattern.md](references/task-decomposition-pattern.md) | [references/bootstrap-sequence-pattern.md](references/bootstrap-sequence-pattern.md)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Gotchas
|
|
223
|
+
|
|
224
|
+
Non-obvious principles that will cause bugs if you violate them:
|
|
225
|
+
|
|
226
|
+
1. **Concurrency classification is per-call, not per-tool.** A tool may be safe for some inputs and unsafe for others. Don't assume a tool's concurrency behavior is static — the runtime decides per invocation.
|
|
227
|
+
|
|
228
|
+
2. **Permission evaluation has side effects.** The permission checker tracks denials, transforms modes, and updates state. Don't treat it as a pure lookup function.
|
|
229
|
+
|
|
230
|
+
3. **Most async work skips the "pending" state.** In practice, work units register directly as "running." Don't build UIs that assume every work unit starts pending.
|
|
231
|
+
|
|
232
|
+
4. **Fork children must not fork.** The recursive guard preserves a single-level invariant. The fork tool stays in the child's tool pool (for prompt cache sharing) but is blocked at call time.
|
|
233
|
+
|
|
234
|
+
5. **Context builders are memoized but manually invalidated.** Add a context source without adding a corresponding invalidation point, and the model sees stale data for the entire session.
|
|
235
|
+
|
|
236
|
+
6. **Memory indexes have hard caps.** Entries beyond the cap are silently truncated. Without periodic cleanup, recent entries become invisible.
|
|
237
|
+
|
|
238
|
+
7. **Skill listing budgets are tight.** Descriptions are concatenated and capped per entry. Front-load the most distinctive trigger language — the tail gets cut.
|
|
239
|
+
|
|
240
|
+
8. **Hook trust is all-or-nothing.** If the workspace is untrusted, the entire hook system is disabled, not just individual suspicious hooks.
|
|
241
|
+
|
|
242
|
+
9. **The default permission for tools is "allow."** Tools that don't implement custom permission logic delegate entirely to the rule-based system. Override only when you need tool-specific gates (path ACLs, quotas, etc.).
|
|
243
|
+
|
|
244
|
+
10. **Eviction requires notification.** A terminal work unit is only GC-eligible after the parent has received the completion signal. Evicting before notification creates a race where the parent can never read the result.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## When NOT to Use This Skill
|
|
249
|
+
|
|
250
|
+
This skill is about the **harness** around an agent, not:
|
|
251
|
+
- Prompt engineering or system prompt design
|
|
252
|
+
- Model selection or fine-tuning
|
|
253
|
+
- Generic software architecture (MVC, microservices)
|
|
254
|
+
- Chat UIs or conversational interfaces
|
|
255
|
+
- LLM API integration basics
|
|
256
|
+
|
|
257
|
+
If your question is about the model itself rather than the system around it, this skill does not apply.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"organization": "Community",
|
|
4
|
+
"date": "April 2026",
|
|
5
|
+
"abstract": "Production harness patterns for AI coding agents — memory, permissions, context engineering, multi-agent delegation, skill runtimes, hook lifecycles, bootstrap sequences. Distilled from systematic source-level analysis of Claude Code.",
|
|
6
|
+
"references": [
|
|
7
|
+
"https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents",
|
|
8
|
+
"https://github.com/anthropics/claude-code"
|
|
9
|
+
]
|
|
10
|
+
}
|