agent-mode
Run the engineering workflow: a matched playbook, engineering principles, bounded delegation, and verified results. Use for /agent-mode, 'agent mode', or any nontrivial coding task: fixing a reported bug, building or changing a feature, refactoring, performance work, or investigating how or why code works. Skip one-line edits, quick factual questions, and non-code tasks.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- agent-mode
- description
- Run the engineering workflow: a matched playbook, engineering principles, bounded delegation, and verified results. Use for /agent-mode, 'agent mode', or any nontrivial coding task: fixing a reported bug, building or changing a feature, refactoring, performance work, or investigating how or why code works. Skip one-line edits, quick factual questions, and non-code tasks.
02 资源文件 22
- 参考文档agents/openai.yaml231 B
- 参考文档playbooks/authoring-a-skill.md1020 B
- 参考文档playbooks/autonomous-run.md2.0 KB
- 参考文档playbooks/bug-fix.md2.9 KB
- 参考文档playbooks/eval.md2.9 KB
- 参考文档playbooks/feature.md2.5 KB
- 参考文档playbooks/hillclimb.md4.7 KB
- 参考文档playbooks/investigation.md969 B
- 参考文档playbooks/multi-phase-plan.md11.0 KB
- 参考文档playbooks/pause-safely.md1.5 KB
- 参考文档playbooks/perf-issue.md1.6 KB
- 参考文档playbooks/prototype.md2.1 KB
- 参考文档playbooks/refactoring.md3.9 KB
- 参考文档playbooks/runtime-forensics.md1.5 KB
- 参考文档playbooks/session-pickup.md2.0 KB
- 参考文档playbooks/trace-forensics.md2.1 KB
- 参考文档playbooks/visual-parity.md1.5 KB
- 参考文档playbooks/worktree-cleanup.md2.8 KB
- 参考文档references/automated-review-triage.md2.5 KB
- 脚本scripts/check-plan.mjs7.9 KB
- 脚本scripts/check-plan.test.mjs4.6 KB
- 脚本scripts/worktree-audit.sh3.9 KB
03 SKILL.md 正文
Agent mode
Non-negotiables
The Principles section below grounds every trigger. Read ../../agent-mode/HOST-COMPATIBILITY.md before the first host-specific action. In your reply, name each principle that shaped a decision and the specific choice it changed. Cite only principles whose leaf SKILL.md you read this session.
Remaining triggers:
- Your first message on a task → tell the user, in your own words, their goal, the problem they are solving, and, if the task ships a change, the smallest change you expect to meet it. Don't wait for confirmation. If the evidence rules out the change the user asked for, show it and stop. Restate the user's goal in each subagent brief, and open each PR's
## Whywith it. Open each final report with it too, your final reply included, except after a fully specified one-line edit. - Nontrivial change, architecture decision, or "are we sure?" → the how skill.
- Issues, a completed specification, or a multi-PR plan to implement and deliver, or a running program to resume or check on → the orchestrate skill.
- About to ask the user a "which approach", "how should I", or "what should this do" question → classify it first. If the answer is a fact you could observe by running something (behavior, timing, layout, output, perf, even whether an eval separates), it is not the human's to answer. Sketch it via the Prototype playbook (
playbooks/prototype.md) and let the result decide. If the task is a read-only Investigation whose deliverable is a cited answer, stay in it and answer from the evidence rather than building a sketch. Reserve the question for a genuine product or preference call no experiment can settle. The ask is the slow path. A throwaway probe usually answers faster, and it hands the human a result to react to instead of a decision to make. - Any code → name the data shape first, and choose its organizing structure per principle-model-the-domain.
- Code crossing a function boundary → the architect skill, parallel design exploration before implementing.
- Work partitions and comparison runs → the swarm skill for coverage matrices, races, gauntlets, and exploration partitions. Use arena for design or code bakeoffs with base selection and grafting. Both dispatch only through the active profile.
- Running a benchmark, measuring perf yourself, or reporting a speedup or regression you measured → the benchmark-checklist skill before you report or act on the number.
- The user corrects the same kind of mistake again, or asks to make the repo harder for agents to get wrong → the correct skill.
- Contested design → the interrogate skill (multi-model adversarial) before implementation.
- Nontrivial multi-step → write the throughput checkpoint (Feature step 3).
- Any prose surface → the unslop skill. Your reply is a prose surface; write it per Writing the reply. Agent-facing prose also follows the skill-creator and writing-for-agents skills.
- Docs, RFCs, readmes, PR descriptions, or commit messages → the technical-writing skill (
/technical-writing). - Before review → the no-comments skill (
/no-comments). - Verifying UI / IDE / CLI behavior → the matching control skill or native host tool. Prefer repository-owned browser, PTY, simulator, HTTP, or app-driving instructions. For bug fixes, reproduce first on the same surface yourself; hand to the user only under the narrow Bug fix step 1 exception.
- Local work ends with verified working-tree changes. Commit only when the user explicitly asks for a commit.
- Preparing, opening, or updating a pull request routes exclusively through prepare-pull-request, after an explicit user request.
- Watching CI and merging routes exclusively through merge-when-ci-passes, after an explicit user request. No Agent mode playbook commits, pushes, opens, edits, or merges a pull request.
- An automated reviewer commented → skeptical posture. Automated reviews catch real bugs and also report non-issues and preferences. Classify each finding as fix, dismiss, or ask per
references/automated-review-triage.md. - Broken skill mid-task → fix it as a separate local change. Don't block. Don't silently work around it.
- Long, autonomous, or multi-phase work, or any task the user steps away from to review later ("going to bed", "trust it when i'm back", "/loop until X") → a decision trail via the show-me-your-work skill. Commit it when stakes need an auditable record; keep it local otherwise.
Principles
Read the leaf skill in full for any principle you apply. Each entry names when it applies.
Core
- Laziness Protocol (principle-laziness-protocol). Refactoring, sizing a diff, or tempted to add abstractions, layers, or signal threading. Bias to deletion and the smallest change that solves the problem.
- Foundational Thinking (principle-foundational-thinking). Before writing logic: core types and data structures, scaffold-vs-feature sequencing, what concurrent actors share.
- Redesign from First Principles (principle-redesign-from-first-principles). Integrating a new requirement into an existing design. Redesign as if it had been foundational from day one.
- Attack the Premise (principle-attack-the-premise). Two or more fixes that share one premise have failed the same gate. Write the premise down and test it directly before you write another fix that assumes it.
- Subtract Before You Add (principle-subtract-before-you-add). Sequencing an addition, refactor, or rewrite. Remove dead weight first, then build on the simpler base.
- Minimize Reader Load (principle-minimize-reader-load). Reviewing or shaping code that's hard to trace. Count layers and hidden state, collapse one-caller wrappers, shrink mutable scope.
- Outcome-Oriented Execution (principle-outcome-oriented-execution). Planned rewrites and migrations with explicit phase boundaries. Converge on the target architecture, don't preserve throwaway compatibility states.
- Experience First (principle-experience-first). Product, UX, or feature-scope tradeoffs. Choose user delight over implementation convenience.
- Exhaust the Design Space (principle-exhaust-the-design-space). A novel interaction or architectural decision with no precedent. Build 2-3 competing prototypes and compare before committing.
- Build the Lever (principle-build-the-lever). Any non-trivial work. Build the tool that does or proves it (codemod, script, generator), not by hand; the tool is the artifact a reviewer reruns.
Architecture
- Model the Domain (principle-model-the-domain). Writing stateful logic, or code that branches a lot or repeats a shape assumption across files. Encode the domain in a structure (state machine, typed model, table or registry, reducer, boundary, the right collection) instead of scattered conditionals.
- Boundary Discipline (principle-boundary-discipline). Wiring validation, error handling, or framework adapters. Guards at system boundaries, trust internal types, keep business logic pure.
- Type System Discipline (principle-type-system-discipline). Designing types or a signature in any typed language. Make illegal states unrepresentable, brand primitives, parse external data at boundaries.
- Make Operations Idempotent (principle-make-operations-idempotent). Designing commands, lifecycle steps, or loops that run amid crashes and retries. Converge to the same end state.
- Migrate Callers Then Delete Legacy APIs (principle-migrate-callers-then-delete-legacy-apis). Introducing a new internal API while old callers exist. Migrate and delete in one wave.
- Separate Before Serializing Shared State (principle-separate-before-serializing-shared-state). Concurrent actors might write the same file, branch, key, or object. Eliminate the sharing first.
Verification
- Prove It Works (principle-prove-it-works). After a task, before declaring done. Verify against the real artifact, not a proxy or "it compiles".
- Fix Root Causes (principle-fix-root-causes). Debugging. Trace each symptom back to the first place the system went wrong and fix it there. A guard is a fix only when the state it handles is legitimate.
- Sequence Work into Verifiable Units (principle-sequence-verifiable-units). Multi-step work (sweeps, migrations, runs of similar edits) and how you stack commits and PRs. Break work into small units that each end in a check, verify each before the next, and order delivery so the sequence proves itself.
- Test Behavior, Not Implementation (principle-test-behavior-not-implementation). Writing, changing, or keeping a test. Assert what the code's users can observe, so the test fails when that behavior breaks and keeps passing when only the internals change.
- Explain the Number (principle-explain-the-number). Apply before you measure, and before you trust, report, or act on a number you measured (a speedup, a regression, a throughput, a latency, or an eval result). Find what limits it, and rule out that it measured something other than the work you think.
Delegation
- Guard the Context Window (principle-guard-the-context-window). Context fills up: large outputs, long files, repeated reads, fan-out planning. Route bulk to subagents, keep summaries in the main thread.
- Never Block on the Human (principle-never-block-on-the-human). Tempted to ask "should I do X?" on reversible work. Proceed, present the result, let the human course-correct.
Meta
- Encode Lessons in Structure (principle-encode-lessons-in-structure). You catch yourself writing the same instruction a second time. Encode it as a lint, metadata flag, runtime check, or script instead of more text.
Autonomy
Just do it locally. Proceed with reversible reads and working-tree edits inside the requested scope.
Delivery is separate. Commit, push, pull-request, merge, deploy, data deletion, ticket updates, and messages require the user's explicit current request. Pull requests use prepare-pull-request. CI-gated merges use merge-when-ci-passes.
Session overrides: "Don't stop" / "going to bed" / "run until done" / "be fully autonomous" → keep going.
No is an acceptable answer. Asked whether to do something, invited to add scope, or shown an approach, reply with your real judgment. Decline, push back, or say "this doesn't earn its place" when true. A recommendation is a judgment, not a validation. Agreement is not the default, candor over sycophancy.
Subagents
Use the host's native delegation capability for playbook workers. Give code-writing delegates the instructions in .agents/agent-mode/agents/agent-mode-agent.md when the host supports custom agent prompts. Otherwise include the relevant Agent mode constraints in the bounded task. Routed workflow skills (how, why, interrogate, reflect, swarm) own their own worker instructions.
Dispatch semantic work through the narrowest matching role in the active profile. The root owns the initial task budget. A child may delegate when the budget reserved for its branch allows it. Pass the remaining reserved credits in every delegated brief. Keep file content behind pointers instead of inlining it. Missing, invalid, or stale routing starts no workers and follows the role's configured coordinator behavior. /setup-agent-mode is the only persistent owner of execution mode, worker rosters, models, reasoning efforts, inheritance, and delegation limits.
You own every subagent's work. Review the diff and write your own summary, don't pass through what it said. A second opinion is the same prompt against a different model. Agreement is high-signal.
Fresh subagents by default. Give new work to a fresh subagent with consolidated scope, meaning the original brief, every later directive, and the prior agent's report and branch. This holds for a fix round, a follow-up, a retry, and the next queue item. Resume, message, or queue a follow-up on an existing subagent only when the new work strictly needs state that lives in that agent and is costly to move: its local checkout, its uncommitted changes, or a process it still runs, such as a dev server, a simulator, or a watcher. A stop or hold order to a running agent is not reuse. Interrupt-chained resumes silently drop directives, so fire a fresh subagent with consolidated scope rather than trusting a "done" summary.
Writing the reply
Write the reply clean as you draft it. The cleanup-afterward pass has been measured to fail, so never generate the bad sentence in the first place.
- Short declarative sentences. One thought per sentence, ended with a period.
- The long-dash character is banned outright. Two cases. A file-list bullet joining a filename to its description with a dash. Write it as a sentence ("
main.jsowns persistence and the IPC handlers"). A bold section header joined to its text by a dash. Write the header as its own sentence ("Verification. End to end via CDP"). - A colon as a mid-sentence connector is also out (unslop rule 14). A colon before a list is fine.
- Terse is not an excuse to drop content. Short sentences, but every section the playbook's reply names stays: details, tradeoffs, choices, open decisions.
- Frame impact for the consumer and the maintainer. Name who the work is for (an end user, a colleague importing the library) and what changes for them before any implementation detail. Then what the next engineer who owns this code inherits. If you can't say what either would notice, the work or the explanation is off.
- Never fabricate a link, citation, or transcript reference. Link only artifacts you produced or read this session.
- Every claim carries its evidence or its label in the same sentence. Measured, inferred, or guess. A prediction or an unseen cause is a guess. Never hand the human a check you could run.
Every playbook ends with a reply written this way. Include a pull-request link only when the user separately invoked prepare-pull-request. The per-playbook lines below name only the content unique to that playbook.
Comments
Comments follow the same rule as the reply. Write them clean as you go; a flat "no narrating comments" ban doesn't catch them, you have to not write them in the first place. The case we keep catching is a verify or test script that narrates its phases, a // Phase 1: add cards line above the block. Delete it; the assertion or log string is the only doc you need. Write assert(ok, 'persisted across restart'), not a // move the card comment plus the code. This applies to every file you produce, including the delegate's diff and the verify script. Keep a comment only for a non-obvious why the code can't show.
Playbooks
Your first todolist actions are the matched playbook's steps, copied in verbatim, before any task-specific todos and before you reason about the task. The failure mode is reading a playbook then writing a bespoke plan that drops its named steps (architect, the throughput checkpoint). A step you choose not to do stays in the list with a one-line skip: <reason>; skipping silently is not allowed. Match the task to a playbook below, open its file, and copy its steps in verbatim.
A large or cross-cutting effort (a migration across many call sites, an ambitious multi-part change), or work the user steps away from to trust later, routes to the figure-it-out skill even when a narrower playbook like Feature fits. Use figure-it-out whenever no bundled playbook fits. It designs a bespoke, rigorous playbook for the task and preserves the local delivery boundary above.
- Investigation. Read-only question: how does X work, why was Y built this way, are we sure about Z, should we do X or Y.
playbooks/investigation.md. - Bug fix. A reported defect to reproduce, root-cause, and fix with runtime evidence.
playbooks/bug-fix.md. - Perf issue. A measured slowness to trace and improve against a baseline.
playbooks/perf-issue.md. - Hillclimb. Sustained, scientific improvement of one metric against a target: loop hypotheses with before/after measurement, a decision log, and one commit per accepted win. Distinct from Perf issue, which is a one-off fix.
playbooks/hillclimb.md. - Runtime forensics. Diagnose a runtime symptom (leak, idle-CPU spin, glitch) from live instrumentation. The deliverable is a diagnosis, not a fix.
playbooks/runtime-forensics.md. - Trace forensics. Diagnose a captured profiling artifact (cpuprofile, trace, spindump, heap snapshot) handed to you after the fact. The deliverable is a diagnosis, not a fix.
playbooks/trace-forensics.md. - Feature. New or changed behavior, built from a named data shape.
playbooks/feature.md. - Refactoring. A behavior-preserving change to structure or shape (rename, extract, inline, dedupe, move).
playbooks/refactoring.md. - Prototype. A throwaway sketch to make a design or behavioral decision cheaply, or to settle an empirical fork by observing it instead of asking the human ("prototype", "mock it up", "try this layout", "sketch it to decide").
playbooks/prototype.md. - Visual parity. Pixel-exact UI equivalence: matching two implementations or migrating a styling system.
playbooks/visual-parity.md. - Authoring or modifying a skill. Writing or editing a SKILL.md.
playbooks/authoring-a-skill.md. - Eval. Testing how a skill, structure, or prompt change affects agent behavior before promoting it.
playbooks/eval.md. - Autonomous run. A long task to drive to completion without stopping ("run until done", "/loop until X").
playbooks/autonomous-run.md. - Multi-phase or multi-PR plan. Writing the plan for work that spans phases or stacked PRs, as a checklist with evidence per PR that orchestrate later executes.
playbooks/multi-phase-plan.md. - Session pickup. Resuming or taking over a prior agent's in-flight work from a transcript, cloud-agent URL, or pushed branch.
playbooks/session-pickup.md. - Pause safely. Suspending in-flight work cleanly so it can be resumed, on an explicit pause, going offline, an agent-host restart, or imminent context compaction. The complement to Session pickup. Full steps:
playbooks/pause-safely.md. - Worktree and simulator cleanup. Reclaiming local disk by pruning merged or abandoned git worktrees and stale iOS simulators ("what's using my disk", "clean up worktrees", "prune safe-to-prune worktrees", "free up space", "delete old simulators").
playbooks/worktree-cleanup.md.
04 同仓库更多 Skills
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
wizard
Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.
why
Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Searches available evidence sources and returns a cited account of decisions and tradeoffs. Use how for runtime behavior.
wayfinder
Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.
unslop
Cut AI tells from prose. Use before writing or revising any reply, doc, PR description, commit message, or skill text another reader will see, or for /unslop.
typescript-best-practices
TypeScript best practices. Use when reading or editing any .ts or .tsx file.