Skip to content

Commit 3570dc1

Browse files
Enhance workflow and iteration support across commands
- Updated implement.prompt.md to include workflow modes (Local and Fork) and iteration support for task completion tracking. - Enhanced plan.prompt.md with workflow modes, iteration detection, and refined task generation based on existing plans. - Improved specify.prompt.md to support fork contributions, detailed branch naming, and specification writing/updating processes. - Modified tasks.prompt.md to incorporate workflow modes, iteration detection, and task updating mechanisms. - Refined create-new-feature.ps1 script to manage branch creation based on current branch context and existing feature detection. - Added a new constitution-template.md for project governance and principles documentation. - Removed obsolete spec.md for the Merge CI and Main Workflows feature.
1 parent c60b819 commit 3570dc1

File tree

8 files changed

+486
-206
lines changed

8 files changed

+486
-206
lines changed

.github/prompts/constitution.prompt.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Create or update the project constitution from interactive or provided principle inputs, ensuring all dependent templates stay in sync.
2+
description: Create (if absent) or iteratively update the project constitution from interactive or provided inputs, ensuring all dependent templates stay in sync.
33
---
44

55
# Constitution
@@ -10,15 +10,49 @@ User input:
1010

1111
$ARGUMENTS
1212

13-
You are updating the project constitution at `.specify/memory/constitution.md`. This file is a TEMPLATE containing placeholder tokens in square brackets (e.g. `[PROJECT_NAME]`, `[PRINCIPLE_1_NAME]`). Your job is to (a) collect/derive concrete values, (b) fill the template precisely, and (c) propagate any amendments across dependent artifacts.
13+
**Note**: This command operates on the local repository's constitution and does not typically require fork-specific logic, as constitutional changes are usually made within the repository itself rather than targeting upstream repositories.
14+
15+
You are (a) creating or (b) iterating on the project constitution at `.specify/memory/constitution.md`.
16+
17+
Two operating modes:
18+
19+
1. Initial Creation Mode (constitution file does NOT exist):
20+
- Copy `.specify/templates/constitution-template.md` to `.specify/memory/constitution.md` verbatim before processing.
21+
- Treat the copied file as a TEMPLATE containing placeholder tokens in square brackets (e.g. `[PROJECT_NAME]`, `[PRINCIPLE_1_NAME]`).
22+
- Produce an initial version (default `1.0.0` unless the user specifies otherwise). Ratification date = today (unless user supplies one). Last amended date = same as ratification.
23+
2. Iteration Mode (constitution file already exists):
24+
- Load the existing `.specify/memory/constitution.md` (NOT the template) as the authoritative current constitution.
25+
- Do NOT re-copy the template. Only reference the template to discover any NEW placeholders/sections that could be adopted.
26+
- Identify new functionality / sections / principles requested (from user input or arguments) and integrate them.
27+
- If a new principle or governance rule appears to REPLACE or substantially OVERLAP an existing one, generate a Replacement Analysis Table and request user confirmation before destructive changes. If interactive confirmation is not possible in this run, mark the affected original item with `TODO(REVIEW_REPLACEMENT): Proposed replacement: <new title>` and include in the Sync Impact Report under deferred actions.
28+
- Preserve original ratification date. Increment version per rules below. Update last amended date to today if any material change occurs.
29+
30+
Replacement Analysis Table (when overlap detected):
31+
32+
| Existing Item | Proposed New / Change | Overlap Basis | Suggested Action |
33+
|---------------|-----------------------|---------------|------------------|
34+
| <title / section> | <incoming title / change> | e.g. semantic similarity, scope duplication | Replace / Merge / Keep Both |
35+
36+
Heuristics for overlap:
37+
- Title similarity score (case-insensitive) >= 0.6 (rough string similarity) OR
38+
- >50% of bullet rules conceptually duplicate (same verbs/nouns) OR
39+
- Governance rule introduces stricter variant of an existing rule.
40+
41+
If ambiguity remains, prefer non-destructive addition plus TODO marker.
1442

1543
Follow this execution flow:
1644

17-
1. Load the existing constitution template at `.specify/memory/constitution.md`.
18-
- Identify every placeholder token of the form `[ALL_CAPS_IDENTIFIER]`.
19-
**IMPORTANT**: The user might require less or more principles than the ones used in the template. If a number is specified, respect that - follow the general template. You will update the doc accordingly.
45+
0. Existence Check & Mode Selection:
46+
- If `.specify/memory/constitution.md` is missing → enter Initial Creation Mode (copy template, then proceed).
47+
- If it exists → Iteration Mode (operate directly on existing file; treat remaining bracket tokens, if any, as still-to-be-resolved placeholders).
48+
49+
1. Load Source Document:
50+
- Creation Mode: load freshly copied `.specify/memory/constitution.md` (formerly the template).
51+
- Iteration Mode: load existing `.specify/memory/constitution.md` and independently load `.specify/templates/constitution-template.md` only to detect any NEW placeholders/sections not yet present.
52+
- Identify every placeholder token `[ALL_CAPS_IDENTIFIER]` still unresolved in the working constitution (not just in template).
53+
- IMPORTANT: User may request changing the number of principles. Respect explicit user instruction; re-number or re-label as needed (maintain Roman numeral style if already in use; otherwise adopt consistent scheme).
2054

21-
2. Collect/derive values for placeholders:
55+
2. Collect/derive values for placeholders (and new/changed content):
2256
- If user input (conversation) supplies a value, use it.
2357
- Otherwise infer from existing repo context (README, docs, prior constitution versions if embedded).
2458
- For governance dates: `RATIFICATION_DATE` is the original adoption date (if unknown ask or mark TODO), `LAST_AMENDED_DATE` is today if changes are made, otherwise keep previous.
@@ -28,34 +62,39 @@ Follow this execution flow:
2862
* PATCH: Clarifications, wording, typo fixes, non-semantic refinements.
2963
- If version bump type ambiguous, propose reasoning before finalizing.
3064

31-
3. Draft the updated constitution content:
65+
3. Draft / Merge updated constitution content:
66+
- In Iteration Mode, integrate new principles/sections with minimal disruption:
67+
* Retain stable identifiers (e.g., keep existing principle numbering unless renumbering is explicitly required or gaps introduced by removals).
68+
* When replacing, either (a) fully substitute content if user confirmed or (b) append revised content and mark old with `DEPRECATED:` prefix plus TODO for removal in a future major version.
3269
- Replace every placeholder with concrete text (no bracketed tokens left except intentionally retained template slots that the project has chosen not to define yet—explicitly justify any left).
3370
- Preserve heading hierarchy and comments can be removed once replaced unless they still add clarifying guidance.
3471
- Ensure each Principle section: succinct name line, paragraph (or bullet list) capturing non‑negotiable rules, explicit rationale if not obvious.
3572
- Ensure Governance section lists amendment procedure, versioning policy, and compliance review expectations.
3673

3774
4. Consistency propagation checklist (convert prior checklist into active validations):
38-
- Read `.specify/templates/plan-template.md` and ensure any "Constitution Check" or rules align with updated principles.
39-
- Read `.specify/templates/spec-template.md` for scope/requirements alignment—update if constitution adds/removes mandatory sections or constraints.
40-
- Read `.specify/templates/tasks-template.md` and ensure task categorization reflects new or removed principle-driven task types (e.g., observability, versioning, testing discipline).
41-
- Read each command file in `.specify/templates/commands/*.md` (including this one) to verify no outdated references (agent-specific names like CLAUDE only) remain when generic guidance is required.
75+
- Read [`.specify/templates/plan-template.md`](../../.specify/templates/plan-template.md) and ensure any "Constitution Check" or rules align with updated principles.
76+
- Read [`.specify/templates/spec-template.md`](../../.specify/templates/spec-template.md) for scope/requirements alignment—update if constitution adds/removes mandatory sections or constraints.
77+
- Read [`.specify/templates/tasks-template.md`](../../.specify/templates/tasks-template.md) and ensure task categorization reflects new or removed principle-driven task types (e.g., observability, versioning, testing discipline).
78+
- Read each related prompt file in `.github/prompts/` (including this one) to verify no outdated agent-specific references remain (e.g., names tied to a specific LLM vendor) when generic guidance is required.
4279
- Read any runtime guidance docs (e.g., `README.md`, `docs/quickstart.md`, or agent-specific guidance files if present). Update references to principles changed.
4380

4481
5. Produce a Sync Impact Report (prepend as an HTML comment at top of the constitution file after update):
4582
- Version change: old → new
4683
- List of modified principles (old title → new title if renamed)
4784
- Added sections
4885
- Removed sections
86+
- Deprecated (marked) sections pending removal
4987
- Templates requiring updates (✅ updated / ⚠ pending) with file paths
5088
- Follow-up TODOs if any placeholders intentionally deferred.
89+
- Replacement items needing confirmation (if any)
5190

5291
6. Validation before final output:
5392
- No remaining unexplained bracket tokens.
5493
- Version line matches report.
5594
- Dates ISO format YYYY-MM-DD.
5695
- Principles are declarative, testable, and free of vague language ("should" → replace with MUST/SHOULD rationale where appropriate).
5796

58-
7. Write the completed constitution back to `.specify/memory/constitution.md` (overwrite).
97+
7. Write the completed constitution back to [`.specify/memory/constitution.md`](../../.specify/memory/constitution.md) (overwrite). Never write to the template path during iteration.
5998

6099
8. Output a final summary to the user with:
61100
- New version and bump rationale.

.github/prompts/implement.prompt.md

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ User input:
1010

1111
$ARGUMENTS
1212

13-
1. Run `.specify/scripts/powershell/check-prerequisites.ps1 -Json -RequireTasks -IncludeTasks` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute.
13+
**Workflow Modes**: This command supports two modes:
14+
- **Local (default)**: Work with the current repository (origin). No special configuration needed.
15+
- **Fork**: Contribute to an upstream repository. Reads `.fork-info.json` created by `/specify`.
16+
17+
**Iteration Support**: This command supports iterative implementation - you can run it multiple times to complete remaining tasks, fix issues, or add refinements. Task completion state is tracked in tasks.md with [X] markers.
18+
19+
1. Run [`.specify/scripts/powershell/check-prerequisites.ps1 -Json -RequireTasks -IncludeTasks`](../../.specify/scripts/powershell/check-prerequisites.ps1) from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute.
1420

1521
2. Load and analyze the implementation context:
1622
- **REQUIRED**: Read tasks.md for the complete task list and execution plan
@@ -21,12 +27,18 @@ $ARGUMENTS
2127
- **IF EXISTS**: Read quickstart.md for integration scenarios
2228

2329
3. Parse tasks.md structure and extract:
30+
- **Detect iteration state**: Check task completion markers
31+
- Tasks marked [X] are complete - skip unless user requests changes
32+
- Tasks marked [ ] are pending - these need implementation
33+
- If all tasks are complete, check if user input requests additional work
2434
- **Task phases**: Setup, Tests, Core, Integration, Polish
2535
- **Task dependencies**: Sequential vs parallel execution rules
2636
- **Task details**: ID, description, file paths, parallel markers [P]
2737
- **Execution flow**: Order and dependency requirements
2838

2939
4. Execute implementation following the task plan:
40+
- **Skip completed tasks**: Don't re-implement tasks marked [X] unless explicitly requested
41+
- **Resume from last incomplete task**: Start with first [ ] task found
3042
- **Phase-by-phase execution**: Complete each phase before moving to the next
3143
- **Respect dependencies**: Run sequential tasks in order, parallel tasks [P] can run together
3244
- **Follow TDD approach**: Execute test tasks before their corresponding implementation tasks
@@ -56,9 +68,22 @@ $ARGUMENTS
5668
- Report final status with summary of completed work
5769

5870
8. Create or update Pull Request:
71+
- **Determine workflow mode and target repository**:
72+
- Check if `.fork-info.json` exists in the feature directory (same directory as spec.md)
73+
- **If exists** (fork mode):
74+
- Validate required fields: `is_fork` (true), `upstream_owner` (non-empty), `upstream_repo` (non-empty)
75+
- If validation fails, halt and instruct user: "Invalid fork configuration in `.fork-info.json`. Please run `/specify` again with complete fork information: upstream owner, upstream repo."
76+
- Use `upstream_owner/upstream_repo` for all GitHub operations
77+
- **If not exists** (local mode - default):
78+
- Use the current repository (origin) for all GitHub operations
79+
- **Determine PR operation**:
80+
- If PR already exists for this branch, UPDATE it (description, status, labels)
81+
- If no PR exists, CREATE a new one
5982
- **Target branch**: The PR must be against the default branch
6083
- **PR status**: The PR must not be draft, it should be ready for review
61-
- **Determine PR type and icon** based on the changes:
84+
- **Retrieve the issue title**: Get the title from the linked GitHub issue (created in `/specify`) from the target repository
85+
- **Use the same title for the PR**: Verify the PR title matches the issue title exactly. If they differ, update the PR title to match the issue.
86+
- If unable to retrieve the issue title, determine the PR type and icon based on the changes:
6287

6388
| Type of change | Icon | Label |
6489
|-|-|-|
@@ -69,20 +94,53 @@ $ARGUMENTS
6994
| Feature | 🚀 | Minor |
7095
| Breaking change | 🌟 | Major |
7196

72-
- **PR title format**: `<Icon> [Type of change]: <Short description>`
73-
- **PR description structure**:
74-
* Start with a summary paragraph describing the key outcome and changes for user
75-
* DO NOT add a title before the leading paragraph
76-
* At the end of the PR paragraph, add a "- Fixes #<issue-number>" line to link the PR to the issue
77-
* Follow with additional details answering Why, How, and What
78-
* Avoid superfluous headers or sections
79-
* We do not need details, we need to add what changes for the user of the code
97+
- Fallback PR title format (if issue title unavailable): `<Icon> [Type of change]: <Short description>`
98+
- **PR description structure** (formatted as a release note):
99+
* Start with a user-focused summary paragraph describing what's new, improved, or fixed
100+
* Write in past tense, focusing on capabilities and user benefits (e.g., "Added support for...", "Improved performance of...", "Fixed issue where...")
101+
* DO NOT add a title or heading before the leading paragraph
102+
* Keep the tone professional and concise - this will be read as a release note
103+
* At the end of the summary paragraph, add "- Fixes #<issue-number>" to link the PR to the issue
104+
* Follow with additional release-note style details:
105+
- **What's Changed**: Brief bullet points of key changes from the user's perspective
106+
- **Technical Details** (optional): Implementation notes if relevant for maintainers
107+
- **Breaking Changes** (if applicable): Clear warning and migration guidance
108+
- **Usage** (if applicable): Brief example or updated command syntax
109+
* Avoid superfluous headers, verbose explanations, or internal implementation details
110+
* Focus on what changes for the end user or developer using this code
80111
- **Apply appropriate label(s)** based on the type of change
81112
- **Link the PR** to the associated issue
113+
- **After PR updates**: Update `.fork-info.json` (if it exists) with the latest PR number (if not already present)
114+
115+
**GitHub Integration**: If GitHub tools or integrations are available (such as GitHub MCP Server or other GitHub integrations), use them to update the PR status and labels automatically in the target repository. If not available, provide these fallback commands with the correct repository:
116+
```bash
117+
# Mark PR as ready for review
118+
# If fork: gh pr ready <PR-number> --repo <upstream_owner>/<upstream_repo>
119+
# If local: gh pr ready <PR-number>
120+
gh pr ready <PR-number>
121+
122+
# Update PR title to match issue (if needed)
123+
gh pr edit <PR-number> --title "<Issue title>"
124+
125+
# Update labels
126+
gh pr edit <PR-number> --add-label "<Type>"
127+
```
82128

83129
9. Update issue labels:
84-
- Remove 'plan' label from the linked issue
130+
- **Determine target repository** (same logic as step 8):
131+
- Check if `.fork-info.json` exists in the feature directory
132+
- If it exists and validated, use `upstream_owner/upstream_repo`
133+
- If it doesn't exist, use the current repository (origin)
134+
- Remove 'plan' label from the linked issue in the target repository
85135
- Add 'implement' label to the linked issue
136+
- **After updating labels**: Ensure `.fork-info.json` (if it exists) has the issue number stored
137+
138+
**GitHub Integration**: If GitHub tools are available, update labels automatically in the target repository. If not available, use:
139+
```bash
140+
# If fork: gh issue edit <issue-number> --repo <upstream_owner>/<upstream_repo> ...
141+
# If local: gh issue edit <issue-number> ...
142+
gh issue edit <issue-number> --remove-label "Plan" --add-label "Implementation"
143+
```
86144

87145
10. Update the constitution:
88146
- Read the [Constitution](../../.specify/memory/constitution.md) file.

0 commit comments

Comments
 (0)