Skip to content

Commit 6155336

Browse files
authored
Merge pull request #23 from flightctl/andalton/implement-workflow
Add implement workflow for AI-assisted story implementation
2 parents 9a5c00f + 7d67846 commit 6155336

20 files changed

Lines changed: 2532 additions & 0 deletions

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This repository contains reusable AI coding workflows that can be installed glob
1515
- **cve-fix** — Automated CVE remediation from Jira tickets (start, patch, validate, pr, backport, close)
1616
- **prd** — Requirements-to-PRD workflow (ingest, clarify, draft, revise, publish, respond)
1717
- **design** — Design-and-decompose workflow (ingest, draft, decompose, revise, publish, respond, sync)
18+
- **implement** — Story-to-code workflow (ingest, plan, revise, code, validate, publish, respond)
1819
- **kcs** — KCS Solution article workflow (gather, draft, validate, handoff)
1920

2021
## Architecture
@@ -58,6 +59,7 @@ Workflows write outputs to `.artifacts/{workflow-name}/{context}/`:
5859
- **cve-fix**: `.artifacts/cve-fix/{context}/` (context.md, patch-log.md, validation-results.md, pr-description.md, backport-log.md, close-report.md)
5960
- **prd**: `.artifacts/prd/{issue-number}/` (01-requirements.md, 02-clarifications.md, 03-prd.md, 04-pr-description.md, 05-review-responses.md)
6061
- **design**: `.artifacts/design/{issue-number}/` (01-context.md, 02-design.md, 03-epics.md, 04-stories/epic-{N}-{slug}.md, 04-stories/epic-{N}/story-{NN}-{slug}.md, 05-coverage.md, 06-pr-description.md, 07-review-responses.md, publish-metadata.json, sync-manifest.json)
62+
- **implement**: `.artifacts/implement/{jira-key}/` (01-context.md, 02-plan.md, 03-test-report.md, 04-impl-report.md, 05-validation-report.md, 06-pr-description.md, 07-review-responses.md, publish-metadata.json)
6163
- **kcs**: `.artifacts/kcs/{issue-key}/` (01-context.md, 02-kcs-draft.md, 03-handoff-message.md)
6264

6365
## Prerequisites
@@ -73,6 +75,7 @@ Workflows write outputs to `.artifacts/{workflow-name}/{context}/`:
7375
- **cve-fix**: Jira MCP server or Jira CLI (`jira`), GitHub CLI (`gh`), optionally `skopeo` for container image verification
7476
- **prd**: Jira MCP server — for requirements ingestion; GitHub CLI (`gh`) — for PR creation and review comment management
7577
- **design**: Jira MCP server or CLI — for `/ingest` (read-only) and `/sync` (creates epics/stories); GitHub CLI (`gh`) — for `/publish` and `/respond`
78+
- **implement**: Jira MCP server or CLI — for `/ingest` (read-only); GitHub CLI (`gh`) — for `/publish` and `/respond`; project build/test/lint tooling (discovered during `/ingest`); docs repo (local clone) — for `/ingest` (reads PRD and design document)
7679
- **kcs**: Jira MCP server — for `/gather` (read-only)
7780

7881
## Installation System
@@ -180,6 +183,16 @@ For detailed workflow development guidelines (structure, file conventions, testi
180183
- Design doc template and section guidance live in `templates/` with project-level override support
181184
- Each story must include functionality AND testing (no deferred test stories)
182185

186+
### implement
187+
188+
- Requires a Jira Story (typically created by the design workflow's `/sync` phase) as input
189+
- Jira is read-only — no phase in this workflow writes to Jira
190+
- Discovery-based validation: build, test, lint, and coverage commands are discovered during `/ingest` from the project's AGENTS.md, Makefile, and CI workflows — not hardcoded
191+
- Contract-based testing: tests validate behavioral contracts through public interfaces; unit tests always required, integration tests required when the story touches component interactions
192+
- Incremental commits prefixed with Jira key — no squashing, each commit independently meaningful for backporting
193+
- Plan evolves during implementation — `02-plan.md` is updated as tasks complete, enabling resumption after interruptions
194+
- Code changes happen in the source repo on a feature branch; `/publish` creates a PR in the source repo (not a separate docs repo)
195+
183196
### kcs
184197

185198
- Requires Jira MCP server for `/gather` (read-only — never modifies Jira)
@@ -252,6 +265,7 @@ ai-workflows/
252265
├── cve-fix/
253266
├── design/
254267
├── docs-writer/
268+
├── implement/
255269
├── kcs/
256270
├── prd/
257271
├── skill-reviewer/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Reusable AI coding workflows a team member can install globally or per-project,
2121
- **Design** -- Design-and-decompose workflow: ingest a PRD, draft a technical design document, decompose into Jira-ready epics and stories, revise based on feedback, publish as a GitHub PR, respond to reviewer comments, and sync epics/stories to Jira.
2222
See [design/README.md](design/README.md).
2323

24+
- **Implement** -- Story-to-code workflow: take a Jira Story, plan the implementation, write contract-based tests and production code via TDD, validate against the project's CI expectations, and manage review via GitHub PRs.
25+
See [implement/README.md](implement/README.md).
26+
2427
- **CVE Fix** -- Automated CVE remediation: read vulnerability details from Jira, apply multi-strategy dependency fixes, validate, create pull requests, backport to release branches, and close Jira tickets. Language-agnostic.
2528
See [cve-fix/README.md](cve-fix/README.md).
2629

@@ -99,6 +102,7 @@ Each workflow is intended for a specific project or use case:
99102
- **docs-writer** -- the [edge-manager](https://gitlab.cee.redhat.com/red-hat-enterprise-openshift-documentation/edge-manager) downstream docs project
100103
- **prd** -- teams drafting Product Requirements Documents from Jira features
101104
- **design** -- teams creating technical design documents and Jira-ready epic/story breakdowns from PRDs
105+
- **implement** -- teams implementing Jira stories produced by the design workflow
102106
- **cve-fix** -- teams patching CVEs and updating vulnerable dependencies from Jira vulnerability tickets
103107
- **ai-ready** -- onboarding any project for AI agents by generating AGENTS.md
104108
- **kcs** -- teams writing KCS Solution articles for known issues with workarounds

implement/README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Implement Workflow
2+
3+
A story-to-code workflow that takes a Jira Story, plans the implementation, writes contract-based tests and production code via TDD, validates against the project's CI expectations, and manages review via GitHub PRs.
4+
5+
## Prerequisites
6+
7+
| Tool | Required | Purpose |
8+
|------|----------|---------|
9+
| Jira access (MCP or CLI) | For `/ingest` | Fetch Story issue details |
10+
| GitHub CLI (`gh`) | For `/publish`, `/respond` | Create PRs, post review comments |
11+
| Git | Yes | Branch management, commits |
12+
| Project build/test tooling | Yes | Discovered during `/ingest` from project's AGENTS.md, Makefile, CI workflows |
13+
| Docs repo (local clone) | For `/ingest` | Read PRD and design document for upstream context |
14+
15+
## Phases
16+
17+
| Phase | Command | Purpose | Artifact(s) |
18+
|-------|---------|---------|-------------|
19+
| Ingest | `/ingest` | Fetch story, load context, explore codebase | `01-context.md` |
20+
| Plan | `/plan` | Design implementation approach and test strategy | `02-plan.md` |
21+
| Revise | `/revise` | Incorporate feedback into the plan | Updated `02-plan.md` |
22+
| Code | `/code` | Write tests and code via TDD | `03-test-report.md`, `04-impl-report.md` |
23+
| Validate | `/validate` | Run tests, lint, coverage analysis | `05-validation-report.md` |
24+
| Publish | `/publish` | Push branch, create draft PR | `06-pr-description.md` |
25+
| Respond | `/respond` | Address reviewer comments | `07-review-responses.md` |
26+
27+
## Typical Flow
28+
29+
```text
30+
/ingest EDM-1234
31+
→ fetches story from Jira
32+
→ loads design document and PRD context
33+
→ explores affected codebase areas
34+
→ discovers validation profile (build, test, lint commands)
35+
→ writes .artifacts/implement/EDM-1234/01-context.md
36+
37+
/plan
38+
→ designs implementation approach
39+
→ defines interfaces and types (the contracts)
40+
→ plans test strategy (unit + integration)
41+
→ breaks work into ordered tasks
42+
→ writes 02-plan.md
43+
44+
/revise (optional, repeatable)
45+
→ user reviews plan, requests changes
46+
→ plan updated, consistency maintained
47+
48+
/code
49+
→ creates feature branch
50+
→ for each task: write tests → write code → review → commit
51+
→ updates 02-plan.md with task completion status
52+
→ writes 03-test-report.md, 04-impl-report.md
53+
54+
/validate
55+
→ runs full validation suite (discovered during /ingest)
56+
→ analyzes coverage for untested behavioral paths
57+
→ adds tests for gaps, fixes lint issues
58+
→ writes 05-validation-report.md
59+
60+
/publish
61+
→ pushes feature branch
62+
→ creates draft GitHub PR with Jira link
63+
→ writes 06-pr-description.md
64+
65+
/respond (repeatable)
66+
→ fetches PR review comments
67+
→ proposes responses (user approves before posting)
68+
→ applies code changes if needed
69+
→ writes 07-review-responses.md
70+
```
71+
72+
## Artifacts
73+
74+
All artifacts are stored in `.artifacts/implement/{jira-key}/`.
75+
76+
```text
77+
.artifacts/implement/EDM-1234/
78+
01-context.md (story context, validation profile)
79+
02-plan.md (task breakdown, test strategy — updated as tasks complete)
80+
03-test-report.md (tests written, contracts covered)
81+
04-impl-report.md (changes, commits, deviations)
82+
05-validation-report.md (check results, coverage, regressions)
83+
06-pr-description.md (PR body)
84+
07-review-responses.md (review comment log)
85+
publish-metadata.json (PR number, branch, URL)
86+
```
87+
88+
## Key Design Decisions
89+
90+
### Contract-Based Testing
91+
92+
Tests validate behavioral contracts through public interfaces:
93+
- Every behavioral path reachable through a public function gets its own test case
94+
- Tests should remain valid if the implementation were rewritten
95+
- Unit tests are always required; integration tests are required when the story touches component interactions
96+
- Coverage tooling is a signal ("is there a behavioral contract I missed?"), not a numeric target. However, new code that cannot reach the project's coverage threshold (discovered during `/ingest`, default 90%) through public API tests signals a design problem — the component likely needs decomposition into smaller units, not tests that reach into internals
97+
98+
### Discovery-Based Validation
99+
100+
The workflow does not hardcode language-specific commands. During `/ingest`, it discovers the project's validation expectations from AGENTS.md, Makefile, and CI workflows, and records them in a validation profile. `/validate` executes whatever was discovered. If the project adds new CI checks, the next `/ingest` picks them up automatically.
101+
102+
### Incremental Commits
103+
104+
Each logical unit of work gets its own commit, following the project's commit format (discovered during `/ingest`). Each commit should be independently meaningful.
105+
106+
### Plan as Living Document
107+
108+
`02-plan.md` is updated during `/code` as tasks are completed. On re-invocation (e.g., after context limits or interruptions), the plan shows which tasks are done and which remain.
109+
110+
## Directory Structure
111+
112+
```text
113+
implement/
114+
├── SKILL.md # Workflow entry point
115+
├── guidelines.md # Behavioral rules and guardrails
116+
├── README.md # This file
117+
├── skills/
118+
│ ├── controller.md # Phase dispatcher and transitions
119+
│ ├── ingest.md # Fetch story, explore codebase
120+
│ ├── plan.md # Design implementation approach
121+
│ ├── revise.md # Incorporate plan feedback
122+
│ ├── code.md # Write tests and code via TDD
123+
│ ├── validate.md # Run validation suite
124+
│ ├── publish.md # Create GitHub PR
125+
│ └── respond.md # Address review comments
126+
└── commands/
127+
├── ingest.md # /ingest command
128+
├── plan.md # /plan command
129+
├── revise.md # /revise command
130+
├── code.md # /code command
131+
├── validate.md # /validate command
132+
├── publish.md # /publish command
133+
└── respond.md # /respond command
134+
```
135+
136+
## Getting Started
137+
138+
```bash
139+
# Install the workflow
140+
./install.sh claude --workflows implement
141+
142+
# Or install all workflows
143+
./install.sh all
144+
```
145+
146+
Then in your project, run the `implement` workflow's `ingest` command for your Jira story (e.g., EDM-1234).

implement/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: implement
3+
description: >-
4+
Story-to-code workflow that takes a Jira Story, plans the implementation,
5+
writes contract-based tests and production code via TDD, validates against
6+
the project's CI expectations, and manages review via GitHub PRs.
7+
Use when implementing Jira stories produced by the design workflow.
8+
Activated by commands: /ingest, /plan, /revise, /code, /validate, /publish, /respond.
9+
---
10+
# Implement Workflow Orchestrator
11+
12+
## Quick Start
13+
14+
1. If the user invoked a specific command (e.g., `/plan`, `/code`), read
15+
`commands/{command}.md` and follow it.
16+
2. Otherwise, read `skills/controller.md` to load the workflow controller:
17+
- If the user provided a Jira issue key or URL, execute the `/ingest` phase
18+
- Otherwise, execute the first phase the user requests
19+
20+
If a step fails or produces unexpected output (e.g., Jira MCP errors, test
21+
failures, build errors), stop and report the error to the user. Do not
22+
advance to the next phase. Offer to retry the failed step or escalate.
23+
24+
For principles, hard limits, safety, quality, and escalation rules, see `guidelines.md`.

implement/commands/code.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: implement:code
3+
description: "Write tests and production code via TDD, committing incrementally"
4+
---
5+
# /code
6+
7+
Read `../skills/controller.md` and follow it.
8+
9+
Dispatch the **code** phase. Context:
10+
11+
$ARGUMENTS

implement/commands/ingest.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: implement:ingest
3+
description: "Fetch Jira story, load design/PRD context, explore codebase, build validation profile"
4+
---
5+
# /ingest
6+
7+
Read `../skills/controller.md` and follow it.
8+
9+
Dispatch the **ingest** phase. Context:
10+
11+
$ARGUMENTS

implement/commands/plan.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: implement:plan
3+
description: "Design the implementation approach with task breakdown and test strategy"
4+
---
5+
# /plan
6+
7+
Read `../skills/controller.md` and follow it.
8+
9+
Dispatch the **plan** phase. Context:
10+
11+
$ARGUMENTS

implement/commands/publish.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: implement:publish
3+
description: "Push branch and create a draft PR in the source repo"
4+
---
5+
# /publish
6+
7+
Read `../skills/controller.md` and follow it.
8+
9+
Dispatch the **publish** phase. Context:
10+
11+
$ARGUMENTS

implement/commands/respond.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: implement:respond
3+
description: "Fetch PR review comments, propose responses, apply code changes"
4+
---
5+
# /respond
6+
7+
Read `../skills/controller.md` and follow it.
8+
9+
Dispatch the **respond** phase. Context:
10+
11+
$ARGUMENTS

implement/commands/revise.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: implement:revise
3+
description: "Incorporate user feedback into the implementation plan"
4+
---
5+
# /revise
6+
7+
Read `../skills/controller.md` and follow it.
8+
9+
Dispatch the **revise** phase. Context:
10+
11+
$ARGUMENTS

0 commit comments

Comments
 (0)