Skip to content

Commit 3e54352

Browse files
Fix constitution-preset-template-sync: discover and propagate to all effective template layers
Apply the remediation from the bug assessment on issue #3737. Update the constitution command template (step 4) to resolve the full effective template stack for plan-template, spec-template, and tasks-template before propagating constitutional guidance. The agent now discovers project-local overrides and all active preset-provided replacements (via .specify/presets/*/preset.yml replaces fields) and propagates to every layer, not just the hard-coded built-in path. Step 5 (Sync Impact Report) is updated to derive entries from the resolved stack and only mark templates as updated when actually reviewed. Refs #3737 Assisted-by: GitHub Copilot (model: claude-sonnet-4.6, autonomous)
1 parent 39f2ac3 commit 3e54352

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

‎templates/commands/constitution.md‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,33 @@ Follow this execution flow:
9797
- Ensure Governance section lists amendment procedure, versioning policy, and compliance review expectations.
9898
9999
4. Consistency propagation checklist (convert prior checklist into active validations):
100-
- Read `.specify/templates/plan-template.md` and ensure any "Constitution Check" or rules align with updated principles.
101-
- Read `.specify/templates/spec-template.md` for scope/requirements alignment—update if constitution adds/removes mandatory sections or constraints.
102-
- Read `.specify/templates/tasks-template.md` and ensure task categorization reflects new or removed principle-driven task types (e.g., observability, versioning, testing discipline).
100+
101+
**Before reading any template, resolve the full effective template stack for each governed template type.**
102+
For each of the three governed templates — `plan-template`, `spec-template`, and `tasks-template` — perform this discovery:
103+
104+
a. **Discover all active layers** (in priority order):
105+
1. **Project-local override**: Check if `.specify/templates/<template-name>.md` exists. If so, include it.
106+
2. **Active preset-provided replacements**: List every subdirectory of `.specify/presets/` (if the directory exists).
107+
For each subdirectory, read `preset.yml` and look for entries under `provides.templates` where the `replaces`
108+
field matches `<template-name>`. For each matching entry, the preset-provided file path is
109+
`.specify/presets/<preset-id>/<file>` (the `file` field from `preset.yml`). Include all such files.
110+
3. **Core/built-in reference**: Note that the core template in the package itself is not directly editable
111+
by the agent; treat it as the canonical reference for constitutional guidance.
112+
113+
b. **Propagate constitutional guidance to every discovered layer** (project-local overrides and preset-provided
114+
replacements). For each discovered file:
115+
- Read the file.
116+
- Ensure any "Constitution Check" sections, rules, task categories, or scope/requirements constraints align
117+
with the updated principles.
118+
- Preserve the file's existing structure, specialized content, and provider-specific generation behavior —
119+
do **not** overwrite provider-specific sections with generic content from a different layer.
120+
- Write back only if changes are needed; otherwise mark as already-compliant.
121+
122+
c. **Fallback (no active layers found)**: If no project-local override or preset-provided replacement exists for
123+
a template, note in the Sync Impact Report that no installed copy was found and the core template (read-only)
124+
is the effective source.
125+
126+
After resolving all three template types, also:
103127
- Read each installed Spec Kit command file for your agent (including this one) — named `speckit.*` or `speckit-*` (dot or hyphen depending on the agent), or laid out as `speckit-<name>/SKILL.md` for skills-based integrations, e.g. in `.github/agents/`, `.github/skills/`, `.claude/skills/`, or your agent's equivalent commands directory — to verify no outdated references (CLAUDE-only or other agent-specific names) remain when generic guidance is required.
104128
- Read any runtime guidance docs (e.g., `README.md`, `docs/quickstart.md`, or agent-specific guidance files if present). Update references to principles changed.
105129
@@ -108,7 +132,11 @@ Follow this execution flow:
108132
- List of modified principles (old title → new title if renamed)
109133
- Added sections
110134
- Removed sections
111-
- Templates requiring updates (✅ updated / ⚠ pending) with file paths
135+
- Templates requiring updates (✅ updated / ⚠ pending / ✗ not found) — list **every** resolved template layer
136+
from step 4 (project-local overrides and preset-provided replacements) with its file path and provider
137+
(e.g., "project override", "preset: <preset-id>"). A template must only be marked ✅ updated if it was
138+
actually reviewed and either modified or explicitly verified as already compliant during this run. Templates
139+
that were not reviewed in this run must be marked ⚠ pending.
112140
- Follow-up TODOs if any placeholders intentionally deferred.
113141
114142
6. Validation before final output:

0 commit comments

Comments
 (0)