@codebehind/agent-workflow 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +94 -0
  2. package/bin/agent-workflow.mjs +96 -0
  3. package/package.json +28 -0
  4. package/templates/.agent-workflow/README.md +160 -0
  5. package/templates/.agent-workflow/acceptance-verification.md +192 -0
  6. package/templates/.agent-workflow/artifacts/.gitkeep +0 -0
  7. package/templates/.agent-workflow/docs/README.md +45 -0
  8. package/templates/.agent-workflow/docs/_template.md +35 -0
  9. package/templates/.agent-workflow/notion-spec-mapping.md +54 -0
  10. package/templates/.agent-workflow/plans/.gitkeep +0 -0
  11. package/templates/.agent-workflow/plans/README.md +19 -0
  12. package/templates/.agent-workflow/playwright-acceptance.md +169 -0
  13. package/templates/.agent-workflow/specs/README.md +46 -0
  14. package/templates/.agent-workflow/specs/_template.md +60 -0
  15. package/templates/.agent-workflow/specs/assets/.gitkeep +0 -0
  16. package/templates/.agent-workflow/specs/assets/README.md +15 -0
  17. package/templates/.claude/hooks/.gitkeep +0 -0
  18. package/templates/.claude/rules/agentic-workflow.md +138 -0
  19. package/templates/.claude/settings.json +76 -0
  20. package/templates/.claude/skills/acceptance-proof/SKILL.md +68 -0
  21. package/templates/.claude/skills/create-mr-summary/SKILL.md +29 -0
  22. package/templates/.claude/skills/implement-spec/SKILL.md +97 -0
  23. package/templates/.claude/skills/prepare-spec/SKILL.md +77 -0
  24. package/templates/AGENTS.md +43 -0
  25. package/templates/agents-workflow-dev-process.md +212 -0
  26. package/templates/agents-workflow-env-setup.md +136 -0
  27. package/templates/scripts/agent/LOCAL_GITLAB_WORKFLOW.md +83 -0
  28. package/templates/scripts/agent/cleanup-worktree.sh +23 -0
  29. package/templates/scripts/agent/ensure-codebase.sh +43 -0
  30. package/templates/scripts/agent/git-detect-default-branch.sh +32 -0
  31. package/templates/scripts/agent/git-find-open-mr.sh +6 -0
  32. package/templates/scripts/agent/git-open-mr.sh +24 -0
  33. package/templates/scripts/agent/git-prepare-worktree.sh +54 -0
  34. package/templates/scripts/agent/git-push-branch.sh +12 -0
  35. package/templates/scripts/agent/git-update-mr.sh +28 -0
  36. package/templates/scripts/agent/implement-task.sh +19 -0
  37. package/templates/scripts/agent/mr-template.sh +33 -0
  38. package/templates/scripts/agent/post-run-summary.sh +24 -0
  39. package/templates/scripts/agent/prepare-spec.sh +19 -0
  40. package/templates/scripts/agent/start-worktree.sh +36 -0
  41. package/templates/scripts/agent/verify-acceptance.sh +12 -0
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: implement-spec
3
+ description: Read an open spec, produce a verified plan, stop for approval when required, implement the approved scope, update docs and artifacts, and publish progress through GitLab on a task branch.
4
+ ---
5
+
6
+ Use this skill when the user points to a spec file for implementation.
7
+
8
+ ## Preconditions
9
+ - Target spec exists
10
+ - Spec status is `open`
11
+
12
+ If the spec is still `draft`, stop and explain that it must be reviewed and moved to `open` first.
13
+
14
+ ## Required sequence
15
+ ### 1. Read context
16
+ Read:
17
+ - target spec
18
+ - `.agent-workflow/codebase.md`
19
+ - relevant existing feature docs
20
+ - relevant code, schema, migrations, controllers, and tests
21
+
22
+ ### 2. Draft plan
23
+ Create or update `.agent-workflow/plans/<spec-filename-without-ext>_plan.md`
24
+
25
+ The plan must include:
26
+ - goal summary
27
+ - impacted files/modules
28
+ - schema/migration impact
29
+ - endpoint/query impact
30
+ - implementation steps
31
+ - verification approach by acceptance criterion
32
+ - risks / open questions
33
+
34
+ ### 3. Validate before proceeding
35
+ Before implementation, validate:
36
+ - referenced tables actually exist
37
+ - chosen data sources are correct
38
+ - migrations are included when persistent schema changes are required
39
+ - endpoints/queries reflect real project patterns
40
+ - acceptance criteria are internally consistent with real data when verifiable
41
+
42
+ ### 4. Handle inconsistencies
43
+ If you detect mismatch between spec and reality, do not silently correct it.
44
+ Stop and report:
45
+ - what is inconsistent
46
+ - what you checked
47
+ - the smallest proposed correction
48
+ - whether approval is required before continuing
49
+
50
+ ### 5. Approval gate
51
+ If `verification: true`, stop after the plan and wait for explicit approval.
52
+ Do not implement before approval.
53
+
54
+ If running on an `agent/task/<slug>` branch:
55
+ - commit the plan,
56
+ - push the branch with `scripts/agent/git-push-branch.sh`,
57
+ - open or update the MR so the user can review the plan there,
58
+ - then wait.
59
+
60
+ ### 6. Implement
61
+ After approval:
62
+ - modify only required files
63
+ - keep scope tight
64
+ - follow existing architecture and naming
65
+ - update the plan if implementation changes materially
66
+ - commit meaningful milestones when helpful
67
+
68
+ ### 7. Verify
69
+ For each acceptance criterion:
70
+ - run or describe concrete verification steps (for the current project, run inside the relevant submodule directory)
71
+ - save proof into `.agent-workflow/artifacts/acceptance-<spec-slug>-<YYYYMMDD>/`
72
+ - note pass/fail clearly per `.agent-workflow/acceptance-verification.md`
73
+
74
+ ### 8. Update docs
75
+ Update the most relevant existing doc in `.agent-workflow/docs/` if one already covers the feature area.
76
+ Only create a new doc if no existing doc is the right place.
77
+
78
+ ### 9. GitLab handoff
79
+ 1. Stage only the relevant meta-repo files (spec, plan, docs, artifacts — not submodule code).
80
+ 2. Commit current changes.
81
+ 3. Push with `scripts/agent/git-push-branch.sh`.
82
+ 4. Generate MR body content using `scripts/agent/mr-template.sh task <spec-path> <plan-path> <doc-path-or-dash> <artifacts-path-or-dash>`.
83
+ 5. Open or update the MR using the scripts in `scripts/agent/`.
84
+ 6. If submodule code was changed, open separate MRs in the affected submodule GitLab projects and reference them in the meta repo MR description.
85
+
86
+ ### 10. Final handoff
87
+ Provide:
88
+ - files changed
89
+ - plan path
90
+ - artifacts path
91
+ - docs path
92
+ - unresolved issues
93
+ - MR summary draft
94
+ - MR URL if created or updated
95
+
96
+ ### 11. Completion
97
+ Set spec status to `done` only after implementation, verification, artifacts, docs, and GitLab handoff are complete.
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: prepare-spec
3
+ description: Turn a Notion task or free-form request into a repository spec file, gather supporting assets, commit the result on a spec branch, and open or update a GitLab MR.
4
+ ---
5
+
6
+ Use this skill when the user wants a new spec created or an existing draft refined.
7
+
8
+ ## Objective
9
+ Produce a clean implementation-ready spec in `.agent-workflow/specs/`, gather relevant supporting files in `.agent-workflow/specs/assets/<spec-slug>/`, and hand the result off through GitLab when the current session is running in the local GitLab workflow.
10
+
11
+ ## Inputs
12
+ Possible inputs:
13
+ - pasted Notion task content
14
+ - Notion page or subpage content available through connectors
15
+ - screenshots or JSON examples
16
+ - short free-form feature request
17
+
18
+ ## Required behavior
19
+ 1. Read `.agent-workflow/specs/_template.md` if present.
20
+ 2. Determine the spec filename using the convention `<YYYYMMDD>_<slug>.md` when a date is known; otherwise preserve project conventions.
21
+ 3. Create the asset directory `.agent-workflow/specs/assets/<spec-slug>/` if supporting assets exist or should exist.
22
+ 4. If the source page references linked pages, child pages, attachments, tables, images, code blocks, or JSON examples relevant to delivery:
23
+ - inspect them,
24
+ - extract what matters,
25
+ - save local copies into the spec asset directory when practical,
26
+ - reference those assets from the spec.
27
+ 5. Default frontmatter:
28
+ - `status: draft`
29
+ - `verification: true`
30
+ - `acceptance_proof: true`
31
+ 6. Keep the scope concrete and implementation-oriented.
32
+ 7. Do not mark the spec `open` yourself unless the user explicitly asks you to.
33
+
34
+ ## Spec sections
35
+ Include these sections unless the repo template already defines them:
36
+ - Title
37
+ - Summary
38
+ - Goals
39
+ - Non-Goals
40
+ - Requirements
41
+ - UX / UI
42
+ - API / Data Contracts
43
+ - Acceptance Criteria
44
+ - Rollout / Risks
45
+ - References
46
+ - Assets
47
+
48
+ ## Quality bar
49
+ - Acceptance criteria must be testable.
50
+ - Counts, IDs, endpoints, and expected results must be internally consistent.
51
+ - If counts or expected outputs look suspicious, call them out in a `Spec review notes` subsection at the bottom.
52
+ - Prefer linking large payload examples as assets instead of embedding them inline.
53
+
54
+ ## Asset rules
55
+ Store assets in:
56
+ - `.agent-workflow/specs/assets/<spec-slug>/`
57
+
58
+ Use filenames that reveal purpose, for example:
59
+ - `rapidapi-game-summary-response.json`
60
+ - `ui-reference-mobile.png`
61
+ - `db-shape-notes.md`
62
+
63
+ ## GitLab handoff behavior
64
+ 1. Stage only the relevant spec, asset, and doc changes (no submodule code).
65
+ 2. Create a focused commit.
66
+ 3. Push the current branch with `scripts/agent/git-push-branch.sh`.
67
+ 4. Generate MR body content using `scripts/agent/mr-template.sh spec <spec-path> - - -`.
68
+ 5. Open or update the MR using the scripts in `scripts/agent/`.
69
+
70
+ ## Final handoff
71
+ Return:
72
+ - created or updated spec path
73
+ - created asset paths
74
+ - missing assumptions or ambiguities
75
+ - recommendation on whether the spec is ready to move from `draft` to `open`
76
+ - commit status
77
+ - MR URL if created or updated
@@ -0,0 +1,43 @@
1
+ # Agent Onboarding
2
+
3
+ ## Workflow Process
4
+
5
+ This repository uses a structured feature delivery workflow.
6
+
7
+ **CRITICAL**: Before starting any work, read `.agent-workflow/README.md` to understand the complete workflow.
8
+
9
+ ## Quick Start
10
+
11
+ 1. Read `.agent-workflow/README.md` (workflow process — **Phase A** spec authorship vs **Phase B** delivery).
12
+ 2. Read `.agent-workflow/codebase.md` (codebase snapshot — do NOT rescan unless explicitly asked).
13
+ 3. Determine the task:
14
+ - **Prepare a spec** (user pasted Notion URL, asked for chat-assisted drafting, or asked to convert Notion → spec): follow **Phase A**; write `.agent-workflow/specs/*.md` with `status: draft` unless the user says otherwise; use `.agent-workflow/notion-spec-mapping.md` for Notion.
15
+ - **Implement a feature**: only specs with **`status: open`**; check `.agent-workflow/specs/` for those.
16
+ 4. For implementation, read `verification` in each open spec (`true|false`, default to `true` when missing).
17
+ 5. Follow the workflow: **open** spec → plan → implement → document → mark spec `done`.
18
+
19
+ ## Meta-repo rule
20
+
21
+ This is the **Mjaumatish meta repository**. Specs, plans, docs, and artifacts live here. Application code changes go inside submodule directories (`backend/`, `web/`, `mobile/`). Each affected submodule gets its own MR in its own GitLab project.
22
+
23
+ - Never commit application code directly to the meta repo.
24
+ - When running acceptance proof (UI, API), navigate inside the relevant submodule to start the app and capture evidence. Save artifacts back here under `.agent-workflow/artifacts/`.
25
+ - Reference submodule MR URLs in the meta repo MR description.
26
+
27
+ ## Key Points
28
+
29
+ - Specs use **`draft`** while authoring; **`open`** means ready for implementation (Phase B).
30
+ - Users promote **`draft` → `open`** after review, or ask the agent to do so.
31
+ - **Implementation** only applies to **`status: open`** specs.
32
+ - Users can set `verification: false` for autonomous execution without verification checkpoints in Phase B.
33
+ - Agents create plans, implement, and document features per `.agent-workflow/README.md`.
34
+ - With `verification: false`, agents proceed after plan creation, then finish docs and mark spec done without waiting for approval pauses.
35
+ - All work follows the structured workflow in `.agent-workflow/`.
36
+
37
+ ## Acceptance proof reminder
38
+
39
+ - For UI work, proof must be **runtime evidence**, not code references.
40
+ - Prefer Playwright screenshots per acceptance criterion or per major UI state.
41
+ - Distinguish clearly between `implemented`, `verified automatically`, and `human QA pending`.
42
+ - Follow `.agent-workflow/acceptance-verification.md` and `.agent-workflow/playwright-acceptance.md`.
43
+ - For this meta repo: run the app inside the relevant submodule directory; save artifacts here.
@@ -0,0 +1,212 @@
1
+ # Agents Workflow — Development Process
2
+
3
+ This document describes how we use **Claude Code** with the `.agent-workflow/` convention in this repository: from writing a spec to opening a merge request and merging.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Work flows through two phases:
10
+
11
+ | Phase | What happens | Skill |
12
+ |-------|-------------|-------|
13
+ | **A — Prepare spec** | Create or refine a spec file (`draft`) | `/prepare-spec` |
14
+ | **B — Implement spec** | Plan → code → docs for an `open` spec | `/implement-spec` |
15
+
16
+ Phases are kept in **separate Claude sessions** on **separate branches** to keep spec authoring and implementation cleanly isolated.
17
+
18
+ ---
19
+
20
+ ## Prerequisites
21
+
22
+ - `git`
23
+ - [`glab`](https://gitlab.com/gitlab-org/cli) (GitLab CLI) — authenticated via `glab auth login`
24
+ - `jq`
25
+ - Claude Code CLI (running locally)
26
+
27
+ See `agents-workflow-env-setup.md` for initial setup.
28
+
29
+ ---
30
+
31
+ ## What is a spec?
32
+
33
+ A **spec** is the authoritative description of what should be built and what "done" means. It lives in:
34
+
35
+ ```
36
+ .agent-workflow/specs/{name}.md
37
+ ```
38
+
39
+ Specs use **YAML frontmatter**:
40
+
41
+ | Field | Values | Meaning |
42
+ |-------|--------|---------|
43
+ | `status` | `draft` / `open` / `done` | `draft` = authoring; `open` = ready for Phase B; `done` = delivered |
44
+ | `verification` | `true` / `false` | `true` = human checkpoints during Phase B; `false` = autonomous after plan |
45
+ | `acceptance_proof` | `true` / `false` | `true` = runtime evidence required; `false` = text-only (config/infra only) |
46
+
47
+ Use `_template.md` when creating specs by hand.
48
+
49
+ ---
50
+
51
+ ## Phase A — Prepare spec
52
+
53
+ ### Option 1: From a Notion page
54
+
55
+ Start a **new Claude Code session** in the repo root worktree and say:
56
+
57
+ ```
58
+ Use prepare-spec skill. Source: <notion-url>
59
+ ```
60
+
61
+ The agent fetches the Notion page, maps content to the spec template, asks clarifying questions, then writes `.agent-workflow/specs/<date>_<slug>.md` with `status: draft`.
62
+
63
+ ### Option 2: From a description
64
+
65
+ ```
66
+ Use prepare-spec skill.
67
+
68
+ <short title and bullet-point description of the feature>
69
+ ```
70
+
71
+ ### Option 3: By hand
72
+
73
+ Copy `.agent-workflow/specs/_template.md` to `.agent-workflow/specs/<name>.md`, fill it in, and set `status: draft` (or `open` if ready).
74
+
75
+ ### After spec prep
76
+
77
+ 1. Review the spec in the MR opened on branch `agent/spec/<slug>`.
78
+ 2. Edit if needed.
79
+ 3. Set `status: open` when ready for development (edit the file or ask the agent to flip it).
80
+ 4. Merge the spec MR into main.
81
+
82
+ ---
83
+
84
+ ## Phase B — Implement spec
85
+
86
+ The spec must have `status: open` and be merged to main before starting Phase B.
87
+
88
+ ### Start a task session
89
+
90
+ From the repo root:
91
+
92
+ ```bash
93
+ scripts/agent/git-prepare-worktree.sh task <slug>
94
+ ```
95
+
96
+ This creates a worktree at `~/agent-runs/mjaumatish-meta/worktrees/task-<slug>` on branch `agent/task/<slug>`.
97
+
98
+ Open Claude Code in that worktree:
99
+
100
+ ```bash
101
+ cd ~/agent-runs/mjaumatish-meta/worktrees/task-<slug>
102
+ claude
103
+ ```
104
+
105
+ Then instruct the agent:
106
+
107
+ ```
108
+ Use implement-spec skill for .agent-workflow/specs/<spec-file>.md.
109
+ Follow the local GitLab workflow. Create the plan first, push it, and stop for approval.
110
+ ```
111
+
112
+ ### What the agent does
113
+
114
+ 1. Reads the spec, codebase snapshot, and relevant existing docs.
115
+ 2. Creates `.agent-workflow/plans/<spec-name>_plan.md`.
116
+ 3. If `verification: true` (default): commits the plan, pushes, opens/updates an MR, and **waits for your approval**.
117
+ 4. After approval (or immediately if `verification: false`): implements the feature — code changes go into the relevant submodule(s) (`backend/`, `web/`, `mobile/`).
118
+ 5. Runs acceptance verification per the criteria in the spec.
119
+ 6. Writes/updates a feature doc in `.agent-workflow/docs/`.
120
+ 7. Opens or updates the MR with the full summary.
121
+ 8. Sets the spec to `status: done`.
122
+
123
+ ### Continue after plan approval
124
+
125
+ Reply in the same Claude session:
126
+
127
+ ```
128
+ Proceed with implementation.
129
+ ```
130
+
131
+ Or start a fresh session in the same worktree and say:
132
+
133
+ ```
134
+ Use implement-spec skill for .agent-workflow/specs/<spec-file>.md. Plan is approved, proceed with implementation.
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Meta-repo specifics
140
+
141
+ This is a **meta repository**. Specs, plans, docs, and artifacts all live here under `.agent-workflow/`. Application code changes, however, go inside the submodule directories.
142
+
143
+ | What | Where it lives |
144
+ |------|---------------|
145
+ | Spec, plan, docs, artifacts | `.agent-workflow/` in this meta repo |
146
+ | Backend code changes | `backend/` submodule → MR in mjaumatish-backend |
147
+ | Web code changes | `web/` submodule → MR in mjaumatish-web |
148
+ | Mobile code changes | `mobile/` submodule → MR in mjaumatish-mobile |
149
+ | Acceptance proof (runtime) | Runs inside the relevant submodule; artifacts stored here |
150
+
151
+ A cross-cutting spec (touching multiple repos) results in one plan here and separate MRs in each affected sub-repo.
152
+
153
+ ---
154
+
155
+ ## Verification: checkpoints or autonomous
156
+
157
+ Controlled by the spec's `verification` field (default `true`):
158
+
159
+ | Value | Behavior |
160
+ |-------|----------|
161
+ | `true` | Agent drafts a plan, commits it, opens an MR, and waits for your explicit approval before implementing. |
162
+ | `false` | Agent proceeds autonomously after the plan — implements, verifies, docs, MR, done. |
163
+
164
+ Use `false` for low-risk, well-defined tasks. Use `true` (default) when you want to review the plan before code is written.
165
+
166
+ ---
167
+
168
+ ## Acceptance proof
169
+
170
+ After implementation, the agent verifies each acceptance criterion and saves evidence under:
171
+
172
+ ```
173
+ .agent-workflow/artifacts/acceptance-<spec-slug>-<YYYYMMDD>/
174
+ ```
175
+
176
+ For UI and API criteria, this means runtime evidence (screenshots, curl output) — not just "the code was added." See `.agent-workflow/acceptance-verification.md` for the full protocol.
177
+
178
+ ---
179
+
180
+ ## GitLab MR flow
181
+
182
+ Scripts under `scripts/agent/` handle the GitLab integration:
183
+
184
+ | Script | Purpose |
185
+ |--------|---------|
186
+ | `git-prepare-worktree.sh` | Create a worktree + branch for spec or task work |
187
+ | `git-push-branch.sh` | Push the current branch to origin |
188
+ | `git-open-mr.sh` | Open a new MR (or update existing) via `glab` |
189
+ | `git-detect-default-branch.sh` | Resolve the target base branch from origin |
190
+ | `git-update-mr.sh` | Update an existing MR description |
191
+ | `cleanup-worktree.sh` | Remove a worktree after work is merged |
192
+
193
+ The agent uses these automatically when instructed to follow the local GitLab workflow.
194
+
195
+ ---
196
+
197
+ ## Quick reference
198
+
199
+ | Concept | Rule |
200
+ |---------|------|
201
+ | Spec location | `.agent-workflow/specs/` in meta repo only |
202
+ | Spec status | `draft` → author; `open` → implement; `done` → finished |
203
+ | Phase A session | Any worktree; use `/prepare-spec` skill |
204
+ | Phase B session | `~/agent-runs/mjaumatish-meta/worktrees/task-<slug>` |
205
+ | Branch — spec | `agent/spec/<slug>` |
206
+ | Branch — task | `agent/task/<slug>` |
207
+ | Code changes | Inside submodule dirs (`backend/`, `web/`, `mobile/`) |
208
+ | Verification | `true` = plan approval checkpoint (default); `false` = autonomous |
209
+ | Acceptance proof | `true` = runtime evidence required (default); `false` = config/infra only |
210
+ | Docs | `.agent-workflow/docs/` + add spec under **Covered Specs** |
211
+ | Artifacts | `.agent-workflow/artifacts/acceptance-<spec-slug>-<YYYYMMDD>/` |
212
+ | Done | Acceptance proof attached to MR → review → **merge** |
@@ -0,0 +1,136 @@
1
+ # Agent Workflow — Environment Setup
2
+
3
+ One-time setup for working with Claude Code and the `.agent-workflow/` convention in this repository.
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ Install these tools before starting:
10
+
11
+ | Tool | Purpose | Install |
12
+ |------|---------|---------|
13
+ | `git` | Version control | System package manager |
14
+ | [`glab`](https://gitlab.com/gitlab-org/cli) | GitLab CLI (MR management) | `brew install glab` |
15
+ | `jq` | JSON processing (used by agent scripts) | `brew install jq` |
16
+ | `node` 20+ | Used by some agent scripts | `brew install node` |
17
+ | Claude Code CLI | AI agent | See [claude.ai/code](https://claude.ai/code) |
18
+
19
+ ---
20
+
21
+ ## 1. Clone with submodules
22
+
23
+ ```bash
24
+ git clone --recurse-submodules https://gitlab.com/codebehind/mjaumatish/mjaumatish-meta.git
25
+ cd mjaumatish-meta
26
+ ```
27
+
28
+ Or if already cloned without submodules:
29
+
30
+ ```bash
31
+ ./scripts/bootstrap.sh
32
+ ```
33
+
34
+ ---
35
+
36
+ ## 2. Authenticate with GitLab
37
+
38
+ ```bash
39
+ glab auth login
40
+ ```
41
+
42
+ Follow the prompts. Choose HTTPS and paste a GitLab personal access token with `api` scope.
43
+
44
+ Verify:
45
+
46
+ ```bash
47
+ glab auth status
48
+ ```
49
+
50
+ ---
51
+
52
+ ## 3. Make agent scripts executable
53
+
54
+ ```bash
55
+ chmod +x scripts/agent/*.sh
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 4. Create the worktree root directory
61
+
62
+ Agent worktrees live outside the main repo clone:
63
+
64
+ ```bash
65
+ mkdir -p ~/agent-runs/mjaumatish-meta/worktrees
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 5. Verify the default branch
71
+
72
+ The agent scripts auto-detect the default branch from origin. You can check it manually:
73
+
74
+ ```bash
75
+ scripts/agent/git-detect-default-branch.sh origin
76
+ ```
77
+
78
+ Should return `main`.
79
+
80
+ ---
81
+
82
+ ## 6. Open Claude Code in the repo root
83
+
84
+ ```bash
85
+ cd mjaumatish-meta
86
+ claude
87
+ ```
88
+
89
+ Claude Code will read `CLAUDE.md` and `.claude/rules/agentic-workflow.md` automatically at session start.
90
+
91
+ ---
92
+
93
+ ## Running a spec session (Phase A)
94
+
95
+ From the repo root (no worktree needed for spec prep):
96
+
97
+ ```bash
98
+ claude
99
+ # then in the session:
100
+ # Use prepare-spec skill. <description or Notion URL>
101
+ ```
102
+
103
+ The agent will create a branch `agent/spec/<slug>`, commit the spec, and open a GitLab MR.
104
+
105
+ ---
106
+
107
+ ## Running a task session (Phase B)
108
+
109
+ ```bash
110
+ # 1. Prepare a worktree for the task
111
+ scripts/agent/git-prepare-worktree.sh task <slug>
112
+
113
+ # 2. Open Claude Code in the worktree
114
+ cd ~/agent-runs/mjaumatish-meta/worktrees/task-<slug>
115
+ claude
116
+
117
+ # 3. Instruct the agent
118
+ # Use implement-spec skill for .agent-workflow/specs/<spec-file>.md.
119
+ # Follow the local GitLab workflow. Create the plan, push it, stop for approval.
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Cleanup after a branch is merged
125
+
126
+ ```bash
127
+ scripts/agent/cleanup-worktree.sh <slug>
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Keeping submodules up to date
133
+
134
+ ```bash
135
+ ./scripts/update-submodules.sh
136
+ ```
@@ -0,0 +1,83 @@
1
+ # Local GitLab + Worktree Workflow
2
+
3
+ This repository supports a local Claude Code workflow with Git worktrees and GitLab merge requests.
4
+
5
+ ## Prerequisites
6
+ - `git`
7
+ - `glab`
8
+ - `jq`
9
+ - authenticated `glab auth login`
10
+ - Claude Code running locally with repo instructions enabled
11
+
12
+ ## Branch conventions
13
+ - Spec prep: `agent/spec/<slug>`
14
+ - Task work (plan + implementation): `agent/task/<slug>`
15
+
16
+ ## Worktree root
17
+ - `~/agent-runs/<repo>/worktrees/`
18
+
19
+ ## 1. Start a spec run
20
+ From the main repo root:
21
+
22
+ ```bash
23
+ scripts/agent/git-prepare-worktree.sh spec <slug>
24
+ ```
25
+
26
+ Then open Claude in the created worktree and instruct it to use the `prepare-spec` skill.
27
+
28
+ Expected result:
29
+ - draft spec created or updated
30
+ - assets stored under `.agent-workflow/specs/assets/<spec-slug>/`
31
+ - commit created
32
+ - branch pushed
33
+ - MR opened automatically via `glab`
34
+
35
+ ## 2. Review and merge spec MR
36
+ - review the MR
37
+ - request changes if needed
38
+ - once ready, mark the spec `open`
39
+ - merge the MR
40
+
41
+ ## 3. Start a task run
42
+ From the main repo root:
43
+
44
+ ```bash
45
+ scripts/agent/git-prepare-worktree.sh task <slug>
46
+ ```
47
+
48
+ Then open Claude in the created worktree and instruct it to use the `implement-spec` skill.
49
+
50
+ Expected result before approval:
51
+ - plan created or updated
52
+ - plan committed on `agent/task/<slug>`
53
+ - branch pushed
54
+ - MR opened or updated for plan review
55
+ - agent stops when `verification: true`
56
+
57
+ After approval:
58
+ - implementation proceeds on same branch
59
+ - artifacts are created
60
+ - docs are updated
61
+ - MR is updated for final review
62
+
63
+ ## Suggested prompts
64
+ ### Spec agent
65
+ ```text
66
+ Use prepare-spec skill for this Notion task. Follow the local GitLab workflow in this repo. When the spec is ready, commit, push, and open or update the merge request.
67
+ ```
68
+
69
+ ### Task agent
70
+ ```text
71
+ Use implement-spec skill for .agent-workflow/specs/<spec-file>.md. Follow the local GitLab workflow in this repo. Create the plan first, push it, and stop for approval because verification=true.
72
+ ```
73
+
74
+ ### Continue after plan approval
75
+ ```text
76
+ Proceed with implementation, verification artifacts, docs update, and merge request update.
77
+ ```
78
+
79
+ ## Notes
80
+ - The target branch is always the repository default branch detected from origin.
81
+ - Do not force-push.
82
+ - Do not reuse a spec branch for task work.
83
+ - Prefer one Claude session per branch/worktree.
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [[ $# -lt 2 ]]; then
5
+ echo "Usage: $0 <repo_root> <spec_slug> [--delete-branch]" >&2
6
+ exit 1
7
+ fi
8
+
9
+ REPO_ROOT="$1"
10
+ SPEC_SLUG="$2"
11
+ DELETE_BRANCH="${3:-}"
12
+ REPO_ROOT="$(cd "$REPO_ROOT" && pwd)"
13
+ WORKTREE_PATH="$REPO_ROOT/.worktrees/$SPEC_SLUG"
14
+ BRANCH_NAME="feature/agent/$SPEC_SLUG"
15
+
16
+ cd "$REPO_ROOT"
17
+ if [[ -d "$WORKTREE_PATH" ]]; then
18
+ git worktree remove "$WORKTREE_PATH" --force
19
+ fi
20
+
21
+ if [[ "$DELETE_BRANCH" == "--delete-branch" ]]; then
22
+ git branch -D "$BRANCH_NAME" 2>/dev/null || true
23
+ fi