Repository navigation
Description
Summary
Invoking /speckit.constitution with additional feature or implementation directives (e.g., “deliver a Todo app”) can cause the agent to both amend the constitution and generate application code in the same run. This couples governance changes with feature implementation and reduces auditability.
Current Behavior
If the operator runs a single message like:
/speckit.constitution Deliver a minimal, production‑style, React Router v7 Todo application
the agent may (depending on model interpretation) both:
- Update constitution.md
- Implement new application routes/components
Expected Behavior
The constitution command should:
- Perform only constitution update + template sync.
- Extract any non-constitution intents and present them as suggested follow-up commands (e.g., /speckit.specify ..., /speckit.plan ...).
- Never modify app source files directly.
Reproduction Steps
- Use a project with an unfilled or editable constitution.md template.
- Run the mixed directive shown above.
- Observe that new source files may be created in addition to constitution edits.
Impact
- Harder to review governance-only changes.
- Risk of unintentional code churn in regulated or audited environments.
- Inconsistent behavior (sometimes only constitution updates; other times dual action).
Root Cause
Prompt lacked an explicit single-task scope guard, allowing the LLM to merge independent imperatives.
Proposed Solution (Implemented and Tested Locally)
Added a SCOPE GUARD section to speckit.constitution.prompt.md:
- Forbids executing extra feature/code intents.
- Introduces an “extra intent extraction” heuristic.
- Adds a “Next Actions” section after constitution update summarizing suggested follow-up commands.
Example After Patch
Input:
/speckit.constitution Deliver a minimal, production‑style, React Router v7 Todo application
Output:
- Constitution updated only.
- “Next Actions”:
- Intent: Deliver a minimal, production‑style, React Router v7 Todo application
- Suggested Command: /speckit.specify minimal React Router v7 Todo application
Acceptance Criteria
- Mixed instruction invocation changes only constitution + synced templates.
- Extra intents listed; no feature code added.
- Guard text appears in prompt file.
- Maintainers confirm phrasing aligns with template style.
speckit.constitution.prompt.md
Follow-Up Recommendations
- Propagate similar guard to /speckit.plan, /speckit.specify, /speckit.tasks.
- Optionally add regression test harness for prompt behavior.
AI Assistance Disclosure
The issue text and the new SCOPE GUARD / intent extraction guard wording were generated with assistance from an AI coding agent and then human‑reviewed and validated.
Activity
RoyceLeonD commentedon Oct 20, 2025
In #967 I was working on guards since I had a different problem on getting speckit to have stronger declarative definition-of-done and did not think of this. Ideally I image this is a problem for the ai coding platform: Claudecode, cursor etc. and the template packer/unpacker here could have explicit mapping to each of those tools' front matter params. Like in claude the front matter allows you to explicitly disable edits https://docs.claude.com/en/docs/claude-code/slash-commands#frontmatter So if someone has a moment it would be trivial to make a matrix of each of the agents supported in spec kit and the their native way of tool whitelisting. With that someone should easily be able to put a PR. I would just ask whoever is doing this too post a matrix first, because it would also be vauable to quickly look at the other agents that people have feature requests and organize the work around "standardizing/extending-support for agenticcoder interop"
@localden do you think the following tasks are reasonable:
github-actions commentedon Jul 21, 2026
Bug assessment — constitution-scope-guard: Valid · severity medium
Bug Assessment: Constitution Command Scope Ambiguity
constitution-scope-guardReport (summarized)
Reported by @hmanicka. When a user invokes
/speckit.constitutionwith a mixed directive (e.g. "Deliver a minimal, production-style, React Router v7 Todo application"), the LLM agent may simultaneously updateconstitution.mdand generate application source code. The reporter has a local patch ready and has already attached a revised prompt file (speckit.constitution.prompt.md). A related comment from@RoyceLeonD(#896 comment) broadens the scope to native agent tool-whitelisting frontmatter across all supported coding agents.Symptom
When the constitution command receives an argument that contains both a governance intent and a feature-implementation intent, the LLM may execute both in the same run, producing new application code alongside the expected constitution update. Expected behavior is that only the constitution update occurs and any non-governance intents are surfaced as suggested follow-up commands.
Reproduction
constitution.mdcontaining unfilled placeholder tokens./speckit.constitution Deliver a minimal, production-style, React Router v7 Todo applicationconstitution.md.Suspected Code Paths
templates/commands/constitution.md:15— The lineYou **MUST** consider the user input before proceeding (if not empty)instructs the LLM to act on all user input without restriction; no guard limits actions to constitution-only tasks.templates/commands/constitution.md:1-7(frontmatterhandoffs) — Thehandoffsblock namesspeckit.specifyas a downstream action. While handoffs are presented as suggestions, some LLM interpretations may follow them eagerly when the user input sounds like a feature request, blurring the line between constitution governance and feature work.presets/lean/commands/speckit.constitution.md— The lean preset is even simpler and has no scope constraint at all (16 lines total), making the problem more pronounced for lean-preset users.templates/constitution-template.mdandpresets/self-test/templates/constitution-template.md— Indirectly relevant: once the LLM decides to "deliver" a feature it may treat the constitution as just one artifact in a broader scaffolding pass.Root Cause Hypothesis
The constitution command prompt relies on the LLM to infer from context that its job is governance-only, but provides no explicit prohibition against executing unrelated feature intents. The directive "You MUST consider the user input" is unconditional, and the
handoffsfrontmatter listingspeckit.specifymakes it structurally plausible for the LLM to chain into feature implementation. This is a prompt-engineering gap: without an explicit scope guard, the LLM applies a liberal interpretation and merges independent imperatives into a single run. Confidence: high — the template text is present in the repo and the permissive phrasing is demonstrable.Proposed Remediation
Preferred: Add a
## Scope Guardsection near the top oftemplates/commands/constitution.md(immediately after the User Input block, before Pre-Execution Checks) that:$ARGUMENTSfor non-governance intents, extract them, and after the constitution update emit a "Next Actions" section listing each extracted intent alongside the appropriate follow-up Spec Kit command (e.g.,/speckit.specify ...).presets/lean/commands/speckit.constitution.md.The reporter's attached patch (
speckit.constitution.prompt.md) can serve as the starting point — maintainers should review the wording for consistency with existing template style before merging.Alternatives:
@RoyceLeonD): Use agent-native frontmatter fields (e.g., Claude Code'sallowed_tools/disallowed_tools) to restrict file-write access at the platform level. This is more robust but requires a per-agent capability matrix and is a larger cross-cutting effort; it should be tracked separately and does not preclude the prompt-level guard..specify/files were written and warns the user. This is weaker than prevention but detectable.Files likely to change:
templates/commands/constitution.mdpresets/lean/commands/speckit.constitution.mdpresets/self-test/equivalent if one exists for this commandTests to add or update:
presets/self-test/structure) that invokes the constitution command with a mixed directive and asserts that no application source files are created and that a "Next Actions" block appears in the output.self-testpreset covers the constitution command path at all; if not, add a basic fixture.Risks & Considerations
constitution.mdfiles in user projects are unaffected.Open Questions
handoffsfrontmatter entry forspeckit.specifybe removed or kept? It is a structural invitation for chaining that may conflict with the scope guard's intent.]@RoyceLeonD's suggestion to build a capability matrix for native tool-whitelisting is broader than this issue — should it be tracked in a dedicated issue?]Posted on behalf of
@BenBtgby GitHub Copilot (model: claude-sonnet-4.6, autonomous)github-actions commentedon Jul 22, 2026
Bug test — constitution-scope-guard: ✅ passing · 2 passed, 0 failed, 0 skipped · fix from PR #3646 (branch
benbtg-fix-896-constitution-scope-guard, head9fd5b39)Bug Test Report: Constitution Command Scope Guard
constitution-scope-guardbenbtg-fix-896-constitution-scope-guard(head SHA9fd5b39)python3 -m pytest tests/test_presets.py -q -k 'constitution_commands_guard'(executed as manual assertion verification — see Notes)test_constitution_commands_guard_against_non_governance_work[core]andtest_constitution_commands_guard_against_non_governance_work[lean]Summary
Both parametrized variants of
test_constitution_commands_guard_against_non_governance_workpass against the fix. The scope guard text is present and correct in bothtemplates/commands/constitution.md(core) andpresets/lean/commands/speckit.constitution.md(lean), confirming that the fix addresses the prompt-engineering gap described in the issue.Test Results
Failures (if any)
None.
Assertion Detail
Each assertion was verified by executing them directly in Python against the checked-out files. All 9 per-case assertions passed for both
coreandlean:## Scope Guardpresent**MUST NOT**presentClassify every partpresentapplication source filespresentnon-governance intentpresent`Next Actions`present__SPECKIT_COMMAND_SPECIFY__presentomitin content (lowercased)do not invoke itorwithout invoking itpresentVerification vs. Historical Fix
Not applicable (no historical fix referenced — this is an open issue with a proposed fix under review).
Notes & Caveats
hatchlingandpytestcould not be installed viapip. The tests were therefore executed by directly evaluating the test assertions in Python against the target files, rather than viapytestproper. All assertions were drawn verbatim fromtests/test_presets.pylines 5407–5419.python3available at test time was PyPy 3.11 (from/opt/hostedtoolcache/PyPy/3.11.15/x64/bin/python3); the assertion logic requires onlypathlib.Path.read_text()with no third-party dependencies, so the interpreter difference does not affect validity.templates/commands/constitution.mdandpresets/lean/commands/speckit.constitution.md). Nopresets/self-test/equivalent for the constitution command was found; the assessment noted this gap and flagged it as a potential addition — it is not covered by the current fix or tests.