alignfirst 0.1.0-beta.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 (74) hide show
  1. package/README.md +31 -0
  2. package/bin/alignfirst.mjs +3 -0
  3. package/dist/cli-error.d.ts +2 -0
  4. package/dist/cli-error.js +2 -0
  5. package/dist/cli.d.ts +10 -0
  6. package/dist/cli.js +98 -0
  7. package/dist/command-form.d.ts +3 -0
  8. package/dist/command-form.js +8 -0
  9. package/dist/commands/config.d.ts +2 -0
  10. package/dist/commands/config.js +55 -0
  11. package/dist/commands/developers.d.ts +2 -0
  12. package/dist/commands/developers.js +36 -0
  13. package/dist/commands/docmap.d.ts +2 -0
  14. package/dist/commands/docmap.js +22 -0
  15. package/dist/commands/doctor.d.ts +2 -0
  16. package/dist/commands/doctor.js +167 -0
  17. package/dist/commands/guide.d.ts +2 -0
  18. package/dist/commands/guide.js +126 -0
  19. package/dist/commands/plans.d.ts +2 -0
  20. package/dist/commands/plans.js +154 -0
  21. package/dist/commands/setup.d.ts +2 -0
  22. package/dist/commands/setup.js +254 -0
  23. package/dist/commands/sync.d.ts +2 -0
  24. package/dist/commands/sync.js +63 -0
  25. package/dist/commands/ticket.d.ts +2 -0
  26. package/dist/commands/ticket.js +119 -0
  27. package/dist/context.d.ts +15 -0
  28. package/dist/context.js +1 -0
  29. package/dist/errors.d.ts +2 -0
  30. package/dist/errors.js +6 -0
  31. package/dist/executables.d.ts +1 -0
  32. package/dist/executables.js +24 -0
  33. package/dist/git.d.ts +5 -0
  34. package/dist/git.js +52 -0
  35. package/dist/overlay.d.ts +19 -0
  36. package/dist/overlay.js +83 -0
  37. package/dist/parse-args.d.ts +1 -0
  38. package/dist/parse-args.js +11 -0
  39. package/dist/plans/archive.d.ts +4 -0
  40. package/dist/plans/archive.js +68 -0
  41. package/dist/plans/layout.d.ts +6 -0
  42. package/dist/plans/layout.js +19 -0
  43. package/dist/plans/link.d.ts +2 -0
  44. package/dist/plans/link.js +36 -0
  45. package/dist/plans/mode.d.ts +9 -0
  46. package/dist/plans/mode.js +31 -0
  47. package/dist/plans/ticket.d.ts +21 -0
  48. package/dist/plans/ticket.js +104 -0
  49. package/dist/project-config.d.ts +27 -0
  50. package/dist/project-config.js +79 -0
  51. package/dist/protocols.d.ts +2 -0
  52. package/dist/protocols.js +9 -0
  53. package/dist/skills.d.ts +9 -0
  54. package/dist/skills.js +54 -0
  55. package/dist/version-guard.d.ts +8 -0
  56. package/dist/version-guard.js +24 -0
  57. package/package.json +48 -0
  58. package/templates/guide/code-review/correctness-reviewer.md +53 -0
  59. package/templates/guide/code-review/intent-reviewer.md +22 -0
  60. package/templates/guide/code-review/module-javascript.md +80 -0
  61. package/templates/guide/code-review/module-python.md +77 -0
  62. package/templates/guide/code-review/module-typescript-strict.md +84 -0
  63. package/templates/guide/code-review/quality-reviewer.md +54 -0
  64. package/templates/guide/code-review/reviewer-common.md +62 -0
  65. package/templates/guide/code-review/safety-reviewer.md +66 -0
  66. package/templates/guide/core.md +54 -0
  67. package/templates/guide/overview.md +57 -0
  68. package/templates/guide/protocols/aad.md +85 -0
  69. package/templates/guide/protocols/catchup.md +13 -0
  70. package/templates/guide/protocols/description.md +51 -0
  71. package/templates/guide/protocols/merge.md +65 -0
  72. package/templates/guide/protocols/plan.md +256 -0
  73. package/templates/guide/protocols/review.md +114 -0
  74. package/templates/guide/protocols/spec.md +78 -0
@@ -0,0 +1,66 @@
1
+ # Perspective — Change Safety
2
+
3
+ What this change does to the systems around it: contracts, the database, security, data volume, dependencies.
4
+
5
+ ## Contracts and Compatibility
6
+
7
+ | Signal | Question | Severity |
8
+ | --- | --- | --- |
9
+ | Public function signature modified | Are all callers in the diff? If not, is the change backward compatible? | 🔴 |
10
+ | Field removed or renamed in an API response, event, or queue message | Does an existing consumer still read it? Does a progressive deployment make both versions coexist? | 🔴 |
11
+ | Field added with a non-null constraint, or stricter validation | Do existing data satisfy the constraint? Do existing clients send the field? | 🔴 |
12
+ | Default value changed | Does the change apply retroactively to existing records or configurations? Is that intended? | 🔴 |
13
+ | Serialization format or cache key changed | Are entries written by the old version readable by the new one — and the reverse, during deployment? | 🔴 |
14
+ | Environment variable or configuration key added | Safe default, or refusal to start without it? Documented in the diff? | 🟡 |
15
+
16
+ ## Database Changes
17
+
18
+ Migrations and ORM classes deserve particular attention: they are the part of a diff that can break production without breaking a single test.
19
+
20
+ | Signal | Question | Severity |
21
+ | --- | --- | --- |
22
+ | Schema migration | Is it backward compatible with the currently deployed application version? The rule: code deployed before the migration must keep working during and after it. | 🔴 |
23
+ | Destructive migration (column or table dropped, type changed) | Does it follow an expand / backfill / switch / contract split across deployments, or attempt everything at once? Is a rollback possible without loss? | 🔴 |
24
+ | Migration on a large table | Which lock is taken, for how long? Index created without a concurrent mode, massive `UPDATE` in one pass, type change rewriting the table. | 🔴 |
25
+ | Auto-generated migration | Was it reviewed? Auto-generation regularly produces unwanted drops and re-creations. | 🔴 |
26
+ | ORM model changed | Does it still match the schema after the migration? Are defaults and validations enforced at the same layer as before? | 🔴 |
27
+
28
+ ## Security
29
+
30
+ | Signal | Question | Severity |
31
+ | --- | --- | --- |
32
+ | New entry point (route, handler, command, job) | Is it under the same authentication as its neighbors? An endpoint added without the neighboring middleware or decorator is the most frequent case. | 🔴 |
33
+ | Resource identified by a client-supplied parameter | Does the caller have the right to **this specific resource**, or only a generic right to the resource type? | 🔴 |
34
+ | Owner, organization, or tenant identifier read from the request | Does it come from a trusted source (session, verified token) or from the client-supplied body/parameters? | 🔴 |
35
+ | Query on a table with a tenancy column | Is the tenancy filter present? An unfiltered query in a partitioned system is a leak. | 🔴 |
36
+ | Query built by string concatenation or interpolation | Are values parameterized? Do dynamic identifiers (table, column, sort direction) go through an allowlist? | 🔴 |
37
+ | External data rendered in an output (HTML, template, document, structured log) | Encoded for the output context? | 🔴 |
38
+ | File path built from user input | Constrained to a base directory after resolution? | 🔴 |
39
+ | Outbound URL built from user input | Destination restricted? Otherwise the application relays into the internal network. | 🔴 |
40
+ | New log, error message, or trace | Does it contain a secret, personal data, a full request body, a token? | 🔴 |
41
+ | Constant that looks like a secret | Hardcoded key, token, password, connection string — including in tests and fixtures. | 🔴 |
42
+ | Deserialization of untrusted data | Does the format allow code execution? | 🔴 |
43
+ | Comparison of a secret, signature, or token | Constant-time comparison? | 🟡 |
44
+
45
+ ## Data and Performance
46
+
47
+ | Signal | Question | Severity |
48
+ | --- | --- | --- |
49
+ | Query inside a loop, or in a function called in a loop | N+1. Can the loading be batched? | 🔴 |
50
+ | Query without limit or pagination | Is the volume bounded by construction, or only by today's data? | 🔴 |
51
+ | New filter or sort on a column | Does an index exist? Adding the query without the index is a finding. | 🟡 |
52
+ | Open transaction | Does it contain an external network call, a long wait, user interaction? Is its scope as narrow as possible? | 🔴 |
53
+ | Cache added or modified | What is the exact key — does it include every dimension the value depends on (tenancy included)? What is the invalidation? | 🔴 |
54
+ | Whole file, response, or result set loaded in memory | Is the size bounded? | 🟡 |
55
+ | Quadratic algorithm on a hot path | Realistic input size? Quadratic over ten elements is not a finding. | 🟡 |
56
+ | Resource opened (file, connection, lock, subscription) | Released on **all** paths, including exception and early return? | 🔴 |
57
+
58
+ ## New Dependencies
59
+
60
+ | Signal | Question | Severity |
61
+ | --- | --- | --- |
62
+ | Package added to the manifest | Does it really exist, under exactly this name? Package-name confusion is an active attack vector. | 🔴 |
63
+ | Package added to the manifest | Is it maintained, and is its license compatible with the project? | 🟡 |
64
+ | Package added to the manifest | Is it necessary? Could the standard library or an already-installed dependency do the job? | 🟡 |
65
+ | Manifest changed without the lockfile, or the reverse | — | 🟡 |
66
+ | Dependency moved between runtime and dev dependencies | Is it used at runtime? | 🔴 |
@@ -0,0 +1,54 @@
1
+ # AlignFirst Guide
2
+
3
+ An agent that does not know which protocol to use runs `{{CMD}} guide overview`.
4
+
5
+ ## Protocols
6
+
7
+ - **Technical Specification** (_spec_, or _alspec_): `{{CMD}} guide spec --protocol-only`
8
+ - **Implementation Plans** (_plan_, or _alplan_): `{{CMD}} guide plan --protocol-only`
9
+ - **Align-and-Do Protocol** (_AAD_): `{{CMD}} guide aad --protocol-only`
10
+ - **Catch Up** (_catchup_, or _alcatchup_): `{{CMD}} guide catchup --protocol-only`
11
+ - **Merge** (_merge_, or _almerge_): `{{CMD}} guide merge --protocol-only`
12
+ - **Code Review** (_alreview_): `{{CMD}} guide review --protocol-only`
13
+ - **Description** (_aldescription_): `{{CMD}} guide description --protocol-only`
14
+
15
+ ## TASK_DIR Location
16
+
17
+ **TASK_DIR** is `.plans/{TICKET_ID}/`. Run `{{CMD}} ticket <id>` and use the directory it prints. The command creates a missing directory, restores an archived one, and lists its entries.
18
+
19
+ {{TICKET_ID_RULE}}
20
+
21
+ **Work without a ticket:** when the user says there is no ticket, run `{{CMD}} ticket --side`. Reuse an existing `side-N` directory when the user refers to that earlier work. Omit the ticket ID from commit messages.
22
+
23
+ ## File Naming Convention
24
+
25
+ Format: `{CYCLE_LETTER}{FILE_NUMBER}-{FILE_TYPE}.md`
26
+
27
+ **Common file types:**
28
+
29
+ - `spec` - technical specification
30
+ - `plan` - implementation plan
31
+ - `AAD.summary` - AAD summary document
32
+ - `description` - PR/MR description
33
+ - `review` - code review report
34
+ - `merge.summary` - merge conflicts resolution summary
35
+
36
+ **Example structure:**
37
+
38
+ ```text
39
+ .plans/
40
+ ├── 123/
41
+ │ ├── A1-spec.md
42
+ │ ├── A2-plan.md
43
+ │ └── A3-AAD.summary.md
44
+ │ └── B1-spec.md
45
+ ```
46
+
47
+ ## Notes
48
+
49
+ - **TICKET_ID** is a unique identifier for the task, often an issue or ticket number.
50
+ - `{{CMD}} ticket <id> --next <filename>` prints the next filename in the current cycle, the extension included (`--next spec.md` giving `.plans/123/A2-spec.md`).
51
+ - `--new-cycle` starts a new cycle.
52
+ - The protocol or the user decides whether to continue the current cycle or start a new one.
53
+ - Cycle letters and file numbers are internal. Never discuss them with the user.
54
+ - New file types are welcome.
@@ -0,0 +1,57 @@
1
+ # AlignFirst Overview
2
+
3
+ AlignFirst is a set of collaborative protocols for working with a user on coding tasks. The two workflows involve **alignment with the user** — investigating, discussing, and agreeing before acting.
4
+
5
+ ## Workflows
6
+
7
+ ### Spec-Plan-Execute (default)
8
+
9
+ The standard workflow for most tasks. It produces formal artifacts at each stage:
10
+
11
+ 1. **Spec** (`/alspec`): Investigate the codebase, discuss with the user, then write a technical specification. There are usually several back-and-forths before the spec is written.
12
+ 2. **Plan** (`/alplan`): Read the spec, investigate further, then write implementation plan(s). The plan is a self-contained prompt for the implementing agent.
13
+ 3. **Execute**: A new session implements the plan and writes a handover document summarizing the changes.
14
+
15
+ After execution, additional rounds of AAD (see below) can address follow-up fixes or adjustments.
16
+
17
+ ### AAD — Align-and-Do (light)
18
+
19
+ For smaller tasks that don't justify a formal spec and plan. Everything happens in one session: investigate, discuss, implement, summarize.
20
+
21
+ Use AAD (`/al`) when:
22
+
23
+ - The task is small or well-understood
24
+ - It's a follow-up change after a plan has already been executed
25
+ - A quick fix or adjustment is needed
26
+
27
+ Use Spec-Plan-Execute when:
28
+
29
+ - The task is non-trivial or touches multiple areas
30
+ - There are open design questions that need formal exploration
31
+ - You're unsure — default to Spec-Plan-Execute
32
+
33
+ ## Catch Up
34
+
35
+ A standalone utility (`/alcatchup`). It loads the ticket's history from its requests, specs, and summaries. It then follows the user's instructions or returns a short synthesis. To continue directly into a light workflow, use `/alcatchup then start an AAD: …`.
36
+
37
+ ## Description
38
+
39
+ A standalone utility (`/aldescription`). It reads specs and summaries that have been generated for a ticket and produces a concise description of what was implemented. Typically used to generate a PR/MR description once the work is done.
40
+
41
+ ## Code Review
42
+
43
+ A standalone utility (`/alreview`). It compares the current branch to a base branch (defaults to the repo's default branch) and runs parallel reviewers, each with its own perspective: intent, correctness, change safety, code quality. Ecosystem modules (strict TypeScript, JavaScript, Python) sharpen the language-specific checks. The findings are merged into a concise review report.
44
+
45
+ ## Merge
46
+
47
+ A standalone utility (`/almerge`). After a merge or rebase, the agent investigates both sides, resolves the conflicts (with a special case for lock files), and writes a brief summary of the resolutions.
48
+
49
+ ## Typical Lifecycle of a Ticket
50
+
51
+ A ticket usually progresses through:
52
+
53
+ 1. **Spec** — explore and formalize what needs to be done
54
+ 2. **Plan** — design how to do it
55
+ 3. **Execute** — implement the plan
56
+ 4. _(optional)_ **AAD** — address follow-up fixes or small adjustments
57
+ 5. **Description** — summarize the implemented work
@@ -0,0 +1,85 @@
1
+ # Align-and-Do Protocol (AAD)
2
+
3
+ ## Pre-requisites
4
+
5
+ You need:
6
+
7
+ - the TASK_DIR — run `{{CMD}} ticket <id>` (`{{CMD}} ticket` alone deduces the id from the branch when the project defines a ticket format; `{{CMD}} ticket --side` when there is no ticket)
8
+ - the CYCLE_LETTER and FILE_NUMBER — continue the current cycle: `{{CMD}} ticket <id> --next AAD.summary.md` prints the file to create
9
+
10
+ Identify and state these values before starting the protocol.
11
+
12
+ ---
13
+
14
+ This is a 4-step protocol. Follow each step in order.
15
+
16
+ ## 1. Investigate
17
+
18
+ Check your context for available **documentation** and **skills**. Read every document and skill relevant to any aspect of the task — this is not optional. For each skill, also **read its relevant references**.
19
+
20
+ Explore the codebase. Take the time to understand how it currently works and what needs to change.
21
+
22
+ Always seek a clean break solution by default. Never consider backward compatibility unless explicitly requested.
23
+
24
+ ## 2. Discuss
25
+
26
+ Present your findings and proposed approach. Ask clarifying questions. Explore trade-offs and edge cases.
27
+
28
+ **Remember**: This discussion happens BEFORE any implementation or formal specification writing.
29
+
30
+ Engage in a thorough collaborative discussion covering:
31
+
32
+ - **Problem/Goal exploration**: Present your understanding and ask clarifying questions
33
+ - **Current implementation analysis**: Share what you discovered and ask for confirmation or corrections
34
+ - **Approach evaluation**: Discuss potential solutions and their trade-offs
35
+ - **Edge cases and implications**: Explore potential issues and broader system impacts
36
+
37
+ You're new to this project, the user can guide you.
38
+
39
+ Do not use your question tool. Always ask in plain text. Your questions will be the opportunity for a real discussion.
40
+
41
+ **This phase is mandatory.** If there is nothing to discuss, ask the user for an explicit validation.
42
+
43
+ ## 3. Act
44
+
45
+ When you and the user agree, create the summary file in TASK_DIR, then start implementing.
46
+
47
+ Compose the filename using the current CYCLE_LETTER and the bumped FILE_NUMBER, then append `-AAD.summary.md`. For example, if the last file is `E5-plan-something.md`, create `E6-AAD.summary.md`. Do not overwrite an existing file.
48
+
49
+ Maintain the file as a **live report** while you work.
50
+
51
+ Use subagents (your subagent tool) for distinct, isolated units of work when beneficial.
52
+
53
+ ## 4. Summarize
54
+
55
+ Finalize the summary file: replace the working notes with the final content described below.
56
+
57
+ Start the summary with a header, then a suggested commit message (follow the convention you are aware of, or default to `<type>: [<ticket_id>] very short description`). The shorter the better. Omit any field with nothing to list. Always exclude `alignfirst` from skills.
58
+
59
+ Example:
60
+
61
+ ```markdown
62
+ # AAD Summary - [very short title]
63
+
64
+ Suggested commit message: `<commit message>`
65
+
66
+ Used documentation:
67
+
68
+ - `docs/topic-a/doc-1.md`
69
+ - `docs/topic-b/doc-2.md`
70
+
71
+ Used skills: `skill-a`, `skill-b`
72
+ ```
73
+
74
+ The finalized summary is a **very concise handover document** that should capture:
75
+
76
+ - What was the topic or problem
77
+ - What was decided or discovered
78
+ - What action was taken (if any)
79
+ - Key outcomes or next steps
80
+
81
+ The shorter the better.
82
+
83
+ _Ignore markdown lint errors in the summary file._
84
+
85
+ At the end, give the path of the summary file to the user.
@@ -0,0 +1,13 @@
1
+ # How to Catch Up With a Task
2
+
3
+ ## Pre-requisites
4
+
5
+ You need the TASK_DIR — run `{{CMD}} ticket <id>` (`{{CMD}} ticket` alone deduces the id from the branch when the project defines a ticket format; `{{CMD}} ticket --side` when there is no ticket).
6
+
7
+ ## Steps
8
+
9
+ 1. Determine TASK_DIR.
10
+ 2. Read every `*request.md`, `*spec.md` and `*summary.md` file in TASK_DIR, in filename order.
11
+ 3. When the user's message carries instructions, follow them with this context loaded, and write no synthesis. Otherwise reply with a short synthesis: what was requested, what was decided, what was done, what remains or is open.
12
+
13
+ This protocol writes no file.
@@ -0,0 +1,51 @@
1
+ # How to Write a Description for Implemented Work
2
+
3
+ ## Pre-requisites
4
+
5
+ You need:
6
+
7
+ - the TASK_DIR — run `{{CMD}} ticket <id>` (`{{CMD}} ticket` alone deduces the id from the branch when the project defines a ticket format; `{{CMD}} ticket --side` when there is no ticket)
8
+ - the CYCLE_LETTER and FILE_NUMBER — start a new cycle: `{{CMD}} ticket <id> --next description.md --new-cycle` prints the file to create
9
+
10
+ Identify and state these values before starting the protocol.
11
+
12
+ ## Steps
13
+
14
+ 1. Find the current ticket plan directory.
15
+ 2. Create your description as a new file `{CYCLE_LETTER}1-description.md` with the next cycle letter, containing just the header — this reserves the filename.
16
+ 3. If a previous `*description.md` file exists in the TASK_DIR, find the latest one. Only read `*spec.md` and `*summary.md` files that come *after* it — earlier work is already covered.
17
+ Otherwise, read all `*spec.md` and `*summary.md` files.
18
+ 4. Write the commit message and description into your file.
19
+
20
+ ## Output Format
21
+
22
+ ```md
23
+ # Description - [very short title]
24
+
25
+ **Suggested commit message:** `<commit message>`
26
+
27
+ ## PR/MR Description
28
+
29
+ [description body]
30
+ ```
31
+
32
+ Start with a suggested commit message (follow the convention you are aware of, or default to `<type>: [<ticket_id>] very short description`). Refine it from the suggested commit messages found in the specs and summaries you read. Keep it brief—usually 3-5 words for the description part. Shorter is better when it's clear.
33
+
34
+ ## Guidelines for the Description Body
35
+
36
+ - Write in markdown:
37
+ - If there is one subject, write a single paragraph.
38
+ - Otherwise, write a bulleted list with one subject per item.
39
+ - **Describe only WHAT was done, never WHY.** Never include explanations, justifications, or reasoning for the changes. Only state what was implemented or modified.
40
+ - **Keep it minimal and functional.** Mention each subject very concisely—just the essentials. Most subjects can be summarized in one sentence of about 5 to 15 words.
41
+ - **Always prefer functional/business descriptions.** Avoid technical implementation details unless absolutely necessary.
42
+ - **CRITICAL: Merge related subjects whenever possible.** Look for opportunities to combine similar changes into a single, cohesive subject. This keeps the description focused and readable.
43
+ - Include technical details only for major structural changes (e.g., renaming a database table, significant linter config changes, major codebase refactors).
44
+ - Do not mention specs that were not implemented. If in doubt, explore the codebase to confirm what was actually done.
45
+ - **Absorb fix-only summaries**: If a summary is about fixing issues introduced by previous summaries in the same ticket (e.g., bug fixes, corrections, adjustments to earlier work), do not mention it as a separate subject. An external reader only cares about the end state.
46
+
47
+ ---
48
+
49
+ _Ignore lint errors (formatting issues) in the description file._
50
+
51
+ At the end, give the path of the description file to the user.
@@ -0,0 +1,65 @@
1
+ # How to Resolve Merge Conflicts
2
+
3
+ ## Pre-requisites
4
+
5
+ You need:
6
+
7
+ - the TASK_DIR — run `{{CMD}} ticket <id>` (`{{CMD}} ticket` alone deduces the id from the branch when the project defines a ticket format; `{{CMD}} ticket --side` when there is no ticket)
8
+ - the CYCLE_LETTER and FILE_NUMBER — continue the current cycle: `{{CMD}} ticket <id> --next merge.summary.md` prints the file to create
9
+
10
+ Identify and state these values before starting the protocol.
11
+
12
+ ---
13
+
14
+ This protocol applies when a merge or rebase has produced conflicts, or when the user provides an incoming branch to merge. Follow the steps below.
15
+
16
+ ## 1. Check git status
17
+
18
+ Run `git status` to check for conflicts.
19
+
20
+ **If there are no conflicts:** start the merge — use the incoming branch if the user provided one, otherwise ask which branch to merge. If the merge completes cleanly, you are done — no summary file needed. Otherwise, continue with the steps below.
21
+
22
+ ## 2. Investigate
23
+
24
+ Take the time to understand how things work in the incoming branch and in the current branch. For each conflicting file, read enough surrounding context to understand the intent on both sides.
25
+
26
+ ## 3. Resolve
27
+
28
+ Create the summary file now: a new file `{CYCLE_LETTER}{FILE_NUMBER}-merge.summary.md` in the TASK_DIR. Log each notable resolution in it as you resolve (see step 5 for the expected content).
29
+
30
+ Resolve the conflicts properly — preserve both intents whenever possible. Do not blindly accept one side.
31
+
32
+ **Special case for lock files:** If a lock file has conflicts:
33
+
34
+ 1. Accept all the changes from the incoming branch.
35
+ 2. After all other conflicts are resolved, run the proper install command so the package manager re-applies the current branch's dependency changes.
36
+
37
+ ## 4. Finalize the merge
38
+
39
+ Finalize the merge using git's default commit message (e.g. `git commit --no-edit`). Do not write your own commit message — git has already prepared the proper merge message.
40
+
41
+ ## 5. Summarize
42
+
43
+ Finalize the summary file.
44
+
45
+ **Keep it lean.** Only document challenging conflicts and the choices made to resolve them. Do not list straightforward resolutions — if everything was trivial, the summary should be almost empty (just a header and a one-line note that there was nothing tricky). Do not include a commit message — git already provides one for merges.
46
+
47
+ Example:
48
+
49
+ ```markdown
50
+ # Merge Summary - [very short title]
51
+
52
+ ## Notable resolutions
53
+
54
+ - `path/to/file.ts`: [what made it tricky and which choice was made, in one or two sentences]
55
+
56
+ ## Lock file
57
+
58
+ [Only if there was a lock file conflict: which lock file, which install command was run]
59
+ ```
60
+
61
+ Omit any section with nothing to report.
62
+
63
+ _Ignore markdown lint errors in the summary file._
64
+
65
+ At the end, give the path of the summary file to the user.
@@ -0,0 +1,256 @@
1
+ # How to Write Implementation Plans
2
+
3
+ ## Pre-requisites
4
+
5
+ ### Determine TASK_DIR, CYCLE_LETTER, and FILE_NUMBER
6
+
7
+ You need:
8
+
9
+ - the TASK_DIR — run `{{CMD}} ticket <id>` (`{{CMD}} ticket` alone deduces the id from the branch when the project defines a ticket format; `{{CMD}} ticket --side` when there is no ticket)
10
+ - the CYCLE_LETTER and FILE_NUMBER — continue the current cycle: `{{CMD}} ticket <id> --next plan.md` or `{{CMD}} ticket <id> --next main-plan.md` prints the file to create
11
+ - a **spec file** in the TASK_DIR
12
+
13
+ Identify and state these values before starting the protocol. If any of these pieces of information is missing, STOP AND ASK THE USER.
14
+
15
+ ## Phases
16
+
17
+ Before starting, **read the spec file** and understand it entirely.
18
+
19
+ In order to generate implementation plans, you MUST follow this process:
20
+
21
+ 1. **Investigation Phase**: Explore the codebase, understand the current implementation, and identify the problem
22
+ 2. **Analysis Phase**: Determine the plan structure (single or multiple plans) and identify relevant documentation and skills
23
+ 3. **Designing Phase - Implementation Plan(s)**: Design plan(s) based on the analysis - If you discover issues or missing design decisions, STOP AND ASK THE USER
24
+ 4. **Designing Phase - Main Plan**: If multiple plans, design a main plan to coordinate them
25
+ 5. **Writing Phase**: Write the plan file(s)
26
+ 6. **Review Phase**: Critically review and improve the plan(s)
27
+
28
+ ## Phase 1. Investigation Phase
29
+
30
+ Check your context for available **documentation** and **skills**. Read every document and skill relevant to any aspect of the task — this is not optional. For each skill, also **read its relevant references**.
31
+
32
+ Investigate the codebase yourself, find the relevant source code, think carefully, take the time to understand how it currently works and what has to be done.
33
+
34
+ Use the SPEC text as a starting point, but do not trust it blindly. Verify the current implementation and ensure the spec is still accurate. If you discover that an important design choice still needs to be made, or if the spec has issues, STOP AND ASK THE USER.
35
+
36
+ For each operation in the spec, search for existing functions that do a similar job.
37
+
38
+ ## Phase 2. Analysis Phase
39
+
40
+ Based on your investigation, determine the plan structure:
41
+
42
+ ### 2.1 Assess Work Scopes
43
+
44
+ Evaluate if the work should be split into multiple specialized plans or handled as a single plan:
45
+
46
+ - **Single plan**: Preferred when work is small enough to be manageable, especially if it is cohesive within one area
47
+ - **Multiple specialized plans with a main plan**: Split the work when it is complex, based on:
48
+ - **Distinct logical units**: When large enough, separate features or modules within the same stack
49
+ - **Stack boundaries**: Different technologies or specialization areas (if custom agents are defined, their descriptions can help identify these boundaries)
50
+ - Each specialized plan should produce a **coherent deliverable**
51
+
52
+ ### 2.2 Identify Relevant Documentation and Skills
53
+
54
+ Identify which **documentation** and **skills** are relevant for the work. Omit if none apply.
55
+
56
+ - List the documentation and skills that the implementing agent should read and follow. Always exclude `alignfirst` from skills.
57
+ - For complex skills with reference files, identify specific files that should be loaded
58
+
59
+ ## Phase 3. Designing Phase - Implementation Plan Structure
60
+
61
+ Design an implementation plan based on the SPEC. Include all useful information from the spec. If the spec is already detailed enough, you can extract and reuse parts of it. Add implementation details, file paths, and a breakdown into steps that weren't in the spec.
62
+
63
+ ### 3.1 Plan Content Guidelines
64
+
65
+ Follow these guidelines for all plans (single or specialized):
66
+
67
+ - The plan must be a **self-explanatory prompt** for the coding agent, so help it by explaining what you discovered that is relevant.
68
+ - Give some context: explain how it works currently, and how it will work after the task is done.
69
+ - In a "Prerequisites" section, list **relevant documentation and skills** to use. Do not repeat their content.
70
+ - Mention a way to find **important source files**: by giving file paths, or by providing a function name to search for, for example. If needed, line numbers can be mentioned in the plan.
71
+ - Include a list of **numbered steps**.
72
+ - **Never plan backward compatibility** unless explicitly requested. Prefer clean code. Unused code must be removed.
73
+ - About **tests**: First investigate the codebase to see if there are tests already in place for the kind of tests you're considering. Do not mention writing tests unless you are sure they will be well-integrated into the project.
74
+ - Do not include sections like "Benefits", "Code Style Compliance", "Rationale" or anything that adds no actionable information. Focus on the problem and the solution.
75
+ - List **existing functions to reuse or refactor**. Plan thin wrappers, not re-implementations. Each operation should have one proper place.
76
+
77
+ ### 3.2 Single Plan Format
78
+
79
+ _Use this when writing a single plan. Skip this section for multiple plans._
80
+
81
+ A single plan has no header with assignment, documentation, or skills — they are listed in the Prerequisites section within the plan body.
82
+
83
+ ### 3.3 Specialized Plan Format
84
+
85
+ _Use this when writing multiple plans. Skip this section for a single plan._
86
+
87
+ For specialized plans, add these additional requirements:
88
+
89
+ **At the top of each specialized plan**, add a header. Only include fields that have content — omit any field with nothing to list. One agent can be assigned to multiple plans (separate instances).
90
+
91
+ _Note: "Custom agent" refers to configured agent profiles in your environment (e.g., custom agents in Copilot, custom subagents in Claude Code). If your environment doesn't support this, ignore the "Assigned to" field._
92
+
93
+ Example:
94
+
95
+ ```markdown
96
+ # Specialized Plan - [Short Title Here]
97
+
98
+ - **Assigned to**: `agent-name`
99
+ - **Documentation**:
100
+ - `docs/topic-a/relevant-doc.md`
101
+ - `docs/topic-b/other-doc.md`
102
+ - **Skills**: `skill-a`, `skill-b`
103
+ ```
104
+
105
+ **In the context section**, explain what you discovered **relevant to this plan's scope** and how it works currently and will work after the task is done **within its scope**.
106
+
107
+ **In the numbered steps**, include only steps for this plan's work. Each plan should be self-contained.
108
+
109
+ **Coordination notes**: If this plan depends on another plan, mention it explicitly.
110
+
111
+ ### 3.4 Add a Final Step to Plans
112
+
113
+ _For all plans (single or specialized)_, add a final step named "Write a Handover Document" with this content:
114
+
115
+ ```markdown
116
+ Write a **handover document**. This document must contain the list of all files you updated. Also, summarize the changes made in a very concise way. Add only relevant information that will help your teammates understand what's new. Do not mention obvious information. It's not a course or a tutorial, if there is nothing to explain, then do not explain. Write this handover document in `{PLAN_FILE_PATH}.summary.md`. Ignore lint errors (formatting issues) in this file. At the end, give the path of this handover file to the user.
117
+ ```
118
+
119
+ Note:
120
+
121
+ - This is a regular step, it should be numbered like the other steps. For example, if your plan has 5 steps, this becomes step 6.
122
+ - Replace "{PLAN_FILE_PATH}" with the actual plan file path without extension (e.g., for plan `.plans/123/A2-plan-backend.md`, use `.plans/123/A2-plan-backend`, resulting in `.plans/123/A2-plan-backend.summary.md`).
123
+
124
+ ### 3.5 Common Footer for All Plans
125
+
126
+ Add the following content to the very end of each plan:
127
+
128
+ ```markdown
129
+ ---
130
+
131
+ Do not trust this plan blindly. Be sure you understand the codebase and the plan by yourself before applying it.
132
+
133
+ **IMPORTANT**: Do NOT use external search tools (Context7, web search, documentation fetching) during implementation unless explicitly allowed in this plan. All context should be provided in this plan or discoverable in the codebase.
134
+ ```
135
+
136
+ ## Phase 4. Designing Phase - Main Plan
137
+
138
+ **Create a main plan only when multiple plans are created. Skip this section entirely if not applicable.**
139
+
140
+ ### 4.1 Main Plan Guidelines
141
+
142
+ The main plan coordinates the execution of all specialized plans. It should contain:
143
+
144
+ 1. **Reference to the specification**: Mention the spec file but do not repeat its content.
145
+ 2. **Execution strategy** section: Specify if plans can be executed in parallel or must be sequential, with dependencies clearly noted.
146
+ 3. **Plan assignments** section: For each specialized plan, include only applicable fields — assignment, documentation, skills, and a brief description
147
+ 4. **Main Handover Document** section
148
+
149
+ Format example:
150
+
151
+ ````markdown
152
+ # Main Plan - [Short Title Here]
153
+
154
+ This main plan coordinates the implementation of [reference spec file].
155
+
156
+ ## Execution Strategy
157
+
158
+ **Parallel execution possible**: Plans A3, A4, and A5 are independent and can be executed simultaneously.
159
+
160
+ OR
161
+
162
+ **Sequential execution required**: A3 must complete before A4 (A4 depends on API endpoints from A3).
163
+
164
+ ## Plan Assignments
165
+
166
+ Execute these specialized plans:
167
+
168
+ 1. **Plan A** (`A3-plan-xxx.md`)
169
+ - **Assigned to**: `agent-name`
170
+ - **Documentation**:
171
+ - `docs/topic-a/doc-1.md`
172
+ - `docs/topic-b/doc-2.md`
173
+ - **Skills**: `skill-a`, `skill-b`
174
+ - **Description**: [Brief description]
175
+
176
+ 2. **Plan B** (`A4-plan-yyy.md`)
177
+ - **Documentation**:
178
+ - `docs/topic-b/doc-3.md`
179
+ - **Description**: [Brief description]
180
+
181
+ _**Important:** In the prompt you give to the subagent tool, do not reproduce the specialized plan. Instead, provide the file path._
182
+
183
+ ### Coordination Notes
184
+
185
+ [Any important notes about how the plans interact, if applicable]
186
+
187
+ ## Main Handover Document
188
+
189
+ Write a **main plan handover document**. This document should:
190
+
191
+ 1. Reference each specialized plan's handover file
192
+ 2. For each referenced handover:
193
+ - State "Completed" if the plan was executed successfully
194
+ - Detail any issues encountered during execution
195
+
196
+ Keep this handover very short. Do not combine or repeat the content of individual handovers. Write this document in `{PLAN_FILE_PATH}.summary.md`. Ignore lint errors (formatting issues) in this file.
197
+
198
+ ---
199
+
200
+ Do not trust this plan blindly. Be sure you understand the codebase and all specialized plans before coordinating their execution.
201
+
202
+ **IMPORTANT**: Do NOT use external search tools (Context7, web search, documentation fetching) during implementation unless explicitly allowed in these plans. All context should be provided in these plans or discoverable in the codebase.
203
+ ````
204
+
205
+ Note:
206
+
207
+ - Replace "{PLAN_FILE_PATH}" with the actual plan file path without extension (e.g., for plan `.plans/123/A2-main-plan.md`, use `.plans/123/A2-main-plan`, resulting in `.plans/123/A2-main-plan.summary.md`)
208
+
209
+ ## Phase 5. Writing Phase
210
+
211
+ Write the plan file(s) according to the determined structure:
212
+
213
+ Use `{{CMD}} ticket <id> --next plan.md`, `{{CMD}} ticket <id> --next main-plan.md`, or `{{CMD}} ticket <id> --next plan-<descriptor>.md` to get the next number. Run one command per file.
214
+
215
+ **Single Plan**:
216
+
217
+ - **Single plan**: `{TASK_DIR}/{CYCLE_LETTER}{FILE_NUMBER}-plan.md`
218
+ - Example: `.plans/123/A2-plan.md`
219
+ - Handover: `.plans/123/A2-plan.summary.md`
220
+ - No main plan needed
221
+
222
+ **Multiple Plans**:
223
+
224
+ - **Main plan**: `{TASK_DIR}/{CYCLE_LETTER}{FILE_NUMBER}-main-plan.md`
225
+ - Example: `.plans/123/A2-main-plan.md`
226
+ - Handover: `.plans/123/A2-main-plan.summary.md` (written after all specialized plans complete)
227
+ - **Specialized plans**: `{TASK_DIR}/{CYCLE_LETTER}{FILE_NUMBER}-plan-{DESCRIPTOR}.md`
228
+ - Use a descriptive name as `{DESCRIPTOR}` (e.g., work scope, stack area)
229
+ - Example: `.plans/123/A3-plan-api.md`, `.plans/123/A4-plan-ui.md`
230
+ - Handovers: `.plans/123/A3-plan-api.summary.md`, etc.
231
+
232
+ **Important**:
233
+
234
+ - Increment FILE_NUMBER for each plan file
235
+ - Use lowercase, hyphenated descriptors for plan names (work scope descriptor)
236
+ - When multiple plans are created, the main plan should be written first and have the lowest FILE_NUMBER
237
+ - Be careful never to overwrite an existing file
238
+
239
+ _Important Note: There will be lint errors in the markdown files you write. Ignore them. NEVER FIX LINT ERRORS (FORMATTING ISSUES) IN THE PLANS._
240
+
241
+ ## Phase 6. Review Phase
242
+
243
+ When you think the plan(s) are complete, read them again with a critical eye and edit them to improve them.
244
+
245
+ Repeat the review until you think all plans are solid.
246
+
247
+ **Additional review for multiple plans**:
248
+
249
+ - Each specialized plan is self-contained
250
+ - Each specialized plan header includes only applicable fields (assignment, documentation, skills)
251
+ - The main plan correctly references all specialized plans with their applicable fields
252
+ - Dependencies between plans are clearly documented
253
+
254
+ ---
255
+
256
+ At the end, give the path of the plan file to the user (for a single plan: the plan file; for multiple plans: the main plan file)