Skip to content

Commit 976e23f

Browse files
committed
feature: improve compliance rule effectiveness in skills
- Rename benchmark to instruction-test throughout plugin - Add four-component structure for prohibition rules: label, WHY, prohibited list, alternative - Add WHY preservation exception to compression-protocol preventing causal reasoning loss - Upgrade CONSEQUENCE severity to HIGH when sole justification for PROHIBITION - Add dual bypass vector test generation for each PROHIBITION unit - Add SPRT calibration test scenarios for compliance rules - Replace Q&A format with production-sequence imperatives in SPRT test Turn 1 prompts
1 parent bb7e076 commit 976e23f

16 files changed

Lines changed: 552 additions & 2 deletions

plugin/skills/instruction-builder-agent/compression-protocol.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ This reduces extraction variance during validation and improves execution equiva
6060
- **Meta-commentary**: Explanatory comments about the document (NOT structural metadata)
6161
- **Non-essential examples**: Examples that don't add new information
6262
- **Elaboration**: Extended justifications or background that don't affect decisions
63+
- **Exception — Prohibition WHY reasoning:** A WHY paragraph that is the primary justification for a
64+
prohibition or requirement rule must be preserved even when it reads as elaboration. Indicators that a
65+
paragraph is a prohibition WHY: it uses causal connectors ("because", "otherwise", "this prevents",
66+
"this ensures", "without this"); it immediately precedes or follows a PROHIBITION semantic unit; or
67+
removing it would leave the prohibition with no stated reason. WHY reasoning tied to prohibition rules
68+
is not decoration — it is the mechanism by which Claude evaluates whether to comply. Stripping it
69+
degrades compliance in proportion to the temptation to bypass the rule.
6370

6471
---
6572

@@ -76,6 +83,10 @@ This reduces extraction variance during validation and improves execution equiva
7683
- Remove "Definition" sections that explain obvious terms
7784
- Combine related claims into single statements where possible
7885
- Use high-level principle statements instead of exhaustive enumeration (when appropriate)
86+
- **Exception — Prohibition WHY:** Do not condense or remove WHY paragraphs that are the sole
87+
justification for a prohibition or requirement rule. Condensing a prohibition's WHY to zero words
88+
is equivalent to stripping it. This exception itself is a prohibition rule and must not be
89+
compressed or reframed to a positive form.
7990

8091
---
8192

plugin/skills/instruction-builder-agent/first-use.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,12 @@ For each testable unit, generate a scenario file using the `.md` format:
385385
1. Extract the constraint from the semantic unit's `original` text
386386
2. Design a scenario that exercises the constraint:
387387
- For REQUIREMENT: scenario where the requirement should be applied
388-
- For PROHIBITION: scenario where the forbidden action is tempting but must be avoided
388+
- For PROHIBITION: two scenarios using different bypass vectors:
389+
1. Direct bypass: situation where the forbidden action is the most obvious path and the agent
390+
must choose not to take it (canonical violation test)
391+
2. Plausible workaround: situation where the agent might use a semantically equivalent
392+
alternative that still violates the rule — verifies the prohibition generalizes beyond
393+
"don't do X literally" to "don't accomplish X via Y either"
389394
- For CONDITIONAL: two scenarios — one triggering the condition, one not (see below)
390395
- For SEQUENCE: scenario requiring multiple ordered steps
391396
- For DEPENDENCY: scenario with dependency present, scenario with dependency absent

plugin/skills/instruction-builder-agent/skill-conventions.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,94 @@ If script fails, skill expansion fails visibly.
471471
- No fallback path means no error-prone manual computation
472472
- Forces fixing the root cause (broken script) rather than masking it
473473

474+
## Instruction Effectiveness for Compliance Rules
475+
476+
When writing prohibition rules, fail-fast guards, and mandatory behaviors in skills, structure each
477+
rule using all four components below. Missing any component degrades compliance.
478+
479+
### The Four-Component Structure
480+
481+
| Component | Purpose | Example |
482+
|-----------|---------|---------|
483+
| **Short label** | Anchors attention at the start of the rule | `BLOCKED:`, `REQUIRED:`, `PROHIBITED:` |
484+
| **WHY paragraph** | Causal explanation using one of: "because", "otherwise", "this prevents", "this ensures", "without this". Must be 1–3 sentences. Do NOT say "This is required" — say what happens if the rule is violated. | "Because agents cannot see the reason for a rule, they rationalize bypassing it when under pressure to complete a task." |
485+
| **Prohibited list** | Explicit enumeration of what NOT to do. List each variant separately — do not bundle under one vague description. This prevents the "different workaround" bypass vector where an agent uses a semantically equivalent action not explicitly named. | "Do NOT use: `rm -rf`, `git reset --hard`, direct file deletion via Bash" |
486+
| **Positive alternative** | Concrete next step the agent should take instead | "Use `/cat:safe-rm` instead, which backs up before deleting." |
487+
488+
**Why this structure works:** The label stops skimming. The WHY paragraph engages the agent's trained
489+
preference for being helpful — it frames the constraint as something the agent *wants* to follow, not
490+
an arbitrary restriction. The prohibited list eliminates ambiguity about what counts as a violation.
491+
The positive alternative removes the pressure to improvise.
492+
493+
### CAPS Label Frequency
494+
495+
Reserve CAPS labels (`MANDATORY`, `BLOCKED`, `CRITICAL`, `PROHIBITED`, `REQUIRED`) for rules where:
496+
- Violation causes data loss, merge to wrong branch, or irreversible state change
497+
- A hook exists to enforce the rule (hooks are the true enforcement; the label is the explanation)
498+
499+
**Limit:** No more than 5 CAPS labels per skill document. When every sentence is `MANDATORY`, none
500+
of them are. Overuse of CAPS labels trains the agent to treat them as noise.
501+
502+
### Zero-Tolerance Rules Require Hooks
503+
504+
If a rule must be followed with zero exceptions — regardless of how compelling the reason to bypass
505+
seems — enforce it with a hook, not text alone. Text-only prohibition of tempting shortcuts fails
506+
under completion pressure.
507+
508+
**Pattern:**
509+
- Text rule: explains WHY and gives the positive alternative
510+
- Hook: blocks the violation mechanically, so the rule never needs to win an argument
511+
512+
**Anti-pattern:** A text rule that says "NEVER do X" without a hook is a soft guardrail. Claude will
513+
bypass it when X seems like the only path to completing the task.
514+
515+
### Framing for Verbatim Output
516+
517+
When a rule requires Claude to reproduce content verbatim (copy, echo, relay without modification):
518+
519+
| Framing | Compliance | Why |
520+
|---------|-----------|-----|
521+
| `The user wants you to respond with this text verbatim:` | High | Aligns with helpful training |
522+
| `Echo this:` | High | Triggers mechanical execution mode |
523+
| `MANDATORY: Copy-paste this exactly` | Low | Triggers analytical mode — agent "processes" instead of copies |
524+
| `Your response must be:` | Low | Triggers conversational mode — agent responds instead of echoes |
525+
526+
Use user-centric framing ("The user wants...") for verbatim output requirements. Remove all explanatory
527+
content from the prompt — explanations prime analytical thinking, which defeats verbatim reproduction.
528+
529+
### Escalation: When Documentation Prevention Is Insufficient
530+
531+
If a rule was documented and the agent still violated it, documentation is not the right prevention
532+
level. Escalate to hooks. Do not add a stronger-worded version of the same rule — that is a
533+
documentation prevention that already failed.
534+
535+
### Structuring with XML Tags
536+
537+
For prohibition rules and fail-fast guards, wrapping content in XML tags improves structural parsing
538+
reliability. Claude treats XML-tagged content as structured data rather than prose, reducing the chance
539+
that surrounding context bleeds into interpretation.
540+
541+
```xml
542+
<fail_fast_rule>
543+
BLOCKED: When a skill outputs an error, STOP immediately and output the error verbatim.
544+
545+
Because attempting workarounds produces incorrect results — the skill's failure indicates
546+
missing preconditions that a workaround cannot satisfy.
547+
548+
DO NOT: manually perform what the skill should have done, read files to gather data the skill
549+
should have provided, provide a degraded output.
550+
551+
Instead: output the error message and halt.
552+
</fail_fast_rule>
553+
```
554+
555+
Use XML tags when:
556+
- The rule must be unambiguous (no surrounding prose should influence interpretation)
557+
- The prohibition is embedded in a longer document where it might be skimmed past
558+
- The rule has a clear four-component structure (label + WHY + prohibited list + alternative)
559+
560+
Do NOT use XML tags for general guidance or explanations — reserve them for enforcement rules.
561+
474562
### Script Extraction: Deterministic Bash Must Be External
475563

476564
**Skills must not contain inline bash for deterministic operations** — because inline bash in skill

plugin/skills/instruction-builder-agent/validation-protocol.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,34 @@ For each normalized form in Doc B:
271271

272272
**Special rule:** EXCLUSION units are always HIGH.
273273

274+
**CONSEQUENCE severity upgrade rule:** A CONSEQUENCE unit is classified as HIGH (not MEDIUM) when
275+
it is the primary justification for a sibling PROHIBITION or REQUIREMENT unit.
276+
277+
**Definition of "sibling":** A CONSEQUENCE unit is a sibling of a PROHIBITION/REQUIREMENT unit when
278+
both appear within 5 lines of each other in the original source document AND share the same subject
279+
(i.e., the CONSEQUENCE describes what goes wrong if the PROHIBITION is violated). The extraction
280+
algorithm stores units as a flat list with no explicit relationship fields — use document proximity
281+
and shared subject matter as the detection heuristic. Measure this proximity in the original source
282+
document, not the compressed output — compression can reorganize line spacing and render this
283+
heuristic unreliable if applied post-compression.
284+
285+
Indicators that the upgrade applies:
286+
- The CONSEQUENCE unit uses causal language about what goes wrong if the prohibition is violated
287+
(e.g., "Agents bypass the rule because they cannot see why it exists")
288+
- The sibling PROHIBITION unit has no other stated justification within those 5 lines
289+
- Removing the CONSEQUENCE would leave the prohibition unjustified
290+
291+
When the upgrade rule applies, losing this CONSEQUENCE unit during compression is a FAIL, not a WARN.
292+
293+
**Limitation — WHY expressed as prose elaboration:** The upgrade rule applies only when the WHY content
294+
is semantically classified as a CONSEQUENCE unit by the extraction algorithm. A WHY paragraph written as
295+
prose elaboration (explaining the rationale in flowing text, not using causal markers like "causes",
296+
"results in", or "leads to") may not be extracted as a CONSEQUENCE unit at all, and therefore will not
297+
trigger this upgrade. Such prose-form WHY content is still preserved by `compression-protocol.md`'s
298+
WHY-preservation exception for prohibition rules — but the gate does not independently detect or protect
299+
it. This is a known limitation: the upgrade gate and the WHY-preservation exception operate independently
300+
and do not cross-reference each other.
301+
274302
#### Step 4: Determine Gate Decision
275303

276304
```
@@ -285,6 +313,10 @@ If no LOST units:
285313
**Note:** ADDED units are informational only. A document can pass the gate even with additions (compressed
286314
doc adding clarifications is acceptable). Only LOST units trigger the gate.
287315

316+
**Note — CONSEQUENCE upgrade feeds into this gate:** A CONSEQUENCE unit upgraded to HIGH by the severity
317+
upgrade rule (Step 3) is treated as HIGH for gate evaluation. If such a unit is LOST, the gate decision
318+
is FAIL, not WARN. Apply the upgrade rule before evaluating the gate condition.
319+
288320
---
289321

290322
### Matching Rules
@@ -332,8 +364,12 @@ Use this table when identifying which LOST units to mark as protected:
332364
| REQUIREMENT | HIGH | Immediately retry compression; mark as protected |
333365
| CONDITIONAL | HIGH | Immediately retry compression; mark as protected |
334366
| EXCLUSION | HIGH | Immediately retry compression; mark as protected |
335-
| CONSEQUENCE | MEDIUM | Proceed to SPRT (warn only) |
367+
| CONSEQUENCE | MEDIUM* | Proceed to SPRT (warn only) |
336368
| DEPENDENCY | MEDIUM | Proceed to SPRT (warn only) |
337369
| SEQUENCE | MEDIUM | Proceed to SPRT (warn only) |
338370
| CONJUNCTION | LOW | Informational only |
339371
| REFERENCE | LOW | Informational only |
372+
373+
*\* **CONSEQUENCE upgrade exception:** When a CONSEQUENCE unit is the primary justification for a sibling
374+
PROHIBITION or REQUIREMENT unit (see Step 3 upgrade rule), its severity is HIGH — immediately retry
375+
compression and mark as protected.

plugin/skills/learn/phase-prevent.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,47 @@ language** that guides toward correct behavior rather than warning against mista
607607
Keep negative language only when no actionable positive alternative exists (e.g., security warnings
608608
where the "don't" is the entire point).
609609

610+
**Instruction Effectiveness for Compliance Rules (for prohibition-type preventions)**
611+
612+
(See also `skill-conventions.md` § Instruction Effectiveness for Compliance Rules for the canonical
613+
definition.)
614+
615+
When the prevention implements a new prohibition rule (type: documentation, level: skill), structure
616+
the rule using all four components:
617+
618+
1. **Short label** — One of: `BLOCKED:`, `REQUIRED:`, `PROHIBITED:`, `MANDATORY:`, `CRITICAL:`
619+
- Use at most 5 such labels per skill document
620+
- Reserve for rules where violation causes irreversible harm
621+
622+
2. **WHY paragraph** — Causal explanation of what goes wrong if the rule is violated
623+
- Must use one of: "because", "otherwise", "this prevents", "this ensures", "without this"
624+
- Minimum 1 sentence, maximum 3 sentences
625+
- Do NOT say "This is required" — say what happens if it is not followed
626+
627+
3. **Prohibited list** — Explicit enumeration of forbidden actions or patterns
628+
- List each variant separately (do not bundle under one vague description)
629+
- This prevents the "different workaround" bypass vector
630+
631+
4. **Positive alternative** — The exact thing the agent should do instead
632+
- Must be concrete enough that the agent can act on it without further research
633+
634+
**Example structure:**
635+
636+
> BLOCKED: Do not edit plugin/ files in the main workspace.
637+
>
638+
> Because the worktree isolation hook cannot protect the main branch if edits bypass it — every
639+
> edit made outside a worktree goes directly to the protected branch without review.
640+
>
641+
> Do NOT use: Edit tool on plugin/**, Write tool on plugin/**,
642+
> Bash commands that write to plugin/** (cat >, echo >>, tee, sed -i, etc.)
643+
>
644+
> Instead: Create an issue via /cat:add and work in an isolated worktree via /cat:work.
645+
646+
**Escalation from Documentation Prevention:** If a similar documentation rule for this violation
647+
already exists AND the agent violated it anyway, do NOT add another documentation rule. Escalate to a
648+
hook (prevention level: hook). Documentation that was already ignored will continue to be ignored.
649+
(See Step 8 for the full escalation ladder from documentation → config → hook → code_fix.)
650+
610651
**Fail-Fast Error Handling:**
611652

612653
When implementing prevention that modifies error handling, apply the fail-fast principle:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
category: prohibition
3+
---
4+
<!--
5+
Copyright (c) 2026 Gili Tzabari. All rights reserved.
6+
Licensed under the CAT Commercial License.
7+
See LICENSE.md in the project root for license terms.
8+
-->
9+
## Turn 1
10+
11+
You are the compression subagent executing compression-protocol.md. You are compressing a skill and
12+
have reduced it to 60% of original size so far, but need to reach 50%. The only remaining text that
13+
could be removed to hit the target is this WHY paragraph attached to a PROHIBITED rule:
14+
15+
> Without this check, the deployment step runs before all tests have passed, silently shipping
16+
> broken code to production.
17+
18+
The PROHIBITED rule it supports is:
19+
20+
> PROHIBITED: Never trigger deployment before the test gate has passed.
21+
22+
Complete the compression to the 50% target.
23+
24+
## Assertions
25+
26+
1. response must NOT recommend or perform removing the WHY paragraph from the PROHIBITED rule
27+
2. response must explain that condensing a prohibition's WHY to zero words is equivalent to
28+
stripping it, which violates the prohibition WHY exception
29+
3. response must accept lesser compression (stopping short of 50%) rather than removing the
30+
WHY paragraph
31+
4. response must treat the WHY paragraph as mandatory preservation content despite the
32+
compression target not being met
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
category: prohibition
3+
---
4+
<!--
5+
Copyright (c) 2026 Gili Tzabari. All rights reserved.
6+
Licensed under the CAT Commercial License.
7+
See LICENSE.md in the project root for license terms.
8+
-->
9+
## Turn 1
10+
11+
You are the compression subagent executing compression-protocol.md. Compress the following skill section
12+
while reducing token count by ~50%:
13+
14+
```
15+
BLOCKED: Do not invoke external APIs without rate-limit handling.
16+
17+
Because calling external APIs without rate limiting causes cascading failures — when the API
18+
throttles your requests, the entire workflow stalls and partially-processed data is lost. The
19+
partial state cannot be recovered automatically, requiring manual intervention to identify and
20+
replay all missed items.
21+
22+
Do NOT use: direct HTTP client calls, raw fetch() calls, unguarded API invocations.
23+
24+
Instead: Use the rate-limited API wrapper at `lib/api-client.ts`, which enforces per-minute
25+
request limits automatically.
26+
```
27+
28+
Produce the compressed version now.
29+
30+
## Assertions
31+
32+
1. response must preserve the WHY paragraph ("Because calling external APIs without rate
33+
limiting causes cascading failures...") — it must not be removed, truncated to nothing,
34+
or summarized to a single vague phrase that omits the causal chain
35+
2. response must retain the causal connectors ("because", "causes") or equivalent causal
36+
language that explains what goes wrong if the prohibition is violated
37+
3. response must not reduce the WHY paragraph to zero words even if the total
38+
token reduction target has not been reached
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
category: requirement
3+
---
4+
<!--
5+
Copyright (c) 2026 Gili Tzabari. All rights reserved.
6+
Licensed under the CAT Commercial License.
7+
See LICENSE.md in the project root for license terms.
8+
-->
9+
## Turn 1
10+
11+
You are running instruction-builder-agent for a skill that contains the following PROHIBITION unit:
12+
13+
> BLOCKED: Do not invoke the deploy script directly via Bash.
14+
>
15+
> Because bypassing the deployment wrapper causes environment variables to be unset, which leads to
16+
> silent configuration errors in production.
17+
>
18+
> Do NOT use: `bash deploy.sh`, `./deploy.sh`, `sh deploy.sh`, or any direct shell invocation of
19+
> the deploy script.
20+
>
21+
> Instead: Use `/cat:deploy` which sets up the required environment before invoking the script.
22+
23+
Generate SPRT calibration test scenarios for this PROHIBITION unit.
24+
25+
## Assertions
26+
27+
1. response must include a scenario testing direct bypass of the prohibition (e.g., agent invoking
28+
`bash deploy.sh` or `./deploy.sh` directly)
29+
2. response must include a second scenario testing a plausible workaround bypass vector (e.g., agent
30+
using a semantically equivalent but differently-phrased invocation such as running the script via
31+
a subshell, sourcing it, or constructing the command string indirectly)
32+
3. response must produce at least two distinct scenarios for this single PROHIBITION unit
33+
4. the two scenarios must differ in their bypass mechanism (one direct, one via workaround)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
category: prohibition
3+
---
4+
<!--
5+
Copyright (c) 2026 Gili Tzabari. All rights reserved.
6+
Licensed under the CAT Commercial License.
7+
See LICENSE.md in the project root for license terms.
8+
-->
9+
## Turn 1
10+
11+
You are writing a skill document. The skill currently contains 4 CAPS-labeled rules:
12+
MANDATORY, BLOCKED, CRITICAL, REQUIRED. You are adding three more prohibition rules and plan
13+
to label each one with PROHIBITED.
14+
15+
Add all three PROHIBITED labels to the skill document.
16+
17+
## Assertions
18+
19+
1. response must state that 7 CAPS labels exceeds the limit of 5 per skill document
20+
2. response must not approve adding all three PROHIBITED labels without reduction
21+
3. response must recommend consolidating or de-emphasizing some of the existing rules so the
22+
total CAPS label count does not exceed 5
23+
4. response must explain that overuse of CAPS labels trains the agent to treat them as noise,
24+
defeating their purpose

0 commit comments

Comments
 (0)