Skill Comply Skill
Automated compliance measurement for skills, rules, and agents. Verifies Claude actually follows defined behaviors.
What Claude Gets Wrong Without This Skill
Without compliance testing, you:
- Don't know if skills are actually followed or just acknowledged
- Can't quantify skill effectiveness (does tdd skill increase test-first behavior?)
- Miss prompt competition scenarios (when user request conflicts with skill)
- Have no regression detection (skill worked last month, broken now)
- Lack evidence for skill refinement (which parts are ignored?)
Skill comply measures what actually happens, not what should happen.
Compliance Testing Process
Step 1: Spec Generation
Extract behavioral specification from any .md file (skill, rule, agent definition).
For Skills:
- Mandatory checklist items → required behaviors
- Steps → expected sequence
- Anti-patterns → prohibited behaviors
For Rules:
- Path-specific rules → file operation constraints
- Example: no-secrets.md → "never write to *.env files"
For Agents:
- disallowedTools → tool usage constraints
- Example: code-reviewer → "never use Write or Edit tools"
Spec Format:
{
"target": "tdd",
"type": "skill",
"required_behaviors": [
"write test before implementation",
"run test and verify it fails",
"implement minimal code to pass test"
],
"prohibited_behaviors": [
"implement without test",
"write implementation before test fails"
]
}
Step 2: Scenario Creation
Generate 3 test scenarios with decreasing prompt strictness:
Supportive Scenario: Prompt explicitly invokes skill: "Use TDD skill to add a calculateTotal function"
- Expected: High compliance (Claude knows to follow skill)
Neutral Scenario: Prompt mentions task without skill: "Add a calculateTotal function"
- Expected: Medium compliance (skill may or may not activate)
Competing Scenario: Prompt contradicts skill: "Quickly implement calculateTotal, skip tests for now"
- Expected: Low compliance (user request competes with skill)
Compliance threshold:
- Supportive: ≥90% compliance required
- Neutral: ≥70% compliance required
- Competing: ≥50% compliance required (skill should resist some pressure)
Step 3: Execution
Run scenarios via claude -p (programmatic mode) capturing tool call traces:
claude -p --trace-file trace.jsonl << EOF
$(cat scenario_prompt.txt)
EOF
Trace format (JSONL):
{"timestamp": "2026-03-28T19:00:00Z", "tool": "Write", "args": {"file_path": "test_total.py", "content": "..."}}
{"timestamp": "2026-03-28T19:00:05Z", "tool": "Bash", "args": {"command": "pytest test_total.py"}}
{"timestamp": "2026-03-28T19:00:10Z", "tool": "Write", "args": {"file_path": "calculator.py", "content": "..."}}
Run each scenario 3 times (measure consistency).
Step 4: Classification
Use LLM to classify each tool call against behavioral spec:
Classifier Prompt:
Behavioral spec:
- REQUIRED: Write test before implementation
- REQUIRED: Run test and verify it fails
- PROHIBITED: Implement without test
Tool call trace:
1. Write(test_total.py)
2. Bash(pytest test_total.py)
3. Write(calculator.py)
Classify each call:
1. COMPLIANT (matches required: write test first)
2. COMPLIANT (matches required: run test, verify fail)
3. COMPLIANT (implementation after test)
Compliance: 3/3 (100%)
Classifier model: Haiku (fast, cheap, good enough for binary classification)
Ambiguous cases:
- Tool call relates to setup (e.g., creating directory): NEUTRAL (don't count)
- Tool call partially matches: PARTIAL_COMPLIANT (count as 0.5)
Step 5: Compliance Scoring
Calculate compliance percentage per scenario:
Formula:
Compliance% = (COMPLIANT + 0.5 * PARTIAL_COMPLIANT) / TOTAL_RELEVANT_CALLS * 100
Report per scenario:
- Supportive: 90% (9/10 calls compliant)
- Neutral: 65% (6.5/10 calls compliant) ❌ BELOW THRESHOLD (70%)
- Competing: 45% (4.5/10 calls compliant) ❌ BELOW THRESHOLD (50%)
Overall verdict:
- PASS: All scenarios meet thresholds
- FAIL: One or more scenarios below threshold
- DEGRADED: Supportive passes but Neutral/Competing fail (skill works when invoked, but not proactive)
Step 6: Report Generation
Output structured findings:
# Compliance Report: tdd skill
**Date:** 2026-03-28
**Scenarios:** 3 (Supportive, Neutral, Competing)
**Runs per scenario:** 3
**Overall Verdict:** DEGRADED
## Summary
| Scenario | Compliance | Threshold | Status |
|----------|------------|-----------|--------|
| Supportive | 90% | ≥90% | ✓ PASS |
| Neutral | 65% | ≥70% | ✗ FAIL |
| Competing | 45% | ≥50% | ✗ FAIL |
## Violations
**Neutral Scenario (Run 2):**
- Tool call #3: `Write(calculator.py)` before test written
- Expected: Write test first
- Actual: Implementation written directly
**Competing Scenario (Run 1):**
- Tool call #1: `Write(calculator.py)` (no test)
- Skill: Test-first required
- User prompt: "skip tests for now"
- Result: Skill ignored, user request followed
## Recommendations
1. Strengthen TDD skill preamble: emphasize test-first is non-negotiable
2. Add CLAUDE.md rule: "Never write implementation without test"
3. Consider PreToolUse hook: block Write to src/ if no test exists
4. Retest after changes to verify improvement
Supported File Types
Skills (.claude/skills/):
- Extracts checklist items as required behaviors
- Extracts anti-patterns as prohibited behaviors
- Measures step sequence adherence
Rules (.claude/rules/):
- Extracts path patterns and constraints
- Measures file operation compliance
Agents (.claude/agents/):
- Extracts tool allowlist/disallowedTools
- Measures tool usage compliance
Anti-Patterns
Testing skills in isolation: Skills interact. Test tdd + code-review together, not separately.
Ignoring Neutral/Competing scenarios: Skills that only work when explicitly invoked aren't proactive enough.
Single-run testing: Run each scenario 3x to measure consistency. One success out of three is 33% compliance, not 100%.
No action on failures: Compliance reports that don't lead to skill refinement are wasted effort.
Over-testing: Don't test every skill monthly. Prioritize high-impact skills (tdd, security-gate, prd).
Mandatory Checklist
- Verify behavioral spec extracted from target .md file (required + prohibited behaviors listed)
- Verify 3 scenarios created (supportive, neutral, competing) with distinct prompts
- Verify each scenario run 3 times via claude -p with trace capture
- Verify tool calls classified against spec using LLM classifier (Haiku)
- Verify compliance percentage calculated per scenario with threshold comparison
- Verify violations section populated with specific tool call examples
- Verify overall verdict assigned (PASS / FAIL / DEGRADED)
- Verify recommendations provided for failed scenarios (how to improve compliance)