cyber-aced 0.3.0 → 0.4.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.
@@ -0,0 +1,260 @@
1
+ # Skill Design
2
+
3
+ Rules for authoring SKILL.md files that agents load on demand. Apply when creating, generalizing, or auditing a skill — before adding scripts or CLI instructions.
4
+
5
+ ## Structure
6
+
7
+ SKILL.md must be agent-first: dense normative rules the agent executes without opening linked files first.
8
+
9
+ - Do not include `## Why`, `## Rationale`, `## Background`, or `## Context` sections.
10
+ - Do not include causal explanation ("because…") or rationale prose in the body.
11
+ - One-line scope ("Apply when…") is allowed at the top.
12
+ - Put optional depth in `## References` at the end — `governance show` commands, external HTTPS URLs, sibling files in the same skill folder only.
13
+
14
+ **SKILL.md structure:**
15
+
16
+ ```markdown
17
+ # Skill Title
18
+ ## When to use / Prerequisites # short scope
19
+ ## Workflow # numbered steps, decision logic
20
+ ## Anti-patterns # optional
21
+ ## References # on-demand standards, external URLs, reference.md — no repo file paths
22
+ ```
23
+
24
+ Do not embed References content or links to sibling files mid-workflow.
25
+
26
+ ## Core principles
27
+
28
+ ### Decisions over documentation
29
+
30
+ Encode what to decide and how. Do not repeat generic best practices, API docs, or facts the model can derive without the skill.
31
+
32
+ ### Narrow and composable
33
+
34
+ One workflow per skill. A skill is selected one of three ways — matched against a situation, named by a caller, or fired by an event. Declare that choice in the `description`; never infer it from a visibility flag.
35
+
36
+ - **Name-only skills** (loaded by name from another skill, never matched to a user situation) set the `description` to exactly `"By name only"` — nothing else. The minimal description is the mechanism, not a label for it: the `description` is the only surface the model matches against, so every word added to it is another handle for a spurious match. Identity — what the skill is, who calls it, what it returns — belongs in the body and README, which the caller reads after loading it by name.
37
+ - **`user-invocable` is a visibility flag only.** It controls whether a skill appears in the user's command list. It never determines how a skill is selected, and must not be read as one: a skill may legitimately be `user-invocable: false` and still situationally triggered.
38
+ - Whether a skill can run standalone is documentation for its README, not a declared kind. A self-contained engine and a fragment of a larger capability are selected the same way and carry the same minimal description.
39
+ - Neither type should be loaded as ambient context.
40
+
41
+ ### No baked-in opinions
42
+
43
+ Detect the user's setup (package manager, monorepo shape, editor, OS paths) at runtime rather than assuming a specific stack. If the skill only applies to one stack, say so explicitly in the description.
44
+
45
+ ## Placement and scope
46
+
47
+ Where a skill file lives depends on who consumes it. Whole-repo layout (manifests, CI, archetypes) is covered in **skill-repo-structure** — load from References when scaffolding a library repo.
48
+
49
+ ### Skill placement
50
+
51
+ Use **placement** for where a skill lives; do not call this axis "type".
52
+
53
+ | Placement | Location | Use case |
54
+ | --- | --- | --- |
55
+ | **User** | `~/.agents/skills/<name>/` | Personal skills across all projects |
56
+ | **Project private** | `.agents/skills/<name>/` | Contributor tooling scoped to one repo |
57
+ | **Project public** | `skills/<name>/` | Shipped with a package or installed via `npx skills add` |
58
+
59
+ ### Skill patterns
60
+
61
+ Use **pattern** for the workflow shape; do not overload "kind" or "type" here.
62
+
63
+ | Pattern | Use case |
64
+ | --- | --- |
65
+ | **Process** | Multi-step workflows where sequence and decision logic matter |
66
+ | **Tool-based** | Workflows centered on consistent use of tools, systems, or connectors |
67
+ | **Standard** | Workflows that enforce tone, structure, formatting, or quality bars |
68
+ | **Persona** | Loads an expert stance, decision style, and working behavior into the session |
69
+
70
+ Repo-internal skills must include `metadata: internal: true` in frontmatter.
71
+ Persona skills must include `metadata.persona: "true"`.
72
+
73
+ ### Patch and local rules
74
+
75
+ - Upstream contributions from a local install map to `skills/<name>/…` in the source repo — never `.agents/skills/` upstream.
76
+ - **`SKILL.local.md`** extends a skill locally; never commit or push it upstream.
77
+ - Include every changed file under the skill folder when patching (not only `SKILL.md`).
78
+
79
+ ## Progressive disclosure
80
+
81
+ Keep SKILL.md concise — essential workflow and decision logic only.
82
+
83
+ - Put detailed reference material in sibling files (`reference.md`, `examples.md`) in the same skill folder.
84
+ - Link sibling files **only from References**; agent reads them when stuck, not by default.
85
+ - Link references **one level deep** from SKILL.md; avoid chains of nested files.
86
+ - Aim to keep SKILL.md under ~500 lines; split when a skill grows beyond that.
87
+
88
+ ## Extract deterministic logic
89
+
90
+ When a step produces the same output given the same input and needs no judgment, move it out of prose:
91
+
92
+ - Prefer an **existing project CLI** or a small **script** in the skill's `scripts/` directory.
93
+ - The skill retains **when** to invoke the tool; the tool retains **how**.
94
+ - Candidates: text manipulation, file I/O, structured data transforms, validation with fixed rules.
95
+
96
+ Do not re-derive deterministic steps in natural language each run.
97
+
98
+ ### Keep scripts inside the skill folder
99
+
100
+ The skill folder is the unit an installer copies (`skills add --skill <name>` takes that folder and nothing else).
101
+
102
+ - Put every script the skill runs in its own `scripts/`, and invoke it as `node <skill-dir>/scripts/<file>`.
103
+ - Never reference a path outside the skill folder: a sibling skill, a plugin's `bin/`, or the package root. Standalone copies and symlinked installs break such paths without an error.
104
+ - Use Node built-ins only, or bundle dependencies into the script. The script itself never depends on `npx`, `tsx`, or a global install; the pinned `npx` fallback below is the skill's, not the script's. For a released CLI the skill depends on but does not ship, follow **cli-resolution**.
105
+
106
+ ### Share logic by bundling it into each skill
107
+
108
+ When several skills, or a skill and a package CLI, need the same logic:
109
+
110
+ - Author it once in the package source, typed and tested there.
111
+ - Have the build emit a self-contained bundle into the `scripts/` of each skill that uses it. Start the bundle with a header naming its source file and saying it is generated, then the usage comment an agent reads when stuck. Minify the rest.
112
+ - Do not commit the bundles. Gitignore them, build them in `prepack`, and ship them through the npm package's `files`.
113
+ - Add a CI check that packs the package, unpacks it with no `node_modules`, and runs each bundle from the unpacked skill folder.
114
+ - If the build is cached (for example by Turborepo), list each bundle as a build output by exact path. A glob such as `skills/**` restores cached copies over hand-written scripts.
115
+ - Keep the tests with the source, outside the skill folder, so installs do not copy them.
116
+ - Expose the same commands in the package CLI, and give each such skill a pinned fallback: when `scripts/<file>` is missing or cannot run, call `npx -y <package>@^<version> <command>` with the same arguments. A skill installed from git has no built `scripts/`, and this is how it still works.
117
+ - Distribute the plugin from npm where the harness supports an npm plugin source. Git-sourced installs, including organization-distributed marketplaces that exclude npm sources, use the fallback.
118
+
119
+ When a skill includes `scripts/` or documents CLI commands agents run, load **agent-tool-output** from References for stdout, JSON, non-interactive, and stderr rules.
120
+
121
+ ## Description and structure
122
+
123
+ ### Frontmatter
124
+
125
+ - `name` must match the parent directory name exactly.
126
+ - `description` of a situationally triggered skill states what the skill does, then when it applies — the situations, requests, and implicit phrasings that should select it. Lead with the capability, in third person.
127
+ - Do not open the `description` with a fixed lead-in such as `"Use this skill when"` or `"When to use"`. A trigger clause after the capability (`"… Use when …"`) is fine; no particular phrase is required.
128
+ - A **name-only** skill's `description` is exactly `"By name only"` and carries no capability or trigger text at all.
129
+ - Keep `description` ≤1024 characters — the agentskills.io hard limit. Put the capability and the main triggers first; listings may truncate the tail.
130
+ - `compatibility` — optional; declare environment constraints (required tools, network access, OS, runtime version). Include only when the skill has requirements the agent cannot assume.
131
+
132
+ #### Runtime fields
133
+
134
+ Support varies by platform; the notes below are Claude Code's documented behavior. Set none of these unless the skill needs them — each one is a deviation the reader must account for.
135
+
136
+ | Field | Effect |
137
+ | --- | --- |
138
+ | `allowed-tools` | **Pre-approves** the listed tools for the invoking turn. It does not restrict the tool pool — every other tool stays callable. The grant clears on the user's next message. |
139
+ | `disallowed-tools` | Removes tools from the pool while the skill is active. This is the field that restricts. Also clears on the next message. |
140
+ | `model` | Model to use while the skill is active. Applies for the rest of the current turn only; the session model resumes on the next prompt. |
141
+ | `effort` | Effort level while the skill is active: `low`, `medium`, `high`, `xhigh`, `max`. Same turn-scoped lifetime as `model`. |
142
+ | `context: fork` | Runs the skill in a subagent, with the skill body as the task prompt. Pair with `agent:` to choose the subagent type. Only meaningful for a skill that states a task — a reference or stance skill forked this way receives no actionable prompt and returns nothing useful. |
143
+ | `paths` | Glob patterns limiting automatic activation to matching files. |
144
+
145
+ A skill cannot express a tool **allowlist** — `allowed-tools` grants and `disallowed-tools` denies, but neither says "only these". A hard allowlist, `permissionMode`, `maxTurns`, persistent `memory`, `mcpServers`, and worktree `isolation` remain agent-definition fields. Reach for an agent definition when one of those is the actual requirement, not for `model` or `effort` alone.
146
+
147
+ ### skill.json — install-time metadata
148
+
149
+ `skill.json` is an optional sidecar file in the same directory as `SKILL.md`. It holds install-time metadata that the `skills add` / `skills update` installer reads. It is **not** loaded into agent context, so it costs zero tokens at runtime.
150
+
151
+ Do not put install-time metadata in SKILL.md frontmatter — agents load it unnecessarily.
152
+
153
+ **Supported fields:**
154
+
155
+ ```json
156
+ {
157
+ "distribution": {
158
+ "install_via": "package_manager",
159
+ "package": {
160
+ "name": "cyber-asana",
161
+ "bin": "cyber-asana"
162
+ }
163
+ }
164
+ }
165
+ ```
166
+
167
+ **`distribution`** — declare the required install channel.
168
+
169
+ | Field | Required | Description |
170
+ | --- | --- | --- |
171
+ | `install_via` | yes | `"package_manager"` — must be installed via npm, not source control |
172
+ | `package.name` | when `install_via: package_manager` | npm package that ships the skill binary |
173
+ | `package.bin` | no | binary name; defaults to `package.name` |
174
+
175
+ Use `install_via: package_manager` when the skill depends on a released binary from the same repo. Source-based `skills add org/repo` will skip such skills and print an `npm install` hint.
176
+
177
+ ### Activation
178
+
179
+ The `activation` field belongs in **SKILL.md frontmatter** as a **top-level field** (not nested under `metadata:`). Agents need this information to know whether a hook is involved; not all agents support hooks, so it must travel with the skill file.
180
+
181
+ ```yaml
182
+ ---
183
+ name: my-skill
184
+ activation: per-situation
185
+ description: "<what it does>. Use when <situations>."
186
+ ---
187
+ ```
188
+
189
+ | `activation` | Claude Code | Cursor | Codex |
190
+ | --- | --- | --- | --- |
191
+ | `per-situation` | — | — | — |
192
+ | `session-start` | `SessionStart` | `sessionStart` | `SessionStart` |
193
+ | `session-end` | `SessionEnd` | `sessionEnd` | — |
194
+ | `pre-tool-use` | `PreToolUse` | `preToolUse` | — |
195
+ | `post-tool-use` | `PostToolUse` | `postToolUse` | `PostToolUse` |
196
+ | `post-tool-use-failure` | — | `postToolUseFailure` | — |
197
+ | `before-submit-prompt` | `UserPromptSubmit` | `beforeSubmitPrompt` | — |
198
+ | `before-shell-execution` | — | `beforeShellExecution` | — |
199
+ | `after-shell-execution` | — | `afterShellExecution` | — |
200
+ | `before-mcp-execution` | — | `beforeMCPExecution` | — |
201
+ | `after-mcp-execution` | — | `afterMCPExecution` | — |
202
+ | `before-read-file` | — | `beforeReadFile` | — |
203
+ | `after-file-edit` | — | `afterFileEdit` | — |
204
+ | `subagent-start` | — | `subagentStart` | — |
205
+ | `subagent-stop` | — | `subagentStop` | `SubagentStop` |
206
+ | `pre-compact` | `PreCompact` | `preCompact` | — |
207
+ | `stop` | `Stop` | `stop` | `Stop` |
208
+ | `after-agent-response` | — | `afterAgentResponse` | — |
209
+ | `after-agent-thought` | — | `afterAgentThought` | — |
210
+ | `before-tab-file-read` | — | `beforeTabFileRead` | — |
211
+ | `after-tab-file-edit` | — | `afterTabFileEdit` | — |
212
+
213
+ — = no documented equivalent on that host.
214
+
215
+ **Default:** omit or set `per-situation` — no hook; load via `description` or explicit invoke.
216
+
217
+ **Hook-backed skills:** set `activation` to the normalized event, then register with `hook register --event …` (cyberplace CLI maps `session-start` → `SessionStart` / `sessionStart`, `post-tool-use` → `PostToolUse` / `postToolUse`). CLI today supports `SessionStart` and `PostToolUse` only; other values are portable declarations until hosts implement them.
218
+
219
+ **Defaults by pattern:** persona → `per-situation` (opt-in via `description`); discipline / always-on injection → `session-start`; process / tool-based / standard → `per-situation` or omit.
220
+
221
+ Deprecated: `metadata.activation` in SKILL.md frontmatter. Use top-level `activation:` instead.
222
+
223
+ ### Body
224
+
225
+ - Include actionable steps, numbered instructions, or decision logic — not just a restatement of the description.
226
+ - Do not instruct generic behavior the model already follows ("write clean code", "be helpful").
227
+
228
+ ## Anti-patterns
229
+
230
+ - Rationale or "because…" prose in the body
231
+ - `## Why`, `## Rationale`, `## Background`, or `## Context` sections
232
+ - Links to other repository files mid-workflow
233
+ - Mid-body links to sibling skill files (use References at end)
234
+
235
+ ## Governance lookup order
236
+
237
+ A skill that reads a governance at run time stops at the first hit:
238
+
239
+ 1. `.agents/governances/<name>.md` — project override.
240
+ 2. Only when an installed copy exists: `upx --local-only buddy-agent-harness@^<major> governance show <name> --overrides-only` when `upx` is on PATH; else `buddy-agent-harness governance show <name> --overrides-only` when `command -v buddy-agent-harness` finds it. Exit 127 from `upx`, or any non-zero exit, means no override. Never through `npx`.
241
+ 3. `references/governances/<name>.md` inside the skill — the default copy, committed to git.
242
+
243
+ Copies live at `<skill>/references/governances/<name>.md`, and the files in that folder declare which governances the skill uses. A skill copies every governance a copied governance references, and lists every copy in its SKILL.md References, so each stays one level deep. A pointer inside a copy (`governance show <other>`) is read as "load `references/governances/<other>.md`".
244
+
245
+ `buddy-agent-harness governance` and the copy step in `universal-plugin plugin build` are planned (tracked in https://github.com/repobuddy/buddy-agent-harness/issues/122). Until they ship, a skill uses step 3 only.
246
+
247
+ ## References
248
+
249
+ Related governances (load on demand; read stdout as authoritative):
250
+
251
+ ```bash
252
+ npx cyberplace@<version> governance show skill-repo-structure
253
+ npx cyberplace@<version> governance show agent-tool-output
254
+ npx cyberplace@<version> governance show universal-plugin
255
+ ```
256
+
257
+ Runtime field reference (re-verify before relying on a version-gated field):
258
+
259
+ - <https://code.claude.com/docs/en/skills> — skill frontmatter, invocation control, `context: fork`
260
+ - <https://code.claude.com/docs/en/sub-agents> — agent-definition frontmatter, `skills:` preloading
@@ -172,6 +172,31 @@ export function recognizedScanRoots(cwd: string, dirGlobs: string[] = []): Set<s
172
172
  return roots
173
173
  }
174
174
 
175
+ // Every non-hidden file under a skill's scripts/, as a /-separated path relative to it. Recurses
176
+ // into subfolders (e.g. scripts/vendor/) so the content checks see nested scripts too; does not
177
+ // follow a symlinked folder, so a link cycle cannot loop the walk.
178
+ export function listScriptFiles(scriptsDir: string, rel = ''): string[] {
179
+ const files: string[] = []
180
+ for (const entry of fs.readdirSync(path.join(scriptsDir, rel), { withFileTypes: true })) {
181
+ if (entry.name.startsWith('.')) continue
182
+ const relPath = rel ? `${rel}/${entry.name}` : entry.name
183
+ if (entry.isDirectory()) {
184
+ files.push(...listScriptFiles(scriptsDir, relPath))
185
+ } else if (entry.isFile() || (entry.isSymbolicLink() && isFileTarget(path.join(scriptsDir, relPath)))) {
186
+ files.push(relPath)
187
+ }
188
+ }
189
+ return files.sort()
190
+ }
191
+
192
+ function isFileTarget(filePath: string): boolean {
193
+ try {
194
+ return fs.statSync(filePath).isFile()
195
+ } catch {
196
+ return false
197
+ }
198
+ }
199
+
175
200
  export function findSkillFiles(dirs: string[], cwd: string): string[] {
176
201
  const seen = new Set<string>()
177
202
  const results: string[] = []
@@ -509,6 +534,9 @@ export function runChecks(filePath: string, scanRoots?: Set<string>): CheckResul
509
534
  const stripped = stripExamples(content)
510
535
  const invisibleInSkill = findInvisibleUnicode(content)
511
536
  const isPartialSkill = fmInternal
537
+ // ADR-0031: the exact description "By name only" is the by-name mechanism, independent of
538
+ // user-invocable (visibility only). A visible by-name skill must not be pushed to pad it (#81).
539
+ const isByNameDescription = fmDesc === 'By name only'
512
540
  const isPublicShippedSkill = parent === 'skills' && skillBaseParent !== '.agents' && !fmInternal
513
541
 
514
542
  // S1: the SKILL.md must sit in its own named subdirectory directly under a recognized scan root.
@@ -609,7 +637,7 @@ export function runChecks(filePath: string, scanRoots?: Set<string>): CheckResul
609
637
  }
610
638
 
611
639
  if (fmDesc) {
612
- if (!isPartialSkill) {
640
+ if (!isPartialSkill && !isByNameDescription) {
613
641
  const wordCount = fmDesc.split(/\s+/).filter(Boolean).length
614
642
  if (wordCount < 12) {
615
643
  warn(
@@ -712,7 +740,7 @@ export function runChecks(filePath: string, scanRoots?: Set<string>): CheckResul
712
740
  }
713
741
 
714
742
  if (hasScripts) {
715
- const scriptFiles = fs.readdirSync(scriptsDir).filter((f) => !f.startsWith('.'))
743
+ const scriptFiles = listScriptFiles(scriptsDir)
716
744
  const hasInteractive = scriptFiles.some((f) => {
717
745
  const src = fs.readFileSync(path.join(scriptsDir, f), 'utf8')
718
746
  return /readline|createInterface|\.question\(/.test(src)
@@ -784,7 +812,7 @@ export function runChecks(filePath: string, scanRoots?: Set<string>): CheckResul
784
812
  }
785
813
 
786
814
  if (hasScripts) {
787
- for (const f of fs.readdirSync(scriptsDir).filter((name) => !name.startsWith('.'))) {
815
+ for (const f of listScriptFiles(scriptsDir)) {
788
816
  const src = fs.readFileSync(path.join(scriptsDir, f), 'utf8')
789
817
  const invisibleInScript = findInvisibleUnicode(src)
790
818
  if (invisibleInScript) {
@@ -76,7 +76,7 @@ itself waiting on its own blind simulator — so it can report before its measur
76
76
  correct itself afterwards. Where an agent reports more than once, the **final** report for that agent
77
77
  id supersedes the earlier one entirely: never bank the first, never merge them. Do not compute
78
78
  results while any judge is still live; a run that ends with cases outstanding reports those cases as
79
- **unmeasured**, not as passes or failures. A judge that emits `BLOCKER: <reason>` in place of a score
79
+ **unmeasured**, not as passes or failures. A judge that emits `BLOCKER: <reason>` in place of a score <!-- field-mandate-ignore: BLOCKER is aced-case-judge's output, which this skill reads -->
80
80
  is likewise unmeasured — surface it rather than folding it into the pass rate.
81
81
 
82
82
  ## Compute results