Files
Defame1297 620f20b0fd refactor(kyberforge)!: merge skill-audit and agent-audit into factory-audit
Why

The two audit skills carried 1,724 lines of byte-identical duplication: the ADR-0020 boundary
resolver (1,061), vale-wrap.sh (526), the Vale style rules (44) and the Contributing-files parser
(93). Nothing shared them — they were held in sync by a 413-line pre-push gate and its 797-line
test suite. Sync-by-gate had already failed once: at 484357a the two parser copies drifted into
different spellings of the bullet loop while a docstring asserted they were identical. That drift
was behaviour-neutral and was re-unified by hand at 598a7c3, so the copies were identical at merge
time — but nothing had caught it, and the next drift need not be neutral.

Implementation Notes

Self-containment binds BETWEEN skills, not within one. The agentskills.io spec forbids reaching
across skill directories, which is why two separate skills needed embedded copies; two files inside
ONE skill may source a third. That is the whole reason the merge removes duplication rather than
relocating it.

The union of both bodies measured 1,532 words against BODY_MAX_WORDS=900, and only 211 of those
words were shared, so SKILL.md is a dispatch body. Step 0 resolves the flow from the target path
before any validation, and its table mirrors validate.sh's detection exactly: a directory holding
SKILL.md or a SKILL.md file (skill); a *.agent.md, or a .md directly under an agents/ directory
(agent); anything else stops without running a validator. Steps 1-3 live in
references/skill-flow.md and references/agent-flow.md, and gotchas that apply to one flow live in
that flow's file, since it is loaded on every invocation anyway. If validate.sh reports on the
other artifact type, the body restarts at Step 0.

Named factory-audit rather than forge-audit because forge is a live skill, and a family prefix that
matches a live sibling reads as ownership rather than membership.

The description carries one arrow per boundary target, because ADR-0020 resolves only the first
target after an arrow. It drops the quoted "audit this skill"-style phrases, which restated
"audited" in a second register (ADR-0020's duplicate-register rule). 241 characters, Gotchas 16%
of the body: no size SUGGESTIONs.

The boundary resolver stays embedded in two files rather than imported: a cache-installed plugin
cannot read outside its own directory, and the repo-root hook resolves via .pre-commit-hooks.yaml
where entry[0] is the only token pre-commit rewrites, so no single file is reachable by both.
tests/test-adr0020-contract.sh hashes both copies for byte-identity, and asserts validate.sh sources
the resolver and that no third copy exists.

The entry scripts classify the target from its resolved parent directory, so a bare agent filename
typed inside agents/ works; resolve SCRIPT_DIR CDPATH-safely; and exit 2 when a lib-*.sh is
missing, rather than dying with exit 1, the tier the flows relay as real findings.

The provenance run functions stash their findings code in KYBERFORGE_PROV_RC and
return 0, so validate-provenance.sh calls them UNTESTED. Testing a function's
status (`f || RC=$?`) disables errexit for its entire body, and no subshell or
`set -e` inside can re-arm it once the call sits in a condition context
(measured, both spellings). Their error paths use `exit`, which is unaffected
either way; this keeps errexit armed for anything added later.

Case 0's readability guard reads the file instead of asking `[[ -r ]]`. `-r` is
access(2), which answers yes for uid 0 even on a mode-000 file, and this repo's
dev environment is root -- so the guard could never fire where it exists to fire.
A read attempt is also the stricter question, catching EIO. This is the reasoning
scripts/check-vale-style-sync.sh carried before this commit deleted it; the
hazard did not go with it.

All three entry scripts are CDPATH-safe, vale-wrap.sh included: both of its cd sites are cleared,
the --config resolution and the directory-mirror walk, where an exported CDPATH would otherwise
print a decoy path into the -print0 stream and build the mirror from the decoy's files. The two
remaining bare cd calls take absolute paths, which CDPATH is never consulted for.

Impact

BREAKING: skill-audit and agent-audit no longer exist as invocable skills. kyberforge goes to
2.0.0 (catalog 0.4.7).

Check logic is unchanged: differential runs of the old and new validators across every skill and
agent produced byte-identical stdout, stderr and exit codes, and the reconstructed Python payloads
differ only in comments and the references/field-inventory.md -> agent-field-inventory.md rename.
One doctrine governs the tiers: exit 0 is audited and clean, exit 1 is audited with findings OR a
target present but unreadable, exit 2 is that nothing was audited at all. Edge paths DID change,
deliberately (full table in ADR-0025):
- a missing target exits 2 (never ran), not 1, under its own "does not exist" message; detection is
  by path shape, so a shape-matching path that is simply absent used to reach the validator and come
  back as a FAIL against a file that never existed;
- an unshaped target exits 2 under the generic "matches neither" message, and a directory with no
  SKILL.md under a third, distinct one -- three exit-2 messages, not one;
- a dangling symlink or a symlink loop stays exit 1: it is present but broken, which is a finding
  about the artifact rather than a usage error;
- a SKILL.md file path is audited as its skill directory instead of refused;
- a .md agent outside an agents/ directory is refused rather than audited;
- a missing script library, a missing python3, a missing PyYAML, and no argument at all each exit 2.
  validate-provenance.sh already exited 2 for the last two; validate.sh now matches it.

.pre-commit-hooks.yaml is a published contract consumed by external repos. Both hook IDs and both
files: regexes are unchanged; only entry: and description: moved.

scripts/check-vale-style-sync.sh (413), scripts/sync-vale-styles.sh (21),
tests/test-check-vale-style-sync.sh (797) and agent-audit/scripts/README.md (47) are deleted. The
checker made 17 assertions: 6 compared the two Vale copies and are moot; 10 are rehomed into
tests/test-vale-wrap.sh (case 0, cases 28-31, and the suite's Vale-absent skip); and the
cross-manifest files: agreement check, which selected hooks by entry: and so could not survive both
hooks sharing one, is ported as case 33 pairing hooks by id:. Cases 28, 30 and 33 carry mutation
self-tests; narrowing the local skill prefilter to 6 of 38 SKILL.md files now fails the suite.

Skills go 39 to 38. Pre-push goes 9 repo-authored hooks to 8.

ADR: 0025
BREAKING-CHANGE: the skill-audit and agent-audit skills are removed. Both flows are served by
  factory-audit, which auto-detects whether it was handed a skill directory or an agent file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YR2CjVumUbEGWcMikcoXBD
2026-09-16 09:13:57 +00:00

5.5 KiB

source_keys
source_keys
claude-code-subagents-docs
context7-github-en-copilot
github-custom-agents-configuration
github-cli-plugin-reference

Project and user scope — the Claude Code / Copilot pair

Two files per agent, written in one pass and kept in step: a Claude Code .md and a Copilot CLI .agent.md. The system prompt body is the same in both — the agent's task does not change with the provider. The frontmatter is not.

Scope Claude Code Copilot CLI
Project .claude/agents/<name>.md .github/agents/<name>.agent.md
User ~/.claude/agents/<name>.md ~/.copilot/agents/<name>.agent.md

Claude Code file

name — lowercase letters and hyphens only, unique within the scope. Claude Code discards a duplicate silently.

description — write it against references/contract.md. It is the primary signal for autonomous delegation.

tools — an allowlist. Write it, and restrict it to the tools the agent actually needs; omitting it inherits every tool from the parent, which is the right value only when the agent genuinely needs all of them. Least privilege is the default, not the exception. Use Agent(type1,type2) to restrict which subagent types this agent may spawn, and omit Agent entirely to stop it spawning any. Five tools reach no subagent whatever this field says — AskUserQuestion, EnterPlanMode, ExitPlanMode, ScheduleWakeup and WaitForMcpServers — so listing one buys nothing. The single exception is ExitPlanMode, available when the parent session runs permissionMode: plan.

disallowedTools — a denylist, applied before tools and taking precedence over it. Supports mcp__<server>, mcp__<server>__* and mcp__* globs. Both a YAML list and a delimited string are accepted; this repo writes the comma-separated string form (disallowedTools: Edit, Write, NotebookEdit) — match it.

model — set it when the agent needs a different capability tier (haiku for fast lookups, opus for deep reasoning). Resolution order is CLAUDE_CODE_SUBAGENT_MODEL → the per-invocation parameter → this field → the main session model, so the frontmatter value is a low-priority default rather than a guarantee.

Optional fields worth considering, none of which exist at plugin/APM scope:

  • maxTurns — cap agentic turns on a bounded task, to stop a runaway
  • effort — low for a single lookup, high or above for multi-file analysis; omit to inherit
  • memory — user, project or local; only when cross-session state is genuinely needed
  • isolation: worktree — only when the agent modifies files and needs an isolated copy
  • skills — skill names preloaded at agent startup; unrelated to the source_keys metadata field
  • color — the UI tile colour (red, blue, green, yellow, purple, orange, pink, cyan)
  • background — true forces background execution
  • initialPrompt — auto-submitted as the first turn when the agent activates as the main session thread; set it only for a main-thread agent, never for a subagent

hooks, mcpServers and permissionMode are honoured at these two scopes and nowhere else — a plugin agent carrying them is ignored silently.

A subdirectory under agents/ does not affect the agent's name at these scopes; it does at plugin scope, which is one reason references/deployment-modes.md recommends keeping agents flat.

Copilot file

Two Copilot formats exist, with different paths and different field sets. Pick one:

CLI format — what the scaffold writes.

  • Path: .github/agents/<name>.agent.md (project) or ~/.copilot/agents/<name>.agent.md (user)
  • The .agent.md extension is mandatory: Copilot CLI does not pick up a plain .md file in agents/, and fails silently rather than reporting it
  • Fields: name (required, must equal the filename stem), description (required), tools (optional)
  • tools uses Copilot aliases, not Claude tool names: execute (shell), read, edit, search, agent, web; MCP tools as server-name/tool-name or server-name/*

Cloud/IDE format — for Copilot Chat in VS Code or on GitHub.com.

  • Path: .github/copilot/agents/<name>.md — a plain .md, in a different directory
  • Adds target (vscode, github-copilot, or omit for both), user-invocable, disable-model-invocation and mcp-servers (processed by the cloud runtime, ignored in VS Code). These four are inert in the CLI format — do not write them there
  • This is the only format that can express the invocation axis in frontmatter; see the Invocation axis section of references/contract.md

Both formats truncate a body past 30,000 characters silently.

Copilot has no permissionMode, maxTurns, isolation, memory, effort, hooks or mcpServers. Never let those cross over from the Claude Code file.

Before invoking factory-audit

Both files:

  • name present and kebab-case; description written to references/contract.md
  • System prompt body present, non-empty and equivalent across the pair
  • Body covers all four required elements: inputs expected, process steps, output format, error handling — what the agent does on malformed, missing or contradictory input
  • No FILL IN: placeholder and no <!-- ... --> template comment left

Copilot file only:

  • Extension is .agent.md (CLI format), and name matches the filename stem
  • No Claude Code-only field present
  • Body under 30,000 characters

Then return to the flow reference you came from.