Skip to content

Commit aa950a5

Browse files
sakitAclaude
andcommitted
feat: Add constitution violation check command and after_implement hook
Adds /speckit.optimize.check for on-demand compliance auditing of feature artifacts against constitution principles. Fills the gap between spec-kit's built-in gates at /speckit.plan and /speckit.analyze where manual edits can silently break constitution rules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e072ad2 commit aa950a5

6 files changed

Lines changed: 371 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to the Optimize extension will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.0] - 2026-04-04
9+
10+
### Added
11+
12+
- Constitution violation check command (`/speckit.optimize.check`) — on-demand compliance audit of feature artifacts and code against constitution principles
13+
- `after_implement` hook — auto-prompts constitution check after implementation completes
14+
- Check configuration settings: `check.include_code_by_default`, `check.min_severity`
15+
- RFC 2119 keyword-based severity classification (CRITICAL for MUST/SHALL, HIGH for SHOULD)
16+
- Support for `--feature`, `--include-code`, and `--severity` arguments
17+
818
## [1.0.0] - 2026-04-03
919

1020
### Added

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,39 @@ Measures the token footprint of all governance files and extension commands. Tra
6666
/speckit.optimize.tokens --extensions-only
6767
```
6868

69+
### `/speckit.optimize.check` — Constitution Violation Check
70+
71+
On-demand compliance audit: checks the current feature's spec, plan, tasks, and optionally implementation code against every principle in the constitution. Catches violations introduced by manual edits between the built-in `/speckit.plan` and `/speckit.analyze` gates.
72+
73+
```bash
74+
# Check active feature against constitution
75+
/speckit.optimize.check
76+
77+
# Check a specific feature
78+
/speckit.optimize.check --feature user-authentication
79+
80+
# Also scan implementation source files
81+
/speckit.optimize.check --include-code
82+
83+
# Only show critical violations
84+
/speckit.optimize.check --severity CRITICAL
85+
```
86+
87+
| Argument | Description | Default |
88+
|----------|-------------|---------|
89+
| `--feature <name>` | Target a specific feature instead of auto-detecting | Active feature |
90+
| `--include-code` | Also scan implementation source files referenced in tasks | Disabled |
91+
| `--severity <level>` | Filter to CRITICAL, HIGH, or ALL | ALL |
92+
93+
**How it works:**
94+
1. Parses the constitution into individual principles using RFC 2119 keywords (MUST, SHOULD, etc.)
95+
2. Loads the feature's spec.md, plan.md, and tasks.md
96+
3. Evaluates each principle for contradictions, omissions, structural violations, and semantic drift
97+
4. Reports violations with severity (CRITICAL for MUST, HIGH for SHOULD, MEDIUM for ambiguous)
98+
5. Provides evidence and location for every finding
99+
100+
**Hook:** After `/speckit.implement` completes, you are prompted to run this check automatically. This catches violations at the earliest useful moment — after code is written but before you commit.
101+
69102
### `/speckit.optimize.learn` — Session Learning
70103

71104
End-of-session analysis: detects AI mistake patterns, repetitive corrections, and governance gaps. Suggests constitution rules or memory entries to prevent recurrence.
@@ -99,6 +132,8 @@ cp .specify/extensions/optimize/config-template.yml \
99132
```
100133

101134
Key settings:
135+
- `check.include_code_by_default` — scan implementation files without `--include-code` flag
136+
- `check.min_severity` — minimum severity to report (CRITICAL, HIGH, MEDIUM, or ALL)
102137
- `categories.*` — toggle individual analysis categories on/off
103138
- `thresholds.max_constitution_tokens` — flag constitutions exceeding this token estimate
104139
- `thresholds.governance_budget_percent` — max % of context window for governance overhead
@@ -109,6 +144,7 @@ Key settings:
109144

110145
- **`/speckit.constitution`** — authoring tool. Optimize hands off to it for applying approved changes with proper version bumping.
111146
- **`/speckit.analyze`** — consistency checker. Run after optimization to verify cross-artifact alignment.
147+
- **`/speckit.optimize.check`****`/speckit.optimize.run`** — if violations are found, run the full audit to optimize the constitution.
112148
- **`/speckit.optimize.tokens`****`/speckit.optimize.run`** — if token tracker reveals high governance overhead, run the full audit.
113149
- **`/speckit.optimize.learn`****`/speckit.constitution`** — approved rules from session learning are applied via the constitution skill.
114150

catalog-entry.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"id": "optimize",
44
"description": "Audits and optimizes AI governance for context efficiency",
55
"author": "sakitA",
6-
"version": "1.0.0",
7-
"download_url": "https://github.com/sakitA/spec-kit-optimize/archive/refs/tags/v1.0.0.zip",
6+
"version": "1.1.0",
7+
"download_url": "https://github.com/sakitA/spec-kit-optimize/archive/refs/tags/v1.1.0.zip",
88
"repository": "https://github.com/sakitA/spec-kit-optimize",
99
"homepage": "https://github.com/sakitA/spec-kit-optimize",
1010
"documentation": "https://github.com/sakitA/spec-kit-optimize/blob/main/README.md",
@@ -14,19 +14,21 @@
1414
"speckit_version": ">=0.1.0"
1515
},
1616
"provides": {
17-
"commands": 3,
18-
"hooks": 0
17+
"commands": 4,
18+
"hooks": 1
1919
},
2020
"tags": [
2121
"constitution",
2222
"optimization",
2323
"token-budget",
2424
"governance",
25-
"audit"
25+
"audit",
26+
"compliance",
27+
"violation-check"
2628
],
2729
"verified": false,
2830
"downloads": 0,
2931
"stars": 0,
3032
"created_at": "2026-04-03T00:00:00Z",
31-
"updated_at": "2026-04-03T00:00:00Z"
33+
"updated_at": "2026-04-04T00:00:00Z"
3234
}

0 commit comments

Comments
 (0)