Skip to content

Commit 6d9421b

Browse files
authored
Merge branch 'develop' into AI-1153
2 parents 6befb1f + bd5380e commit 6d9421b

45 files changed

Lines changed: 5396 additions & 5 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/skills/requirements-refiner/SKILL.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ description: "Requirements Refiner: Iteratively questions the user to clarify va
1717
- This document should include the initial requirements plus all details gathered during the Q&A process.
1818
- Ensure the output is structured and ready for a User Story writer to consume.
1919
4. **Save to feature-docs**:
20-
- Examine the `feature-docs/` directory to find the highest numbered folder (e.g., `001-graph-workflows`).
21-
- Determine the next increment number (e.g., if `001` exists, use `002`).
20+
- Generate a datetime stamp in the format `YYYYMMDDHHmmss` (same format as Prisma migrations) using the current UTC time.
2221
- Generate a short feature name/slug (kebab-case, e.g., "benchmarking-system").
23-
- Create a new folder: `feature-docs/{NNN}-{feature-slug}/` (e.g., `feature-docs/002-benchmarking-system/`).
22+
- Create a new folder: `feature-docs/{YYYYMMDDHHmmss}-{feature-slug}/` (e.g., `feature-docs/20260313143022-benchmarking-system/`).
2423
- Save the consolidated requirements as `REQUIREMENTS.md` in that folder.
2524

2625
## Key Behaviors
2726
- **Iterative Approach**: Do not rush to the final output. Prioritize clarity over speed.
2827
- **Probe Deeply**: Ask about edge cases, error states, and user roles.
29-
- **Auto-increment Folders**: Always check existing feature-docs folders to determine the next number.
30-
- **Output Format**: The final output must be saved as `feature-docs/{NNN}-{feature-slug}/REQUIREMENTS.md`.
28+
- **Datetime-stamped Folders**: Use the current UTC time in `YYYYMMDDHHmmss` format as the folder prefix.
29+
- **Output Format**: The final output must be saved as `feature-docs/{YYYYMMDDHHmmss}-{feature-slug}/REQUIREMENTS.md`.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
name: story-implementer
3+
description: "Implements user stories from a user_stories directory in dependency order using subagents. Reads README.md to find the next unchecked story, spawns Agent tool subagents to implement each one, tracks progress via scenario checkboxes in story files and story checkboxes in README. Trigger phrases: implement stories, implement user stories, story implementer, work on stories, implement next story. Do NOT invoke for: writing user stories (use write-user-stories), general code changes, checklist execution."
4+
---
5+
6+
Implement user stories from: $ARGUMENTS
7+
8+
**Role**: You are an implementation orchestrator. You read a user stories README.md, identify the next unimplemented story, and dispatch subagents to implement them one at a time in dependency order.
9+
10+
## Input
11+
12+
$ARGUMENTS should be a path to either:
13+
- A `user_stories/README.md` file, OR
14+
- A `user_stories/` directory (read README.md inside it), OR
15+
- A feature-docs directory containing a `user_stories/` subfolder
16+
17+
If no argument is provided, look for the most recently modified directory under `feature-docs/` that contains `user_stories/README.md`.
18+
19+
## Orchestration Algorithm
20+
21+
### Step 1: Read README.md and locate context
22+
23+
1. Read the `user_stories/README.md` file
24+
2. Extract the path to the requirements document from the NOTE line at the top
25+
3. Identify the base directory (the parent of `user_stories/`)
26+
27+
### Step 2: Find the next unchecked story
28+
29+
1. Go to the "Suggested Implementation Order" section
30+
2. Find the first line matching `- [ ] **US-XXX**`
31+
3. Extract the story ID (e.g., `US-001`)
32+
4. If no unchecked stories remain, report completion to the user and stop
33+
34+
### Step 3: Read the story file and assess size
35+
36+
1. Find the story file matching the ID in the `user_stories/` directory (e.g., `US-001-*.md`)
37+
2. Read the story file
38+
3. Count the number of `- [ ]` scenario checkboxes in the Acceptance Criteria section
39+
4. Decide the implementation strategy:
40+
- **8 or fewer unchecked scenarios**: Send ALL to a single subagent
41+
- **More than 8 unchecked scenarios**: Split into batches of 4-6 scenarios, send to sequential subagents
42+
43+
### Step 4: Dispatch subagent(s)
44+
45+
Read the workflow template from `.claude/skills/story-implementer/Workflows/implement-story.md` and construct the subagent prompt by substituting the variables.
46+
47+
Use the **Agent tool** to spawn the subagent. Pass the constructed prompt as the `prompt` parameter.
48+
49+
**For a single subagent (all scenarios fit):**
50+
- Pass the full story file content
51+
- Pass the requirements document path
52+
- Pass the list of ALL scenario numbers to implement
53+
- Pass the story file path (so subagent can check off scenarios)
54+
55+
**For batched scenarios:**
56+
- For each batch:
57+
- Pass the full story file content
58+
- Pass the requirements document path
59+
- Pass the specific scenario numbers for THIS batch only (e.g., "Scenarios 1-4")
60+
- Pass the story file path
61+
- Add batch note: "This is batch N of M. Only implement the specified scenarios."
62+
- After each batch subagent completes, re-read the story file to verify the scenarios were checked off
63+
- Then dispatch the next batch
64+
65+
### Step 5: Verify story completion
66+
67+
After the subagent(s) finish:
68+
1. Re-read the story file
69+
2. Verify ALL scenario checkboxes are `[x]`
70+
3. If any scenarios remain unchecked, report which ones to the user and ask whether to retry or skip
71+
72+
### Step 6: Mark story complete and commit
73+
74+
1. In `user_stories/README.md`, change the line `- [ ] **US-XXX**` to `- [x] **US-XXX**`
75+
2. Stage all changes and commit with message: `feat: implement US-XXX - <story title>`
76+
- Include `Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>`
77+
3. Report to the user: which story was completed, summary of what was implemented
78+
79+
### Step 7: Loop
80+
81+
Return to Step 2 to find the next unchecked story. Continue until all stories are implemented or the user interrupts.
82+
83+
## Rules
84+
85+
- Implement stories strictly in the order listed in the README (respect dependency chain)
86+
- Never skip a story without user approval
87+
- Always re-read README.md fresh before each iteration (it may have been modified)
88+
- Each subagent MUST follow all CLAUDE.md rules (tests for backend, proper typing, no placeholders, update docs-md)
89+
- Auto-commit after each STORY (not each scenario)
90+
- If a subagent encounters a question or ambiguity, it should surface it to the user rather than making assumptions
91+
- Do not modify the story file format beyond checking off scenario checkboxes
92+
- The orchestrator never implements code directly — always delegate to subagents via Agent tool
93+
94+
## Workflow Reference
95+
96+
- [Implement a single story](Workflows/implement-story.md) — subagent prompt template for implementing scenarios within a story
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Implement Story Scenarios
2+
3+
This workflow is used by the story-implementer orchestrator. The orchestrator reads this file and substitutes the variables below before passing to the Agent tool.
4+
5+
## Subagent Prompt Template
6+
7+
The Agent tool should be invoked with a prompt constructed as follows:
8+
9+
---
10+
11+
You are implementing a user story for this project. Follow ALL rules in CLAUDE.md strictly.
12+
13+
### Your Assignment
14+
15+
**Story**: {STORY_ID} - {STORY_TITLE}
16+
17+
**Scenarios to implement**: {SCENARIO_LIST}
18+
19+
**Story file path**: {STORY_FILE_PATH}
20+
21+
**Requirements document**: Read the requirements at {REQUIREMENTS_PATH} for full context.
22+
23+
### Story Content
24+
25+
{FULL_STORY_FILE_CONTENT}
26+
27+
### Implementation Instructions
28+
29+
1. Read the requirements document at {REQUIREMENTS_PATH} for full project context
30+
2. Read CLAUDE.md for project rules you must follow
31+
3. For each scenario in your assignment:
32+
a. Read the Given/When/Then carefully
33+
b. Explore the codebase to understand where changes are needed
34+
c. Implement the scenario fully (no stubs, no placeholders)
35+
d. For backend changes: create/update tests and run them (`npm run test` from the relevant app directory)
36+
e. For frontend changes: run typecheck (`npm run typecheck`)
37+
f. After the scenario is fully working, edit {STORY_FILE_PATH} and change that scenario's `- [ ]` to `- [x]`
38+
4. After all assigned scenarios are complete, provide a summary of:
39+
- Files created or modified
40+
- Tests added or updated
41+
- Any gaps or questions that came up (per CLAUDE.md: do not assume, report gaps)
42+
43+
### Rules You Must Follow
44+
45+
- Implement ONLY the scenarios assigned to you, not others
46+
- Check off EACH scenario in the story file as you complete it (change `- [ ]` to `- [x]`)
47+
- Do NOT modify the README.md (the orchestrator handles that)
48+
- Do NOT commit (the orchestrator handles commits)
49+
- Follow all CLAUDE.md rules: no "any" types, no placeholders, create tests for backend, update docs-md, no document-specific implementations
50+
- If you need to run `npx prisma generate`, use `npm run db:generate` from `apps/backend-services`
51+
- If something is ambiguous or unclear, stop and ask the user rather than guessing
52+
- Do not add backwards compatibility features
53+
- The system is generic and must support arbitrary workloads
54+
55+
{BATCH_NOTE}
56+
57+
---
58+
59+
## Variable Reference
60+
61+
| Variable | Source |
62+
|----------|--------|
63+
| STORY_ID | Extracted from story filename (e.g., US-001) |
64+
| STORY_TITLE | First heading in story file |
65+
| SCENARIO_LIST | "All scenarios" or "Scenarios 1-4" etc. |
66+
| STORY_FILE_PATH | Absolute path to the story .md file |
67+
| REQUIREMENTS_PATH | Extracted from README.md NOTE line |
68+
| FULL_STORY_FILE_CONTENT | Complete contents of the story .md file |
69+
| BATCH_NOTE | Empty string for single subagent, or "This is batch N of M. Only implement the specified scenarios. Check off each scenario as you complete it." for batched |
70+
71+
## Common Pitfalls
72+
73+
- Forgetting to check off scenarios in the story file — the orchestrator relies on these checkboxes to verify completion
74+
- Committing changes — the subagent must NOT commit; the orchestrator does this after verifying all scenarios
75+
- Modifying README.md — the subagent must NOT touch the README; only the orchestrator updates it
76+
- Making assumptions about unclear requirements — always surface questions to the user

.claude/skills/write-user-stories/SKILL.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Generate user stories from: $ARGUMENTS
1212
2. **Decompose**: Break the requirements down into individual, independent User Stories.
1313
3. **Draft**: Write each User Story using the strictly defined template at `.claude/skills/write-user-stories/user_story_template.md`.
1414
- Ensure each story has a clear Title, Description, and Acceptance Criteria.
15+
- **Keep each story to 4-6 acceptance criteria scenarios maximum.** If a requirement naturally produces more than 6 scenarios, split it into multiple stories (e.g., sequential US numbers) preserving full detail across the split. Never sacrifice detail — distribute it across more stories instead.
16+
- Each scenario must be independently implementable — a scenario's Given/When/Then should not depend on another scenario within the same story being implemented first. Cross-story dependencies are captured in the phase ordering.
17+
- Ensure scenario checkboxes use exactly the format `- [ ] **Scenario N**: Title` (with the space inside brackets and bold scenario label) for consistent automated parsing.
1518
- Organize stories into logical phases/groups based on dependencies and priority.
1619
4. **Output**:
1720
- Create a `user_stories` subfolder **in the same directory as the requirements file**.
@@ -67,6 +70,10 @@ After implementing the user story check it off at the bottom of this file
6770
### Phase 2
6871
- [ ] **US-002** (brief description)
6972
- [ ] **US-003** (brief description)
73+
74+
> Stories are ordered by dependency chain for automated implementation.
75+
> Each story should be implementable after all stories in previous phases are complete.
76+
> Do not start a phase until all stories in prior phases are checked off.
7077
```
7178

7279
## Key Behaviors
@@ -75,3 +82,6 @@ After implementing the user story check it off at the bottom of this file
7582
- **Same Directory Organization**: Create the `user_stories` subfolder in the same directory as the requirements file.
7683
- **Comprehensive README**: Always generate the README.md with complete phase breakdown and tracking checkboxes.
7784
- **Logical Phases**: Organize implementation phases based on technical dependencies and priorities from the requirements.
85+
- **Scenario Size Limit**: Keep each story to 4-6 acceptance criteria scenarios maximum. If a requirement naturally has more, split into multiple stories preserving full detail — never sacrifice detail, distribute it across more stories.
86+
- **Atomic Scenarios**: Each scenario must be independently implementable within its story. No intra-story scenario dependencies.
87+
- **Consistent Checkbox Format**: Scenario checkboxes must use exactly `- [ ] **Scenario N**: Title` for automated parsing by the story-implementer skill.

.claude/skills/write-user-stories/user_story_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
**So that** [Benefit/Value].
66

77
## Acceptance Criteria
8+
<!-- Keep to 4-6 scenarios max. Each scenario should be independently implementable. -->
89
- [ ] **Scenario 1**: [Title]
910
- **Given** [Context]
1011
- **When** [Action]
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build Instance Images
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: "Branch to build images from (defaults to the branch the workflow is triggered on)"
8+
required: false
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_BASE: ghcr.io/${{ github.repository }}
18+
19+
jobs:
20+
metadata:
21+
name: Prepare Build Metadata
22+
runs-on: ubuntu-latest
23+
outputs:
24+
sanitized-branch: ${{ steps.branch-info.outputs.sanitized }}
25+
commit-sha: ${{ steps.branch-info.outputs.sha }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ inputs.branch || github.ref }}
31+
32+
- name: Compute branch name and SHA
33+
id: branch-info
34+
run: |
35+
# Resolve the branch name from inputs or the current ref
36+
RAW_BRANCH="${{ inputs.branch || github.ref_name }}"
37+
38+
# Sanitize for container image tags: lowercase, replace non-alphanumeric
39+
# sequences with a single hyphen, trim leading/trailing hyphens,
40+
# and truncate to 128 characters (OCI tag length limit)
41+
SANITIZED=$(echo "$RAW_BRANCH" \
42+
| tr '[:upper:]' '[:lower:]' \
43+
| sed 's/[^a-z0-9._-]/-/g' \
44+
| sed 's/--*/-/g' \
45+
| sed 's/^-//;s/-$//' \
46+
| cut -c1-128)
47+
48+
SHA=$(git rev-parse HEAD)
49+
50+
echo "sanitized=$SANITIZED" >> "$GITHUB_OUTPUT"
51+
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
52+
echo "Branch: $RAW_BRANCH -> Tag: $SANITIZED"
53+
echo "Commit SHA: $SHA"
54+
55+
build:
56+
name: Build ${{ matrix.service }}
57+
needs: [metadata]
58+
runs-on: ubuntu-latest
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
include:
63+
- service: backend-services
64+
context: "."
65+
dockerfile: apps/backend-services/Dockerfile
66+
- service: frontend
67+
context: apps/frontend
68+
dockerfile: apps/frontend/Dockerfile
69+
- service: temporal
70+
context: "."
71+
dockerfile: apps/temporal/Dockerfile
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
with:
76+
ref: ${{ inputs.branch || github.ref }}
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Log in to GitHub Container Registry
82+
uses: docker/login-action@v3
83+
with:
84+
registry: ${{ env.REGISTRY }}
85+
username: ${{ github.actor }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Cache Docker layers
89+
uses: actions/cache@v4
90+
with:
91+
path: /tmp/.buildx-cache
92+
key: ${{ runner.os }}-buildx-instance-${{ matrix.service }}-${{ github.sha }}
93+
restore-keys: |
94+
${{ runner.os }}-buildx-instance-${{ matrix.service }}-
95+
96+
- name: Build and push image
97+
uses: docker/build-push-action@v5
98+
with:
99+
context: ${{ matrix.context }}
100+
file: ${{ matrix.dockerfile }}
101+
push: true
102+
tags: |
103+
${{ env.IMAGE_BASE }}/${{ matrix.service }}:${{ needs.metadata.outputs.sanitized-branch }}
104+
${{ env.IMAGE_BASE }}/${{ matrix.service }}:${{ needs.metadata.outputs.commit-sha }}
105+
labels: |
106+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
107+
org.opencontainers.image.revision=${{ needs.metadata.outputs.commit-sha }}
108+
cache-from: type=local,src=/tmp/.buildx-cache
109+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
110+
111+
- name: Rotate cache
112+
run: |
113+
rm -rf /tmp/.buildx-cache
114+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ feature-docs/*/playwright/screenshots/
1515
# Backend logs
1616
apps/backend-services/backend.log
1717
/packages/logging/dist
18+
19+
# OpenShift deployment tooling
20+
.oc-deploy-token
21+
backups/

0 commit comments

Comments
 (0)