-
Notifications
You must be signed in to change notification settings - Fork 0
Feature Mastering Hooks Spec
Feature Branch: feature/cch-skill-v1
Created: 2025-01-21
Status: In Progress
Input: PRD documents from docs/prds/
As a developer, I want to say "Install CCH" and have the skill automatically download and install the correct binary for my platform.
Why this priority: Without the binary, nothing else works. Installation must be seamless.
Independent Test: Can be fully tested by running the skill on a machine without CCH and verifying the binary is installed and working.
Acceptance Scenarios:
-
Given CCH binary is not installed, When user says "Install CCH", Then skill detects OS/arch, downloads correct artifact, verifies checksum, and installs to
.claude/bin/cch - Given CCH binary is installed, When user says "Install CCH", Then skill reports current version and offers to update if newer available
-
Given installation completes, When running
cch --version --json, Then output shows valid version and api_version - Given download fails, When checksum doesn't match, Then skill reports error and does not install
As a developer, I want to say "Set up hooks for this project" and have the skill analyze my codebase and generate appropriate rules.
Why this priority: Zero-config setup is the key value proposition that differentiates CCH Skill from manual configuration.
Independent Test: Can be tested by running the skill on a project with skills and CLAUDE.md, verifying hooks.yaml is generated with sensible rules.
Acceptance Scenarios:
-
Given a project with
.claude/skills/containing skill definitions, When user requests setup, Then skill generates PreToolUse trigger rules for each skill - Given CLAUDE.md contains "MUST NOT use console.log", When user requests setup, Then skill generates a validator script and rule to enforce it
- Given analysis complete, When presenting to user, Then skill shows each recommended rule with explanation of WHY it's recommended
-
Given user approves, When installing, Then skill creates hooks.yaml, context files, validators, runs
cch validate, and runscch install --project
As a developer, I want to say "Create a hook to trigger the CDK skill when editing infra files" and have the skill add just that rule.
Why this priority: Incremental configuration is essential for users who want fine-grained control.
Independent Test: Can be tested by requesting a single rule addition and verifying hooks.yaml is updated correctly.
Acceptance Scenarios:
- Given user describes a rule, When skill parses request, Then it identifies skill, target files, and action type
-
Given skill exists at
.claude/skills/aws-cdk/SKILL.md, When creating trigger rule, Then skill extracts relevant extensions/directories from SKILL.md - Given existing hooks.yaml, When adding rule, Then skill merges new rule without breaking existing configuration
-
Given rule added, When user approves, Then skill runs
cch validateandcch install --project
As a developer, I want to ask "Why isn't my hook blocking WIP commits?" and get a clear explanation with suggested fixes.
Why this priority: Users will inevitably have configuration issues; good troubleshooting builds trust.
Independent Test: Can be tested by creating a misconfigured rule and asking the skill to debug it.
Acceptance Scenarios:
- Given user reports hook not working, When skill investigates, Then it reads hooks.yaml, finds relevant rule, and queries logs
- Given logs show event, When rule didn't match, Then skill explains which matcher failed and why
- Given rule matched but didn't block, When mode is "audit", Then skill explains the mode and suggests changing to "enforce"
- Given analysis complete, When presenting to user, Then skill shows relevant log entry and suggests specific fix
As a developer, I want to ask "Why does this rule exist?" and understand where it came from and its purpose.
Why this priority: Enterprise governance requires auditability of all policy decisions.
Independent Test: Can be tested by querying provenance of rules generated by the skill.
Acceptance Scenarios:
- Given rule has metadata.author, When user asks about rule, Then skill shows who created it
- Given rule came from CLAUDE.md, When explaining, Then skill shows the original text and line number
- Given rule is a safety default, When explaining, Then skill explains it's a recommended standard protection
- Given rule has confidence level, When explaining, Then skill shows confidence and explains implications
- What if project has no skills? → Generate only safety defaults and CLAUDE.md rules
- What if CLAUDE.md is missing? → Continue with skill triggers and safety defaults
- What if CCH binary is incompatible version? → Warn user and offer to upgrade
- What if rules conflict? → Detect and present conflicts to user for resolution
- What if user rejects all recommendations? → Allow cancel without changes
- FR-001: Skill MUST detect OS (macOS, Linux, Windows) and architecture (x86_64, ARM64)
- FR-002: Skill MUST download CCH binary from official GitHub releases
- FR-003: Skill MUST verify binary checksum before installation
-
FR-004: Skill MUST discover all SKILL.md files in
.claude/skills/recursively - FR-005: Skill MUST parse CLAUDE.md and extract MUST/MUST NOT/SHOULD rules
- FR-006: Skill MUST classify rules by confidence: high (enforceable), medium (ambiguous), low (vague)
- FR-007: Skill MUST generate hooks.yaml with provenance comments
- FR-008: Skill MUST generate validator scripts for complex rules
- FR-009: Skill MUST detect rule conflicts and present for resolution
-
FR-010: Skill MUST maintain audit trail in
.claude/cch/install.json
- DiscoveredSkill: Name, path, description, applicable extensions/directories
- ExtractedRule: Original text, classification (hard/soft), confidence, scope
- Recommendation: Rule to generate, explanation of why, confidence level
- Conflict: Two rules with overlapping scope and incompatible actions
- AuditRecord: Installation history with timestamps, versions, sources analyzed
- SC-001: Installation succeeds on macOS (Intel + Apple Silicon), Linux (x86_64 + ARM64), Windows (x86_64)
- SC-002: Project analysis completes in <10 seconds for typical projects
-
SC-003: Generated hooks.yaml passes
cch validatein 100% of cases - SC-004: All generated rules include provenance comments
- SC-005: User understands each recommendation (measured by approval rate >80%)