/wiki-sdd:to-triggersfrom wiki-sdd
Converts plain-language rules into vault.yaml trigger entries by interviewing intent, authoring matching mechanics (regex, globs, predicates), and validating with kmd validate.
Ships in wiki-sdd. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Convert a stated rule into a trigger entry in vault.yaml. The division of
labor is fixed: the user owns the intent ("never let a tag happen before the
retro"); the agent owns the matching sophistication. A mis-authored trigger
either never fires (silent protocol decay) or fails the vault.yaml load
(fail-loud: one invalid trigger takes down every tool). Never hand the user a
regex question they didn't ask for.
The trigger schema is read at use time, never from memory:
wiki skill's references/vault-yaml.md § Harness gate triggers (ships
alongside these skills) — field vocabulary and examples.vault.schema.json (vault root) and kmd validate — the
runtime authority. When the reference file is unavailable, these suffice.Draft a complete trigger from the user's sentence, present it, and ask only what could not be inferred. Never open the interview with questions the intent already answers.
Intent class. Map the sentence:
| The user wants | Class | Event |
|---|---|---|
| a reminder when a topic comes up | inject | prompt |
| a nudge alongside a risky tool call | inject or warn | pretool |
| an action denied until a precondition holds | block | pretool |
Only pretool can block. A prompt-time rule that sounds like a gate
("never tag before the retro") is really a pretool block on the tagging
command plus, optionally, a prompt-time reminder — propose both, let the
user drop one.
Matching draft. Author the mechanics (rules below) with the trigger
id (descriptive kebab-case; duplicate ids keep the first occurrence).
Payload register. text (inject) and reason (block) are read by an
agent mid-session: one ASCII line naming the protocol pointer, no banners.
A block reason tells the denied agent what to do instead, not just why.
Scope. Propose where it lands: the active scope's triggers_extra
(additive), or triggers_extra._all for vault-wide. A full-replace
triggers section only on explicit request — it drops the engine defaults
and the compiled file source too.
Precondition. When the rule is state-dependent ("until the retro is
newer than the release note"), attach when: newer-than {fresh, than} —
the trigger fires when the predicate is FALSE, is suppressed when true,
and is skipped loudly when unevaluable. The clock is frontmatter
updated; an empty than set passes vacuously. Globs select the two
page sets; each scope names its own retro/release conventions.
Keywords (prompt inject). The engine matches through a stemmed, word-boundary FTS5 porter table. Consequences:
release already matches "releasing", "released".release); don't defend against them with regex.intent regexes are the escape hatch for phrasings stemming cannot reach,
not the default.Pretool matchers. AND-composed, deterministic:
tool equals the event's tool name.args_match is an authored, anchored regex over the serialized tool input
(compound commands included). Draft it against real command shapes — for
"block force pushes": matches git push --force origin main and
git push -f, does not match echo "force push". Write the near-miss
counterexamples down; they become the dry-run cases.files globs are cwd-relativized: ** crosses directories (**/ may
match empty), * stays within a segment, ? is one character.Noise budget. Name the cost of a broad draft before accepting it: inject-class dedup defaults to once per session per trigger, so a broad keyword still fires in every session; block-class is exempt from dedup and fires on every matching event. Propose the narrower match first, with the broad one as the explicit fallback. Two consequences worth designing for:
dedup field overrides the default per trigger: never (every
match — pair only with sharp matchers), {minutes: N} (re-fires each
bucket within a session — for long sessions that outlive their context).
The schema rejects dedup on block triggers.No draft touches vault.yaml untested. Write the candidate entries to a
temp file as a bare YAML list (exactly the entries, not nested under a
scope key) and pipe synthetic events through the engine:
cat > /tmp/triggers-draft.yaml <<'EOF'
- id: release-protocol-reminder
on: prompt
enforce: inject
keywords: [tagging, releasing]
text: "Release protocol: ops-publish-kmd is the release chain."
EOF
Synthetic events — one JSON object on stdin per run, always with
--explain:
# prompt event: {"session_id": "...", "prompt": "...", "cwd": "..."}
printf '%s' '{"session_id":"dry-1","prompt":"thinking about releasing tomorrow","cwd":"/tmp"}' \
| kmd hook prompt <vault-root> --explain --triggers /tmp/triggers-draft.yaml
# pretool event: {"session_id": "...", "tool_name": "...", "tool_input": {...}, "cwd": "..."}
printf '%s' '{"session_id":"dry-2","tool_name":"Bash","tool_input":{"command":"git push --force origin main"},"cwd":"/tmp"}' \
| kmd hook pretool <vault-root> --explain --triggers /tmp/triggers-draft.yaml
Reading the trace. --explain prints one JSON object naming the
resolved scope and, per trigger: the matcher verdict (hit, or which stage
missed — tool-miss/args-miss/files-miss/payload-miss; prompt
triggers carry keywords/intent evidence instead), the typed predicate
verdict (satisfied/unmet/vacuous/unknown), the dedup verdict
(exempt/never/fresh/suppressed), whether it fired, and the exact
outcome the harness would receive. Diagnose a near-miss from the trace,
never from empty output. Hook events always exit 0 — the trace is the only
signal.
No state spent. --explain never writes dedup state: probes repeat
stably, and a probe never silences the trigger for a live session. A
dedup: "suppressed" verdict means existing session state already carries
the key — retest under a throwaway session_id (dry-1, dry-2, …) to
see the fresh path.
Fire + near-miss discipline. Every matcher runs at least one
intended-fire case and one near-miss counterexample, and the user sees both
results. The near-misses were written down while drafting the matcher —
"prerelease" against keywords: [releasing] (word boundary holds),
echo "force push" against the force-push regex (no match). A matcher
proven only on its fire case is untested.
Predicate drafts. A when: newer-than candidate is tested against the
real vault filesystem read-only — the vault-root argument points at the real
vault so the globs select real pages. Never fabricate retro or release
fixtures inside a real vault to make a predicate evaluate.
vault.yaml is a controlled-vocabulary
surface.kmd validate after the write. Red means revert before anything else:
an invalid config fails the load for every tool, not just the new trigger.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub bartolli/kmd --plugin wiki-sdd10 skills in this plugin
/handoffThis skill should be used to close a session so the next one starts cold from corrected truth. Operator-invoked, gated on a retro note newer than the scope's last edit. Rewrites the primer within its budget first, then runs the status sweep (fully-resolved stories proposed for archiving, flipped only on approval) and reconciles every plan's Story Index — Focus, Next, Open, Read order, about 300 words, nothing another surface derives — confirms the index synced, and prints the one line the next session starts with. Use when the user says "/handoff", "hand off", "close the session", "wrap up the session", "prep the primer", "get the primer ready", "cold session prep", or "what does the next session start with"./intentInterview-style grilling that captures intent, sharpens vocabulary, and scaffolds wiki structure for a project scope. Use when the user wants to start a new workstream, refine an existing scope's intent, stress-test a plan against the project's domain language, or write a `glossary.md` (terms + relationships). Walks one question at a time, recommends an answer for each, and creates artifacts (`index.md`, `primer.md`, `glossary.md`, lazy ADRs) inline as decisions crystallize. Auto-detects greenfield (scope folder missing → scaffold) vs brownfield (scope exists → refine + cross-reference code). Triggers on phrases like "grill me", "grill the plan", "let's nail down what we're building", "set up a new scope", "refine the intent", "capture the intent", "write an intent", or `/intent`.Other plugins' skills for the same job