Skip to content

Common patterns for skill harnesses ​

Source: an audit of 2026-10 session records (about 770 sessions, including the first and second pro-launch audits). Issue #950.

Purpose ​

To build better skill harnesses, this page collects the general lessons, independent of any one skill, that the session audit confirmed again and again. Use it as the reference document for open-source sharing and for applying these ideas to other harnesses. Individual bugs are handled in their linked issues; this page covers only the patterns.

What works (keep it and generalize it) ​

  • A uniform JSON envelope (ok, code, summary, next): of about 3,360 calls, about 90 returned ok:false, and every one of them was machine-readable. The agent branches on code, not on the wording, and follows next.
  • bad_args as JSON: the agent corrects itself in one turn. available_subcommands gets used.
  • Domain-aware warnings: label_warning, assignee_warning, Korean/English status label equivalence (#776).
  • Passing secrets through environment variables (SECRET_VALUE), sanitize-message, staging with explicit paths, redirect-safe log downloads.
  • pro-launch's fixed entry point + newer_installed, known_fix and kb, learn_hint, the device claim display.
  • Dry-run before/planned for actions that change a remote repository + approval per repo.

General lessons ​

  1. Agents guess arguments, regular expressions and key names. Accept the most commonly guessed forms, or fail with a hint. When the same guess repeats across independent sessions, it is a product signal (--issue N in about 12 sessions).
  2. Put usage inside the structured error. usage, one example, the closest subcommand. Agents read only the stdout JSON.
  3. A fixed entry point beats path searching. 18% of calls were find | sort -V | tail -1.
  4. Provide a field selector and an output schema. --field a.b removes inline Python and the KeyError family.
  5. Keep a verified raw API escape hatch. When a feature is missing, the agent reads the token from a config file and uses curl. An api pass-through command that injects auth centrally is safer. Grepping sessions for api.github.com gives you a map of missing features.
  6. Put polling inside the tool. One --wait --timeout beats sleep (blocked by the harness), scheduled wake-ups and watch loops. Return a final verdict and next.
  7. Waiting states need an age and a way out. A waiting with no time limit turns a dead pipeline into an endless wait (4.5 hours). Include age_seconds and report stuck at a threshold.
  8. Turn any ritual the agent types by hand more than 3 times into a subcommand. Base sync, worktree create + copy + record, comment + label + close.
  9. Separate transient errors from permanent ones. Retry only 5xx and mark retryable. For non-idempotent calls, detect duplicates with a marker.
  10. Check cheap preconditions inside the tool first. Checking that the branch exists on origin names the cause, instead of GitHub's vague 422.
  11. Do not take secrets through argv. When the permission classifier blocks it, the agent gives up instead of changing its approach. Provide a store, environment variables and a human prompt. Docs that tell the agent to read a secret also leak into session records.
  12. Silent correction is a bug. Image resizing, accepting empty input, Path('.').parents. Surface it as a structured warning.
  13. Tell transport success apart from remote command failure. Map known exit codes such as ssh 255 and sshpass 5 to named codes, take remote output as bytes and decode it in the order utf-8 > legacy code page > replace.
  14. QA steps that change the environment keep a ledger. Record the before/after values and verify the restore. Before filing a defect, rule out leftover state and tool errors through a different input path.
  15. Document a platform symmetry table. A table that covers only one side makes the agent build the other side by hand (22 Maestro YAML files). If it cannot be built, do not skip it silently; report blocked with a reason.
  16. Give large payloads a file-based happy path. For tools with large MCP results, without an ingest that takes the result file the harness saved, the agent spends the tokens again or skips the tool.
  17. Subagent contract: the worker writes and verifies its own output file, and the parent only checks that it exists. Put the resolved script path into the prompt template.
  18. Separate approval gates. "Write a report" can be automatic; "change a remote repository" is always manual and shows the values before and after the change.
  19. Provide deterministic choices as scripts. If "the 3 weakest" is left as prose, the answer differs on every run.
  20. Find dead features with usage metering. Record only the subcommand and code (no arguments) locally, and on each release look at "never called", "most common error code", the number of --help calls, raw API hosts and the amount of exploration boilerplate. These four numbers alone produced most of this audit.
  21. Tie docs and code together with tests that run the docs as written on both OSes. A recipe verified only on Windows breaks silently on macOS. Block forbidden idioms, such as git porcelain that truncates text, with a lint.
  22. Model/effort fit as data. A frontmatter field instead of a prose banner (⚠️ model recommendation). Parallel workers record the model they used in their output and warn on degenerate output (for example, 0 citations).
  23. Put a fix id in the failure response. Show the fix verified in sessions on the first failure, not after 3 failures.
  24. Fact memory also keeps failures and explorations of unsupported platforms. Otherwise every session learns chcp and schtasks all over again.

What this repo implements ​

PatternImplementation
Fixed entry point + old version warningscripts/projectops_cli.py, scripts/common/stable_entry.py (#942)
4 leading response keys, --brief/--field, usage in bad_argsscripts/common/emit.py, cli_parser.py (#940)
Polling inside the tool, stuck verdictactions wait, deploy-status --wait (#939, #945)
Transient error retry, idempotent reconciliationscripts/common/github_rest/transport.py, issues.py (#941)
Environment change ledgerdevice appearance/locale/text-size --restore (#929, #947)
Precondition pre-checkcreate-pr head check (#938)