@heihei0299/matt-skills 1.3.1 → 1.3.3
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/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
- package/.agents/skills/ask-matt/SKILL.md +37 -25
- package/.agents/skills/ci-guard/SKILL.md +104 -0
- package/.agents/skills/ci-guard/agents/openai.yaml +5 -0
- package/.agents/skills/code-review/SKILL.md +28 -35
- package/.agents/skills/codebase-design/DEEPENING.md +4 -4
- package/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +10 -10
- package/.agents/skills/codebase-design/SKILL.md +13 -13
- package/.agents/skills/diagnosing-bugs/SKILL.md +34 -30
- package/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +3 -0
- package/.agents/skills/domain-modeling/ADR-FORMAT.md +11 -11
- package/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +3 -3
- package/.agents/skills/domain-modeling/SKILL.md +10 -10
- package/.agents/skills/grill-me/SKILL.md +1 -1
- package/.agents/skills/grill-with-docs/SKILL.md +1 -1
- package/.agents/skills/grilling/SKILL.md +20 -4
- package/.agents/skills/grilling/agents/openai.yaml +1 -1
- package/.agents/skills/handoff/SKILL.md +1 -1
- package/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +19 -19
- package/.agents/skills/improve-codebase-architecture/SKILL.md +21 -21
- package/.agents/skills/instance-test/SKILL.md +36 -27
- package/.agents/skills/instance-test/agents/openai.yaml +1 -1
- package/.agents/skills/instance-test/references/instances.md +63 -36
- package/.agents/skills/prototype/LOGIC.md +30 -42
- package/.agents/skills/prototype/SKILL.md +7 -7
- package/.agents/skills/prototype/UI.md +23 -23
- package/.agents/skills/research/SKILL.md +1 -1
- package/.agents/skills/resolving-merge-conflicts/SKILL.md +1 -1
- package/.agents/skills/scaffold-functional-test/SKILL.md +77 -0
- package/.agents/skills/scaffold-functional-test/agents/openai.yaml +5 -0
- package/.agents/skills/setup-matt-pocock-skills/SKILL.md +30 -30
- package/.agents/skills/setup-matt-pocock-skills/domain.md +4 -4
- package/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +5 -5
- package/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +6 -6
- package/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +3 -3
- package/.agents/skills/tdd/SKILL.md +9 -7
- package/.agents/skills/teach/GLOSSARY-FORMAT.md +3 -3
- package/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +10 -10
- package/.agents/skills/teach/MISSION-FORMAT.md +4 -4
- package/.agents/skills/teach/RESOURCES-FORMAT.md +2 -2
- package/.agents/skills/teach/SKILL.md +4 -4
- package/.agents/skills/to-questionnaire/SKILL.md +54 -0
- package/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
- package/.agents/skills/to-spec/SKILL.md +4 -4
- package/.agents/skills/to-tickets/SKILL.md +16 -16
- package/.agents/skills/triage/AGENT-BRIEF.md +9 -9
- package/.agents/skills/triage/OUT-OF-SCOPE.md +15 -15
- package/.agents/skills/triage/SKILL.md +29 -29
- package/.agents/skills/wait-what/SKILL.md +7 -0
- package/.agents/skills/wait-what/agents/openai.yaml +5 -0
- package/.agents/skills/wayfinder/SKILL.md +37 -37
- package/.agents/skills/wizard/SKILL.md +44 -0
- package/.agents/skills/wizard/agents/openai.yaml +3 -0
- package/.agents/skills/wizard/template.sh +204 -0
- package/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/.agents/skills/writing-for-agents/SKILL.md +81 -0
- package/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
- package/README.md +9 -9
- package/bin/cli.js +1 -1
- package/config/proprietary.json +8 -1
- package/package.json +1 -1
- package/scripts/sync-upstream.js +1 -1
- package/template/.opencode/CONTEXT.md +2 -2
- package/template/.opencode/commands/{writing-great-skills.md → writing-for-agents.md} +1 -1
- package/template/.opencode/docs/agents/skill-design.md +3 -3
- package/template/.opencode/skills/ci-guard/SKILL.md +104 -0
- package/template/.opencode/skills/ci-guard/agents/openai.yaml +5 -0
- package/template/.opencode/skills/scaffold-functional-test/SKILL.md +77 -0
- package/template/.opencode/skills/scaffold-functional-test/agents/openai.yaml +5 -0
- package/template/.pi/CONTEXT.md +55 -0
- package/template/.pi/docs/agents/runtime-discipline.md +3 -2
- package/template/.pi/docs/agents/skill-design.md +10 -5
- package/template/.pi/skills/ci-guard/SKILL.md +104 -0
- package/template/.pi/skills/ci-guard/agents/openai.yaml +5 -0
- package/template/.pi/skills/scaffold-functional-test/SKILL.md +77 -0
- package/template/.pi/skills/scaffold-functional-test/agents/openai.yaml +5 -0
- package/template/AGENTS.md +3 -4
- package/.agents/skills/writing-great-skills/GLOSSARY.md +0 -201
- package/.agents/skills/writing-great-skills/SKILL.md +0 -83
- package/.agents/skills/writing-great-skills/agents/openai.yaml +0 -5
- package/template/.opencode/skills/instance-test/SKILL.md +0 -61
- package/template/.opencode/skills/instance-test/agents/openai.yaml +0 -5
- package/template/.opencode/skills/instance-test/references/instances.md +0 -48
- package/template/.pi/skills/instance-test/SKILL.md +0 -61
- package/template/.pi/skills/instance-test/agents/openai.yaml +0 -5
- package/template/.pi/skills/instance-test/references/instances.md +0 -48
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# A wizard walks a human through a manual procedure, step by step.
|
|
4
|
+
# Generated by the /wizard skill.
|
|
5
|
+
#
|
|
6
|
+
# Everything above the "STAGES" marker is the wizard library: do not hand-edit
|
|
7
|
+
# it. Author the per-step stages below the marker.
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
12
|
+
# Wizard library: delightful, consistent UX, identical across every wizard.
|
|
13
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
if [[ -t 1 ]] && command -v tput >/dev/null 2>&1 && [[ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]]; then
|
|
16
|
+
BOLD=$(tput bold); DIM=$(tput dim); RESET=$(tput sgr0)
|
|
17
|
+
BLUE=$(tput setaf 4); GREEN=$(tput setaf 2); YELLOW=$(tput setaf 3); RED=$(tput setaf 1)
|
|
18
|
+
else
|
|
19
|
+
BOLD=""; DIM=""; RESET=""; BLUE=""; GREEN=""; YELLOW=""; RED=""
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Author sets this at the top of the stages section.
|
|
23
|
+
TOTAL_STAGES=0
|
|
24
|
+
|
|
25
|
+
_STAGE_INDEX=0
|
|
26
|
+
ENV_FILE="${ENV_FILE:-.env}"
|
|
27
|
+
WRITTEN_ENV=() # KEYs written to ENV_FILE this run
|
|
28
|
+
WRITTEN_SECRET=() # secret NAMEs set this run
|
|
29
|
+
SKIPPED=() # things we couldn't do (e.g. gh missing)
|
|
30
|
+
|
|
31
|
+
# _clear wipes the terminal so only the current step is on screen. No-op when
|
|
32
|
+
# output isn't a terminal, so piped logs stay readable.
|
|
33
|
+
_clear() {
|
|
34
|
+
[[ -t 1 ]] || return 0
|
|
35
|
+
if command -v tput >/dev/null 2>&1; then tput clear; else printf '\033[2J\033[3J\033[H'; fi
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# banner "Title" shows the opening frame: what this wizard does.
|
|
39
|
+
banner() {
|
|
40
|
+
_clear
|
|
41
|
+
printf '\n%s%s %s%s\n' "$BOLD" "$BLUE" "$1" "$RESET"
|
|
42
|
+
printf '%s %s stages%s\n\n' "$DIM" "$TOTAL_STAGES" "$RESET"
|
|
43
|
+
printf '%s You drive the browser; this wizard tells you exactly what to do and\n' "$DIM"
|
|
44
|
+
printf ' captures the values you copy back. Stop any time with Ctrl-C and re-run\n'
|
|
45
|
+
printf ' later, since it remembers values already saved.%s\n' "$RESET"
|
|
46
|
+
pause "Ready to start?"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# stage "Name" clears the screen, then announces a stage and shows progress.
|
|
50
|
+
# Clearing keeps only the current step on screen.
|
|
51
|
+
stage() {
|
|
52
|
+
_clear
|
|
53
|
+
_STAGE_INDEX=$((_STAGE_INDEX + 1))
|
|
54
|
+
printf '\n%s%s▸ Stage %s/%s · %s%s\n' \
|
|
55
|
+
"$BOLD" "$BLUE" "$_STAGE_INDEX" "$TOTAL_STAGES" "$1" "$RESET"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# say "..." prints a plain instruction line.
|
|
59
|
+
say() { printf ' %s\n' "$1"; }
|
|
60
|
+
# step "..." is a numbered-feeling action the human takes in the browser.
|
|
61
|
+
step() { printf ' %s•%s %s\n' "$BLUE" "$RESET" "$1"; }
|
|
62
|
+
note() { printf ' %s%s%s\n' "$DIM" "$1" "$RESET"; }
|
|
63
|
+
warn() { printf ' %s⚠ %s%s\n' "$YELLOW" "$1" "$RESET"; }
|
|
64
|
+
|
|
65
|
+
# open_url URL opens it in the human's browser, cross-platform incl. WSL.
|
|
66
|
+
open_url() {
|
|
67
|
+
local url="$1"
|
|
68
|
+
printf ' %s↗ opening%s %s\n' "$GREEN" "$RESET" "$url"
|
|
69
|
+
{ if command -v wslview >/dev/null 2>&1; then wslview "$url"
|
|
70
|
+
elif command -v explorer.exe >/dev/null 2>&1; then explorer.exe "$url"
|
|
71
|
+
elif command -v xdg-open >/dev/null 2>&1; then xdg-open "$url"
|
|
72
|
+
elif command -v open >/dev/null 2>&1; then open "$url"
|
|
73
|
+
else warn "couldn't open a browser; visit it manually: $url"; fi
|
|
74
|
+
} >/dev/null 2>&1 || warn "couldn't open a browser, so visit it manually: $url"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# pause "msg" waits for the human to confirm they've done the manual part.
|
|
78
|
+
pause() {
|
|
79
|
+
printf ' %s%s%s ' "$DIM" "${1:-Press Enter to continue}" "$RESET"
|
|
80
|
+
read -r _ || true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# confirm "question" is a y/N gate; returns success on yes.
|
|
84
|
+
confirm() {
|
|
85
|
+
local reply=""
|
|
86
|
+
printf ' %s? %s [y/N] ' "$YELLOW" "$1"
|
|
87
|
+
read -r reply || true
|
|
88
|
+
[[ "$reply" =~ ^[Yy] ]]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# _existing KEY: current value of KEY in ENV_FILE, if any.
|
|
92
|
+
_existing() {
|
|
93
|
+
[[ -f "$ENV_FILE" ]] || return 1
|
|
94
|
+
local line; line=$(grep -E "^${1}=" "$ENV_FILE" | tail -n1) || return 1
|
|
95
|
+
printf '%s' "${line#*=}"
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# ask KEY "Prompt" reads a value into $KEY. Offers the existing .env value as
|
|
99
|
+
# a default on re-runs (Enter keeps it). Visible input (non-secret).
|
|
100
|
+
ask() {
|
|
101
|
+
local key="$1" prompt="$2" current input
|
|
102
|
+
current=$(_existing "$key" || true)
|
|
103
|
+
if [[ -n "$current" ]]; then
|
|
104
|
+
printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET"
|
|
105
|
+
else
|
|
106
|
+
printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET"
|
|
107
|
+
fi
|
|
108
|
+
read -r input || true
|
|
109
|
+
[[ -z "$input" && -n "$current" ]] && input="$current"
|
|
110
|
+
printf -v "$key" '%s' "$input"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# ask_secret KEY "Prompt" is like ask, but input is hidden.
|
|
114
|
+
ask_secret() {
|
|
115
|
+
local key="$1" prompt="$2" current input
|
|
116
|
+
current=$(_existing "$key" || true)
|
|
117
|
+
if [[ -n "$current" ]]; then
|
|
118
|
+
printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET"
|
|
119
|
+
else
|
|
120
|
+
printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET"
|
|
121
|
+
fi
|
|
122
|
+
read -rs input || true
|
|
123
|
+
printf '\n'
|
|
124
|
+
[[ -z "$input" && -n "$current" ]] && input="$current"
|
|
125
|
+
printf -v "$key" '%s' "$input"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
# write_env KEY VALUE upserts KEY=VALUE into ENV_FILE (creates it; replaces
|
|
129
|
+
# any existing line). Idempotent.
|
|
130
|
+
write_env() {
|
|
131
|
+
local key="$1" value="$2" tmp
|
|
132
|
+
touch "$ENV_FILE"
|
|
133
|
+
tmp=$(mktemp)
|
|
134
|
+
grep -vE "^${key}=" "$ENV_FILE" > "$tmp" || true
|
|
135
|
+
printf '%s=%s\n' "$key" "$value" >> "$tmp"
|
|
136
|
+
mv "$tmp" "$ENV_FILE"
|
|
137
|
+
WRITTEN_ENV+=("$key")
|
|
138
|
+
printf ' %s✓ wrote%s %s → %s\n' "$GREEN" "$RESET" "$key" "$ENV_FILE"
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# set_secret NAME VALUE sets a GitHub Actions repo secret via gh. Falls back
|
|
142
|
+
# to a warning (and records it) if gh is unavailable or unauthenticated.
|
|
143
|
+
set_secret() {
|
|
144
|
+
local name="$1" value="$2"
|
|
145
|
+
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
|
|
146
|
+
if printf '%s' "$value" | gh secret set "$name" >/dev/null 2>&1; then
|
|
147
|
+
WRITTEN_SECRET+=("$name")
|
|
148
|
+
printf ' %s✓ set%s GitHub secret %s\n' "$GREEN" "$RESET" "$name"
|
|
149
|
+
return
|
|
150
|
+
fi
|
|
151
|
+
fi
|
|
152
|
+
SKIPPED+=("GitHub secret $name (set it manually: gh secret set $name)")
|
|
153
|
+
warn "skipped GitHub secret $name: gh not ready; set it later"
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# set_var NAME VALUE sets a GitHub Actions repo variable (non-secret).
|
|
157
|
+
set_var() {
|
|
158
|
+
local name="$1" value="$2"
|
|
159
|
+
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
|
|
160
|
+
if gh variable set "$name" --body "$value" >/dev/null 2>&1; then
|
|
161
|
+
printf ' %s✓ set%s GitHub variable %s\n' "$GREEN" "$RESET" "$name"
|
|
162
|
+
return
|
|
163
|
+
fi
|
|
164
|
+
fi
|
|
165
|
+
SKIPPED+=("GitHub variable $name")
|
|
166
|
+
warn "skipped GitHub variable $name, gh not ready; set it later"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
# finish clears, then shows a closing summary of everything configured.
|
|
170
|
+
finish() {
|
|
171
|
+
_clear
|
|
172
|
+
printf '\n%s%s ✓ Setup complete%s\n' "$BOLD" "$GREEN" "$RESET"
|
|
173
|
+
(( ${#WRITTEN_ENV[@]} )) && note "wrote ${#WRITTEN_ENV[@]} value(s) to $ENV_FILE: ${WRITTEN_ENV[*]}"
|
|
174
|
+
(( ${#WRITTEN_SECRET[@]} )) && note "set ${#WRITTEN_SECRET[@]} GitHub secret(s): ${WRITTEN_SECRET[*]}"
|
|
175
|
+
if (( ${#SKIPPED[@]} )); then
|
|
176
|
+
printf '\n'; warn "still to do by hand:"
|
|
177
|
+
for s in "${SKIPPED[@]}"; do note " - $s"; done
|
|
178
|
+
fi
|
|
179
|
+
printf '\n'
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
183
|
+
# STAGES: author this section. One stage() per step the human takes.
|
|
184
|
+
# Replace the example below. Set TOTAL_STAGES to match the stages you write.
|
|
185
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
186
|
+
|
|
187
|
+
TOTAL_STAGES=1
|
|
188
|
+
|
|
189
|
+
banner "Stripe setup"
|
|
190
|
+
|
|
191
|
+
# ── Example stage: replace with your real steps ───────────────────────────
|
|
192
|
+
stage "Stripe: API keys"
|
|
193
|
+
say "We'll grab your Stripe test keys and store them for local dev + CI."
|
|
194
|
+
open_url "https://dashboard.stripe.com/test/apikeys"
|
|
195
|
+
step "On the API keys page, copy the Publishable key (starts pk_test_)."
|
|
196
|
+
ask STRIPE_PUBLISHABLE_KEY "Paste the publishable key:"
|
|
197
|
+
step "Click 'Reveal test key' on the Secret key row, then copy it."
|
|
198
|
+
ask_secret STRIPE_SECRET_KEY "Paste the secret key:"
|
|
199
|
+
write_env STRIPE_PUBLISHABLE_KEY "$STRIPE_PUBLISHABLE_KEY"
|
|
200
|
+
write_env STRIPE_SECRET_KEY "$STRIPE_SECRET_KEY"
|
|
201
|
+
set_secret STRIPE_SECRET_KEY "$STRIPE_SECRET_KEY" # CI needs this one
|
|
202
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
203
|
+
|
|
204
|
+
finish
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Skill mechanics
|
|
2
|
+
|
|
3
|
+
The skill-specific branch of [`writing-for-agents`](SKILL.md): what changes when the document is a skill (frontmatter, the invocation choice, and router skills). Everything else about writing it is the universal reference in `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## Invocation
|
|
6
|
+
|
|
7
|
+
Two choices, trading the two loads:
|
|
8
|
+
|
|
9
|
+
- A **model-invoked** skill keeps a `description`, so the agent can fire it autonomously, and other skills can reach it. You can still type its name: model-invocation always _includes_ user reach; a description only ever adds agent discovery, never removes the human's. The description is the skill's top-level context pointer, forced to stay loaded at all times: permanent context load in exchange for discoverability. A model-invoked skill whose content is all reference is also one home for shared reference: another skill can invoke it, so reference needed by several skills lives in one place. Mechanics: omit `disable-model-invocation`, and write a model-facing description carrying the trigger branches (the pointer-writing rules in `SKILL.md` apply in full).
|
|
10
|
+
- A **user-invoked** skill strips the description from the agent's reach: only the human typing its name can invoke it, and no other skill can. Zero context load, but it spends cognitive load: you are the index that must remember it exists. Mechanics: set `disable-model-invocation: true`; the `description` becomes human-facing: a one-line summary, trigger lists stripped.
|
|
11
|
+
|
|
12
|
+
Pick model-invocation only when the agent must reach the skill on its own, or another skill must. If it only ever fires by hand, make it user-invoked and pay no context load.
|
|
13
|
+
|
|
14
|
+
Shared reference that two user-invoked skills both need can live in neither: with no descriptions, neither can fire the other. Push it to a plain file outside the skill system: external reference any skill can point at.
|
|
15
|
+
|
|
16
|
+
## Splitting by invocation
|
|
17
|
+
|
|
18
|
+
The invocation cut of splitting (the sequence cut lives in `SKILL.md`): split off a model-invoked skill when you have a distinct leading word that should trigger it on its own (a trigger word you actually use in your prompts), or another skill must reach it. You pay context load for the new always-loaded description, so that independent reach has to be worth it.
|
|
19
|
+
|
|
20
|
+
## Router skills
|
|
21
|
+
|
|
22
|
+
When user-invoked skills multiply past what you can remember, that piled-up cognitive load is cured by a **router skill**: one user-invoked skill that names the others and when to reach for each, so the human has one skill to remember instead of many. It can only hint, never fire them: user-invoked skills have no description, so nothing but the human can reach them.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: writing-for-agents
|
|
3
|
+
description: Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Reference for writing any document an agent consumes: a skill, an `AGENTS.md` / `CLAUDE.md`, a doc reached by a pointer. The packaging differs; the writing does not: the same levers make each one predictable, since the agent takes the same _process_ every run rather than producing the same output.
|
|
7
|
+
|
|
8
|
+
When the document you're writing is a skill, read [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md) for frontmatter, invocation choice, and router skills.
|
|
9
|
+
|
|
10
|
+
## Context pointers
|
|
11
|
+
|
|
12
|
+
A **context pointer** is a reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. A skill's description is one; a line in `AGENTS.md` naming a doc is the same object. The pointer's _wording_, not its target, decides when the agent reaches the material, and how reliably. A must-have target behind a weakly worded pointer is a variance bug: sharpen the wording first, and inline the material only if sharpening fails.
|
|
13
|
+
|
|
14
|
+
A pointer does two jobs: state what the material is, and list the **branches** that should trigger reaching it (a branch is a distinct case the document handles, so different runs take different paths through it). Every word of an always-loaded pointer costs on every turn, so it earns even harder pruning than the body:
|
|
15
|
+
|
|
16
|
+
- **Front-load the leading word**: the pointer is where it does its triggering work.
|
|
17
|
+
- **One trigger per branch.** Synonyms that rename a single branch are one branch written twice; collapse them and keep only genuinely distinct branches.
|
|
18
|
+
- **Cut identity the body already carries.**
|
|
19
|
+
|
|
20
|
+
## The two loads
|
|
21
|
+
|
|
22
|
+
Every document and pointer you add spends one of two budgets:
|
|
23
|
+
|
|
24
|
+
- **Context load** is the cost of always-loaded material on the agent's window: an `AGENTS.md` line, a skill description, anything sitting in context every turn, spending tokens and attention whether or not it fires.
|
|
25
|
+
- **Cognitive load** is the cost on the human: which documents exist and when to reach for each. The human is the index. Not a cost to minimise: it is the price of human agency; spend it where human judgement matters, remove it where it does not.
|
|
26
|
+
|
|
27
|
+
Material reached only through a pointer escapes context load at the price of the pointer's own line; material with no pointer at all rides entirely on cognitive load.
|
|
28
|
+
|
|
29
|
+
## Information hierarchy
|
|
30
|
+
|
|
31
|
+
A document is built from two content types: **steps** (the ordered actions the agent performs) and **reference** (definitions, rules, facts consulted on demand). The two mix freely: all steps (a recipe), all reference (a review's rules, this skill), or both. The core decision is where each piece sits on the **information hierarchy**, a ladder ranked by how immediately the agent needs the material:
|
|
32
|
+
|
|
33
|
+
1. **In-file step** is the primary tier: what the agent does, in order.
|
|
34
|
+
2. **In-file reference** is consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung), which is a fine arrangement, not a smell.
|
|
35
|
+
3. **Disclosed reference** is pushed out into a separate file, reached by a context pointer, loaded only when the pointer fires. Spans a sibling file in the same folder through fully external reference that lives anywhere and any document can point at.
|
|
36
|
+
|
|
37
|
+
Push too little down and the top bloats; push too much and you hide material the agent actually needs. That tension is the whole decision.
|
|
38
|
+
|
|
39
|
+
**Progressive disclosure** is the move down the ladder (out of the main file and behind a pointer) so the top stays legible. Not primarily a token optimisation: it is how the hierarchy is protected. Branching is the cleanest disclosure test: inline what every branch needs, and push behind a pointer what only some branches reach. When a document has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip: a variance lever, not just a legibility one.
|
|
40
|
+
|
|
41
|
+
**Co-location** is the within-file companion: where the ladder decides _how far down_ a piece sits, co-location decides _what sits beside it_ once there. Keep a concept's definition, rules, and caveats under one heading rather than scattered, so reading one part brings its neighbours with it. The test: the document should read like documentation written for the agent. Grouped material reads that way; scattered material does not. (Distinct from duplication: that repeats one meaning in two places; scattering fragments one meaning across many.)
|
|
42
|
+
|
|
43
|
+
**Sprawl** is the failure mode here: a document simply too long, even when every line is live and unique. Attention thins across the excess, and every extra line is one more to keep relevant. The cure is the ladder: disclose reference behind pointers, and split by branch or sequence so each path carries only what it needs.
|
|
44
|
+
|
|
45
|
+
## Steps and completion criteria
|
|
46
|
+
|
|
47
|
+
Every step ends on a **completion criterion**, the condition that tells the agent the work is done. Two properties make it a lever:
|
|
48
|
+
|
|
49
|
+
- **Clarity**: can the agent tell done from not-done? A vague bound ("understanding reached") invites **premature completion**: ending the step before it is genuinely done, attention slipping to _being done_. The visible steps still ahead (the **post-completion steps**) supply the pull; the criterion's clarity is the resistance. Defend in order: **sharpen the bound first** (local and cheap); only if it is irreducibly fuzzy _and_ you observe the rush, hide the later steps by splitting the sequence. Hiding only works across a real context boundary (a hand-off or a subagent dispatch; an inline call leaves the later steps in context and clears nothing).
|
|
50
|
+
- **Demand**: how much it requires. "Every modified model accounted for" forces thorough work where "produce a change list" does not. Demand drives **legwork** (the digging the agent does within the work, latent in the wording rather than written as its own step), and it is not step-bound: "every rule applied" binds a body of flat reference just as "every step done" binds a sequence, which is how an all-reference document still carries an exhaustiveness bar.
|
|
51
|
+
|
|
52
|
+
The strongest criteria are both checkable and exhaustive.
|
|
53
|
+
|
|
54
|
+
## When to split
|
|
55
|
+
|
|
56
|
+
Splitting one document into two spends one of the two loads, so split only when the cut earns it:
|
|
57
|
+
|
|
58
|
+
- **By sequence**: split a run of steps where the post-completion steps tempt the agent to rush the one in front of it. Keeping them out of view drives more legwork on the current task. Beware the reverse: merging sequences exposes each step's later steps to what follows, inviting premature completion.
|
|
59
|
+
- **By invocation**, skill-specific: see [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md).
|
|
60
|
+
|
|
61
|
+
## Leading words
|
|
62
|
+
|
|
63
|
+
A **leading word** is a compact concept already living in the model's pretraining that the agent thinks with while running the document (_lesson_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition and anchors a whole region of behaviour in the fewest tokens, by recruiting priors the model already holds. Coining your own works if you define it clearly, but a made-up word recruits no priors: you pay in definition tokens what a pretrained word gives free; reach for an existing word first.
|
|
64
|
+
|
|
65
|
+
It anchors twice. In the body, _execution_: the agent reaches for the same behaviour every time the word appears, and inside flat reference it focuses attention on a class of thing to look for. In a pointer, _invocation_: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the material and reaches it more reliably.
|
|
66
|
+
|
|
67
|
+
Hunt for opportunities to refactor with leading words. A triad spelled out at three sites, a pointer spending a sentence to gesture at one idea. Each is a passage begging to collapse into a single token:
|
|
68
|
+
|
|
69
|
+
- "fast, deterministic, low-overhead" → _tight_ (a _tight_ loop).
|
|
70
|
+
- "a loop you believe in" → _red_, turning a fuzzy gate into a binary observable state (the loop goes _red_ on the bug, or it doesn't).
|
|
71
|
+
|
|
72
|
+
You win twice: fewer tokens, and a sharper hook for the agent to hang its thinking on. Assume every document is carrying restatements that leading words retire. Go find them.
|
|
73
|
+
|
|
74
|
+
**Negation** is the failure mode beside this lever: steering by prohibition drags the forbidden behaviour into context and makes it _more_ available, not less. _Don't think of an elephant_, and the elephant is all there is; the negation is a weak modifier the strongly-activated concept overruns, so the ban half-reads as an instruction to do the thing. Prompt the **positive**: state the target behaviour ("write one-line comments") so the banned one is never spoken. A prohibition earns its place only as a hard guardrail you cannot phrase positively; even then, pair it with the positive target so attention lands on what to do.
|
|
75
|
+
|
|
76
|
+
## Pruning
|
|
77
|
+
|
|
78
|
+
- Keep each meaning in a **single source of truth**: one authoritative place, so changing the behaviour is a one-place edit. **Duplication** (the same meaning in more than one place) costs maintenance and tokens, and inflates a meaning's prominence on the ladder past its real rank. (The accidental inverse of a leading word, which repeats a token on purpose, never the meaning.)
|
|
79
|
+
- The **environment** is a source of truth too (`package.json` scripts, config files, the directory layout, `--help` output), and a document that restates it is a **cache**: a copy of a lookup, earning its load only when the lookup is expensive. Cache what the agent cannot find by looking: the unwritten convention, the reason behind a choice, the gotcha no config confesses. Leave the one-file, one-command lookups to the environment, where they cannot go stale.
|
|
80
|
+
- Check every line for **relevance**: does it still bear on what the document does? A line loses relevance by never bearing on the task (mere exposition, or a branch that should be disclosed) or by going stale as the behaviour or world it describes changes. Shorter documents are easier to keep relevant. Without a pruning discipline the default fate is **sediment**: stale layers that settle because adding feels safe and removing feels risky, until you must core down through them to find what is still live.
|
|
81
|
+
- Hunt **no-ops** sentence by sentence: an instruction the model already obeys by default pays load to say nothing. The test (does it change behaviour versus the default?) is model-relative, not reader-relative: two people disagreeing about a no-op disagree about the default, and settle it by running the document, not by debate. When a sentence fails, delete the whole sentence rather than trim words from it. The test also grades leading words: a word too weak to beat the default (_be thorough_ when the agent is already thorough-ish) is a no-op, and the fix is a stronger word (_relentless_), not a different technique.
|
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@ template/
|
|
|
9
9
|
├── AGENTS.md 项目级全局配置(行为路由 + 分文件指针)
|
|
10
10
|
├── .pi/ pi-agent 项目配置(pi 标准结构:`.pi/skills/` 直放独有技能,自动发现)
|
|
11
11
|
└── .opencode/ 分发内容(目标仓库的 opencode 项目配置)
|
|
12
|
-
├── skills/
|
|
12
|
+
├── skills/ 6 个独有技能(ci-guard、tdd-implement、grill-to-spec、diagnose-fix、commit-check、scaffold-functional-test)
|
|
13
13
|
├── agents/ issue-audit 子代理定义
|
|
14
|
-
├── commands/ issue-audit + 9 个显式触发技能命令(grill-to-spec/wayfinder/to-spec/to-tickets/triage/improve-codebase-architecture/teach/handoff/writing-
|
|
14
|
+
├── commands/ issue-audit + 9 个显式触发技能命令(grill-to-spec/wayfinder/to-spec/to-tickets/triage/improve-codebase-architecture/teach/handoff/writing-for-agents)
|
|
15
15
|
├── docs/agents/ 5 个分文件(运行时纪律 / 技能设计 / issue tracker / triage labels / domain)
|
|
16
16
|
├── CONTEXT.md 术语表
|
|
17
17
|
├── package.json 插件依赖清单
|
|
@@ -46,7 +46,7 @@ npx @heihei0299/matt-skills sync --apply --dest <path> --upstream <url> --ref <r
|
|
|
46
46
|
|
|
47
47
|
上游没有 `tdd-implement`、`grill-to-spec`、`diagnose-fix`、`commit-check`,复制天然不冲突。目标仓库会话即自动加载全部技能(上游在 `.agents/skills/`、独有在 `.opencode/skills/`;pi 侧独有在 `.pi/skills/`)与项目级全局配置(行为路由表、分文件约定);`issue-audit` 以子代理 + 命令形式分发(`.opencode/agents/`、`.opencode/commands/`);9 个显式触发技能注册为 opencode 命令(`.opencode/commands/`,`/命令名` 触发)。
|
|
48
48
|
|
|
49
|
-
**pi-agent 用户**:初始化命令完全相同。pi 从 `.pi/skills/` 自动发现独有技能(tdd-implement、grill-to-spec、diagnose-fix、commit-check),无需任何指向配置;首次在目标仓库交互启动时 pi 会询问项目信任,用 `/trust` 保存即可。
|
|
49
|
+
**pi-agent 用户**:初始化命令完全相同。pi 从 `.pi/skills/` 自动发现独有技能(ci-guard、tdd-implement、grill-to-spec、diagnose-fix、commit-check、scaffold-functional-test),无需任何指向配置;首次在目标仓库交互启动时 pi 会询问项目信任,用 `/trust` 保存即可。
|
|
50
50
|
|
|
51
51
|
**手动方式(备选)**:无 npx 环境时,将 `template/` 整个文件夹复制到目标仓库根目录,再拉取上游技能:
|
|
52
52
|
|
|
@@ -60,7 +60,7 @@ rm -rf /tmp/mattpocock-skills
|
|
|
60
60
|
|
|
61
61
|
上游没有 `tdd-implement`、`grill-to-spec`、`diagnose-fix`、`commit-check`,复制天然不冲突。目标仓库会话即自动加载全部技能(上游在 `.agents/skills/`、独有在 `.opencode/skills/`;pi 侧独有在 `.pi/skills/`)与项目级全局配置(行为路由表、分文件约定);`issue-audit` 以子代理 + 命令形式分发(`.opencode/agents/`、`.opencode/commands/`);9 个显式触发技能注册为 opencode 命令(`.opencode/commands/`,`/命令名` 触发)。
|
|
62
62
|
|
|
63
|
-
**pi-agent 用户**:初始化命令完全相同。pi 从 `.pi/skills/` 自动发现独有技能(tdd-implement、grill-to-spec、diagnose-fix、commit-check),无需任何指向配置;首次在目标仓库交互启动时 pi 会询问项目信任,用 `/trust` 保存即可。
|
|
63
|
+
**pi-agent 用户**:初始化命令完全相同。pi 从 `.pi/skills/` 自动发现独有技能(ci-guard、tdd-implement、grill-to-spec、diagnose-fix、commit-check、scaffold-functional-test),无需任何指向配置;首次在目标仓库交互启动时 pi 会询问项目信任,用 `/trust` 保存即可。
|
|
64
64
|
|
|
65
65
|
## 维护约定
|
|
66
66
|
|
|
@@ -68,8 +68,8 @@ rm -rf /tmp/mattpocock-skills
|
|
|
68
68
|
|
|
69
69
|
| 工作区 | 模板 |
|
|
70
70
|
|--------|------|
|
|
71
|
-
| `.agents/skills/{tdd-implement,grill-to-spec,diagnose-fix,commit-check}/` | `template/.opencode/skills/{tdd-implement,grill-to-spec,diagnose-fix,commit-check}/` |
|
|
72
|
-
| `.agents/skills/{tdd-implement,grill-to-spec,diagnose-fix,commit-check}/` | `template/.pi/skills/{tdd-implement,grill-to-spec,diagnose-fix,commit-check}/` |
|
|
71
|
+
| `.agents/skills/{ci-guard,tdd-implement,grill-to-spec,diagnose-fix,commit-check,scaffold-functional-test}/` | `template/.opencode/skills/{ci-guard,tdd-implement,grill-to-spec,diagnose-fix,commit-check,scaffold-functional-test}/` |
|
|
72
|
+
| `.agents/skills/{ci-guard,tdd-implement,grill-to-spec,diagnose-fix,commit-check,scaffold-functional-test}/` | `template/.pi/skills/{ci-guard,tdd-implement,grill-to-spec,diagnose-fix,commit-check,scaffold-functional-test}/` |
|
|
73
73
|
| `.opencode/agents/issue-audit.md`、`commands/*.md`(issue-audit + 9 个显式技能命令)、`.gitignore`、`package.json`、`package-lock.json` | `template/.opencode/` 同名 |
|
|
74
74
|
| `.pi/prompts/issue-audit.md`(pi 命令:opencode 版适配,去 subagent frontmatter) | `template/.pi/prompts/issue-audit.md` |
|
|
75
75
|
| `AGENTS.md` | `template/AGENTS.md`(引用映射为 `.opencode/` 路径) |
|
|
@@ -79,7 +79,7 @@ rm -rf /tmp/mattpocock-skills
|
|
|
79
79
|
独有技能需同步**双份**:`.opencode/skills/`(opencode 分发)与 `.pi/skills/`(pi 标准分发)。
|
|
80
80
|
`test/template-sync.test.js` 守护同步(含路径映射),漏同步测试即红。
|
|
81
81
|
|
|
82
|
-
新增技能前先查上游 `mattpocock/skills` 是否已存在;仅上游没有的技能才作为独有技能落在本仓库(当前独有:tdd-implement、grill-to-spec、diagnose-fix、commit-check),上游技能一律不进 `template/`。
|
|
82
|
+
新增技能前先查上游 `mattpocock/skills` 是否已存在;仅上游没有的技能才作为独有技能落在本仓库(当前独有:ci-guard、tdd-implement、grill-to-spec、diagnose-fix、commit-check、scaffold-functional-test),上游技能一律不进 `template/`。
|
|
83
83
|
|
|
84
84
|
## harness 支持
|
|
85
85
|
|
|
@@ -156,7 +156,7 @@ node scripts/sync-upstream.js --apply --dry-run
|
|
|
156
156
|
上游重命名映射:`RENAMES = { "writing-great-skills": "writing-for-agents" }`,Actions/CLI 均会删除旧目录并复制新目录。
|
|
157
157
|
## 发布
|
|
158
158
|
|
|
159
|
-
推送 `v*` 标签自动发布到 npm(GitHub Actions,见 `.github/workflows/
|
|
159
|
+
推送 `v*` 标签自动发布到 npm(GitHub Actions,见 `.github/workflows/ci.yml`):
|
|
160
160
|
|
|
161
161
|
```sh
|
|
162
162
|
# 1. 确保 main 分支为最新且测试全绿
|
|
@@ -189,5 +189,5 @@ npm run build:template # 从单源生成 template/.opencode/.pi(con
|
|
|
189
189
|
|
|
190
190
|
交互模式依赖 `prompts`(见 `package.json`);测试见 `test/cli.test.js`、`test/cli-init.test.js`、`test/template-sync.test.js`。
|
|
191
191
|
|
|
192
|
-
用户手动触发的功能测试:`/instance-test
|
|
192
|
+
用户手动触发的功能测试:`/instance-test`(matt-skills 专属示范,见 `.agents/skills/instance-test/SKILL.md`)——验证 sync 合并 update 后的行为,`references/instances.md` 由 `scaffold-functional-test` 从 spec 生成;通用模板已废弃。新增生成器 `/scaffold-functional-test`(见 `.agents/skills/scaffold-functional-test/SKILL.md`)——读 spec 生成定制化功能测试 skill。
|
|
193
193
|
|
package/bin/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import prompts from 'prompts';
|
|
|
7
7
|
|
|
8
8
|
const SKILLS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '.agents', 'skills');
|
|
9
9
|
const TEMPLATE_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'template');
|
|
10
|
-
const PROPRIETARY_SKILLS = new Set(['tdd-implement', 'grill-to-spec', 'diagnose-fix', 'commit-check', '
|
|
10
|
+
const PROPRIETARY_SKILLS = new Set(['ci-guard', 'tdd-implement', 'grill-to-spec', 'diagnose-fix', 'commit-check', 'scaffold-functional-test']);
|
|
11
11
|
process.stdout.on('error', (err) => {
|
|
12
12
|
if (err.code === 'EPIPE') process.exit(0);
|
|
13
13
|
throw err;
|
package/config/proprietary.json
CHANGED
package/package.json
CHANGED
package/scripts/sync-upstream.js
CHANGED
|
@@ -21,7 +21,7 @@ async function loadProprietary() {
|
|
|
21
21
|
const raw = await readFile(PROPRIETARY_PATH, 'utf8');
|
|
22
22
|
return new Set(JSON.parse(raw));
|
|
23
23
|
} catch {
|
|
24
|
-
return new Set(['tdd-implement', 'grill-to-spec', 'diagnose-fix', 'commit-check', '
|
|
24
|
+
return new Set(['ci-guard', 'tdd-implement', 'grill-to-spec', 'diagnose-fix', 'commit-check', 'scaffold-functional-test']);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -13,11 +13,11 @@ mattpocock/skills — the source of the 22 skill bodies (skills/engineering, 17
|
|
|
13
13
|
_Avoid_: source repo, skill origin
|
|
14
14
|
|
|
15
15
|
**Proprietary Skill** (独有技能):
|
|
16
|
-
A skill that does not exist upstream and lives only in this repo (currently tdd-implement, grill-to-spec, diagnose-fix and
|
|
16
|
+
A skill that does not exist upstream and lives only in this repo (currently ci-guard, tdd-implement, grill-to-spec, diagnose-fix, commit-check and scaffold-functional-test). Before adding a new skill, check the Upstream Repository first; only skills absent there qualify as proprietary. The issue-audit subagent is NOT a skill: it ships as a subagent + command under `.opencode/` and is distributed through the Template Snapshot without a skill directory.
|
|
17
17
|
_Avoid_: private skill, local skill
|
|
18
18
|
|
|
19
19
|
**Workspace** (工作区):
|
|
20
|
-
The root-level working copies of the template content — `.agents/skills/` (proprietary skill sources), `.opencode/` (issue-audit agent, explicit-skill commands, plugin manifests), `.pi/` (pi-agent project config: `.pi/skills/` + `.pi/prompts/` issue-audit command), `AGENTS.md`, `CONTEXT.md`, `docs/`. Where this repo's own sessions load, modify, and test the content. The template paths mirror them with a path mapping: `.agents/skills/{tdd-implement,grill-to-spec,diagnose-fix,commit-check}` → `template/.opencode/skills/` and `template/.pi/skills/` (dual mirror), `.opencode/commands/*.md` → `template/.opencode/commands/`, `.pi/prompts/issue-audit.md` → `template/.pi/prompts/issue-audit.md`, root-level `CONTEXT.md` and `docs/agents/` → `template/.opencode/`.
|
|
20
|
+
The root-level working copies of the template content — `.agents/skills/` (proprietary skill sources), `.opencode/` (issue-audit agent, explicit-skill commands, plugin manifests), `.pi/` (pi-agent project config: `.pi/skills/` + `.pi/prompts/` issue-audit command), `AGENTS.md`, `CONTEXT.md`, `docs/`. Where this repo's own sessions load, modify, and test the content. The template paths mirror them with a path mapping: `.agents/skills/{ci-guard,tdd-implement,grill-to-spec,diagnose-fix,commit-check,scaffold-functional-test}` → `template/.opencode/skills/` and `template/.pi/skills/` (dual mirror), `.opencode/commands/*.md` → `template/.opencode/commands/`, `.pi/prompts/issue-audit.md` → `template/.pi/prompts/issue-audit.md`, root-level `CONTEXT.md` and `docs/agents/` → `template/.opencode/`.
|
|
21
21
|
_Avoid_: working copy, source repo
|
|
22
22
|
|
|
23
23
|
**Template Snapshot** (模板快照):
|
|
@@ -7,11 +7,11 @@ This spec exists because of a real incident: a long-horizon skill run on a flash
|
|
|
7
7
|
|
|
8
8
|
Every **Long-Horizon Skill** must carry a positive **Turn Continuity** rule of its own: the consecutive actions of a stage (red → green → typecheck → next seam) are executed serially **within one turn**, until the stage's exit condition is met. Do not end the turn at "announce the next step" points, and do not wait for the user to say "continue".
|
|
9
9
|
|
|
10
|
-
- State it **positively** (per the negation principle in `writing-
|
|
10
|
+
- State it **positively** (per the negation principle in `writing-for-agents`): describe the target behaviour, never the banned one.
|
|
11
11
|
- It must be **self-contained** — the skill cannot rely on the harness `/goal` line, because no `/goal` exists when the user does not activate one.
|
|
12
12
|
- Every stage ends on a checkable exit condition; reaching it is the only thing that ends the turn.
|
|
13
13
|
- A sub-step going green (e.g. one seam) is not a stage exit — a stage ends only when all of its seams are complete. Progress output does not itself end the turn: output, then keep executing until one of the three endpoints (compliance checkpoint, external blocker, stage exit) is reached.
|
|
14
|
-
- Canonical example: the 回合连续性 rule in [`.agents/skills/tdd-implement/references/stages.md`](
|
|
14
|
+
- Canonical example: the 回合连续性 rule in [`.agents/skills/tdd-implement/references/stages.md`](.agents/skills/tdd-implement/references/stages.md) stage ③.
|
|
15
15
|
|
|
16
16
|
## Rule 2 — Model Selection
|
|
17
17
|
|
|
@@ -31,7 +31,7 @@ Every skill that touches git must preserve history after `BASE_HEAD`: history ma
|
|
|
31
31
|
|
|
32
32
|
To achieve "directory clean" (`git status` clean) the skill may only delete its own temporary artifacts (`[DEBUG-...]`, one-off scripts, untracked probe files) — it must never use git-level destructive commands to reach a clean state. The following are forbidden without explicit user confirmation: `git reset --hard`, `git checkout .`, `git clean -fd`, `git stash push --include-untracked` (use `--keep-index` instead and `pop` with verification), `git push --force`, `git rebase -i` and any `reset`/`checkout` that moves `HEAD` backward.
|
|
33
33
|
|
|
34
|
-
Canonical enforcement: [`tdd-implement/references/stages.md`](
|
|
34
|
+
Canonical enforcement: [`tdd-implement/references/stages.md`](.agents/skills/tdd-implement/references/stages.md) stage ③/⑥/⑦/A2-A4 Git 安全红线 and [`commit-check/SKILL.md`](.agents/skills/commit-check/SKILL.md) ③ 目录卫生.
|
|
35
35
|
## Long-horizon skills inventory
|
|
36
36
|
|
|
37
37
|
Skills currently classified as Long-Horizon, to be evolved against these rules as they are touched: `tdd-implement` (fixed), `diagnose-fix` (fixed — new orchestration skill for diagnosis + TDD fix, carries its own Turn Continuity rule), `diagnosing-bugs`, `improve-codebase-architecture`, `wayfinder`, `grill-to-spec`, `to-spec`. Backfilling existing skill texts is out of scope for now — these rules bind new and edited skills going forward.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ci-guard
|
|
3
|
+
description: "Guard the GitHub Actions release pipeline: orchestrate workflow flow, enforce pre-release verification, and self-correct after publish. Use when CI is flaky/failing, when setting up or editing .github/workflows/ci.yml, or before tagging a release to npm."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CI Guard
|
|
7
|
+
|
|
8
|
+
**guard** 为领衔词的发布门禁技能:以一次**可复现的失败**为起点,把 `verify → build → publish` 编排成不可绕过的门,把**预发布校验**做成硬门槛,把**发布后自纠**做成闭环。本技能沉淀自 `heihei0299/pi-switch` 23 次运行中 14 次失败的复盘(见 `.scratch/research/ci-actions-调研.md`)——不替代 `diagnose-fix` 的通用诊断,只收敛 CI/发布这一条链。
|
|
9
|
+
|
|
10
|
+
## 何时用
|
|
11
|
+
|
|
12
|
+
- Actions 持续红 / 偶发红(尤其是 `verify` 单点红而 `publish` 仍绿)
|
|
13
|
+
- 新建或改动 `.github/workflows/ci.yml`、调整 `cargo test` / `clippy` / `rustfmt` 参数
|
|
14
|
+
- 打 tag 前、发 npm 前、或发布后需要自检/回滚
|
|
15
|
+
|
|
16
|
+
## 三段式门禁
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
① 编排 flows → ② 预发布 gate → ③ 发布后自纠
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
每段有**完成条件**(可验证),未满足不进入下一段。
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
### ① 编排 flows —— 让工作流不可被绕过
|
|
27
|
+
|
|
28
|
+
**做**:
|
|
29
|
+
- `on`:`push.tags: ["v*"]` **必须**同时配 `push.branches: [main]`(或 `master`)+ `pull_request.branches: [main]` + `workflow_dispatch`。否则直推 `main` 的修复(如 `2d68f62`)无法被 CI 验证,tag 才暴露问题
|
|
30
|
+
- `jobs` 依赖:`publish.needs: [build, verify]`,**禁止** `needs: build` 单依赖。门禁失效的直接原因就是 `verify` 红仍发包
|
|
31
|
+
- `permissions` 最小化:`verify`/`build` 只需 `contents: read`,仅 `publish` 保留 `contents: write` + `packages: write`(或 `id-token: write` 若用 OIDC)
|
|
32
|
+
- `concurrency`:`group: ci-${{ github.ref }}` + `cancel-in-progress: true`,避免同分支并行互踩
|
|
33
|
+
- `cache`:`rust-cache` 或 `actions/cache` 缓存 `~/.cargo` + `target`,`actions/setup-node` 加 `cache: npm`,避免每次 `npm install` 重装
|
|
34
|
+
- `find changed Rust files`:`git diff origin/main...HEAD` 在 tag 事件下为空,改为 `git diff --name-only HEAD~1...HEAD` 或直接全量 `cargo fmt --check` / `clippy`,避免误跳过
|
|
35
|
+
|
|
36
|
+
**完成条件**:
|
|
37
|
+
- [ ] `git diff HEAD -- .github/workflows/ci.yml` 显示 `on.push.branches` 存在
|
|
38
|
+
- [ ] `publish.needs` 包含 `verify`
|
|
39
|
+
- [ ] `workflow_dispatch` 可手动触发全量
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### ② 预发布 gate —— 在写盘之前变红
|
|
44
|
+
|
|
45
|
+
本段是**硬门槛**,顺序固定:`fmt → clippy → test → build`,任一步红即阻断 `publish`。
|
|
46
|
+
|
|
47
|
+
**fmt / clippy**:
|
|
48
|
+
- `rustfmt --check` 与 `cargo clippy --all-targets -- -D warnings` 必须与本地一致(`rust-toolchain.toml` 锁定 `stable` 版本)
|
|
49
|
+
- 允许的 `-A` 必须显式列出(如本仓 `-A clippy::manual_checked_ops` 等 4 项),不批量 `-A clippy::all`
|
|
50
|
+
|
|
51
|
+
**test(关键)**:
|
|
52
|
+
- 落盘测试(如 `web::tests` 直写 `config.json` / `models.json`)**必须**测试隔离:`config_dir()` / `pi_dir()` / `models_path()` 在 `#[cfg(test)]` 下重定向到 `temp/pi-switch-test-<pid>`(参考 `src-rust/proxy.rs:115 init_test_state_dir()`,`config.rs:460` 为未隔离反例;曾用 `PI_SWITCH_CONFIG_DIR` 环境覆盖后被 `20f6f86` 误删,即回归)
|
|
53
|
+
- 若暂未隔离,CI 侧以 `cargo test --release --lib -- --test-threads=1` 串行化为**过渡**(`2d68f62` 方案,322/322 稳定),并在代码侧记录 `TODO(ci-guard): 恢复 config_dir 测试隔离后去掉 --test-threads=1`
|
|
54
|
+
- `verify` 必须跑 `cargo test --lib`(或 `--release --lib` 与发布一致),不跳过;`build` 矩阵 5 目标仅验编译,不代验测试
|
|
55
|
+
|
|
56
|
+
**完成条件**:
|
|
57
|
+
- [ ] 本地 `cargo test --lib -- --test-threads=1` 322/322 且 `cargo test --lib`(并行)亦 322/322 或已记录隔离 TODO
|
|
58
|
+
- [ ] `cargo clippy --all-targets` 0 warning
|
|
59
|
+
- [ ] `npm run build:webui` 在 `verify` 与 `build` 均执行(本仓 WebUI 缺失会导致 `publish` 产物不一致)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### ③ 发布后自纠 —— 发出去的包自己负责
|
|
64
|
+
|
|
65
|
+
**发布时**:
|
|
66
|
+
- `npm publish --access public` 仅在 `if: startsWith(github.ref, 'refs/tags/v')` 且 `needs` 全绿时执行
|
|
67
|
+
- 发布前 `actions/download-artifact` 校验 `if-no-files-found: error`,发布后 `npm view <pkg>@<version> version` 回读确认
|
|
68
|
+
|
|
69
|
+
**自纠**:
|
|
70
|
+
- 失败即 **阻断**:`verify` 红 → `publish` 不执行(由 `needs` 保证);`publish` 自身失败(`409 already exists` / `401`)→ 工作流整体 `failure`,不静默
|
|
71
|
+
- 发布后 30s 内 `curl https://registry.npmjs.org/<pkg>/<version>` 校验可用;失败则 `gh issue create --title "chore(release): vX.Y.Z 发布后自检失败" --body "run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"` 并 `gh release delete vX.Y.Z --yes`(或 `npm unpublish <pkg>@<version>` 在 72h 内)
|
|
72
|
+
- `workflow_dispatch` 支持 `inputs.rollback_version` 手动回滚
|
|
73
|
+
|
|
74
|
+
**完成条件**:
|
|
75
|
+
- [ ] `npm view` 回读与 tag 一致
|
|
76
|
+
- [ ] 失败路径有 issue/通知(非静默)
|
|
77
|
+
- [ ] `git tag` 与 `package.json version` 一致(`scripts/release.sh` 或 `npm version` 保证)
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 反模式
|
|
82
|
+
|
|
83
|
+
- **单依赖 publish**:`needs: build` 是本仓 7 次带病发布的根因
|
|
84
|
+
- **仅 tag 触发**:`push.branches` 缺失导致主干修复无 CI
|
|
85
|
+
- **真实落盘并行测试**:无 `#[cfg(test)]` 隔离的 `config_dir` 直写是偶发红的根因,`--test-threads=1` 只是止血
|
|
86
|
+
- **静默发布**:`publish` 失败不建 issue / 不删 tag,下次 `409` 叠加
|
|
87
|
+
- **`-A clippy::all`**:掩盖真实告警
|
|
88
|
+
|
|
89
|
+
## 引用
|
|
90
|
+
|
|
91
|
+
- 调研:`.scratch/research/ci-actions-调研.md`(23 次运行全量、`proxy.rs:115` vs `config.rs:460` 对比)
|
|
92
|
+
- 修复:`2d68f62 fix(ci): gate publish on verify and serialize Rust tests`
|
|
93
|
+
- 关联技能:`diagnose-fix`(通用诊断)、`commit-check`(提交前门禁)、`tdd`(测试隔离后的回归)
|
|
94
|
+
|
|
95
|
+
## 执行清单(粘贴即用)
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
- [ ] .github/workflows/ci.yml: on.push.branches: [main] 已加
|
|
99
|
+
- [ ] publish.needs: [build, verify]
|
|
100
|
+
- [ ] verify: cargo test --release --lib -- --test-threads=1(或已隔离则去掉该 flag)
|
|
101
|
+
- [ ] config.rs: #[cfg(test)] config_dir/pi_dir → temp(或 TODO 已记录)
|
|
102
|
+
- [ ] workflow_dispatch 可手动触发
|
|
103
|
+
- [ ] npm view 回读 + 失败建 issue
|
|
104
|
+
```
|