@coding-with-hassan/devkit 1.4.0 → 1.6.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.
- package/README.md +78 -13
- package/claude/skills/add-error-code/SKILL.md +77 -0
- package/claude/skills/merge-upstream/SKILL.md +3 -2
- package/claude/skills/open-pr/SKILL.md +132 -0
- package/claude/skills/project-setup/SKILL.md +262 -0
- package/claude/skills/sync-theme/SKILL.md +141 -0
- package/claude/skills/ticket-graph/SKILL.md +115 -0
- package/claude/standards.md +40 -0
- package/package.json +1 -1
- package/src/commands/tickets.js +53 -0
- package/src/commands/tracker.js +31 -0
- package/src/commands/worktree.js +6 -1
- package/src/core/agents-docs.js +19 -1
- package/src/core/claude.js +57 -7
- package/src/core/config.js +40 -6
- package/src/core/derive.js +9 -3
- package/src/core/tickets/graph.js +169 -0
- package/src/core/tracker/github.js +100 -1
- package/src/core/tracker/index.js +31 -4
- package/src/core/tracker/jira.js +182 -5
- package/src/core/worktrees.js +137 -22
- package/src/index.js +4 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The way of working of Hassan's client projects as one versioned package: parallel git worktrees with isolated Docker stacks, the pre-commit chain, a CI job with commit standards and an Nx cache, the Claude Code standards/agents/hooks, and the bilingual acceptance-test workbooks. A project installs it, fills one config block in `package.json`, runs `hassan-devkit init`, and picks up every later standard by bumping the version. Design: `docs/design/way-of-working.md`; decisions: `docs/adr/`.
|
|
4
4
|
|
|
5
|
-
New projects start from [hassan-devkit-template](https://github.com/CodiNG-With-Hassan/hassan-devkit-template),
|
|
5
|
+
New projects start from [hassan-devkit-template](https://github.com/CodiNG-With-Hassan/hassan-devkit-template): a maintained Nx `apps/*` + `libs/*` pnpm workspace in the shape of a real project (a NestJS API with the error-code contract, an Angular staff app, a server-rendered Angular customer site and the shared libs), already wired to this package. It reaches a running stack with `pnpm install` and `pnpm docker:dev:up`, and typing `/project-setup` in the fresh clone takes it to its setup PR (see [Claude Code layer](#claude-code-layer)). `init` is for adopting the devkit in a workspace that already exists.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -74,11 +74,13 @@ Everything a project declares lives in the `hassan-devkit` block of the root `pa
|
|
|
74
74
|
"ready": { "url": "http://localhost:${DEVKIT_PORT_API}/api-json" },
|
|
75
75
|
"env": { "API_PROXY_TARGET": "http://localhost:${DEVKIT_PORT_API}" }
|
|
76
76
|
},
|
|
77
|
-
"tracker": { "kind": "jira", "project": "DAZ", "baseUrl": "https://x.atlassian.net"
|
|
77
|
+
"tracker": { "kind": "jira", "project": "DAZ", "baseUrl": "https://x.atlassian.net",
|
|
78
|
+
"transitions": { "prOpened": "In Review", "merged": "Acceptance" } }, // optional, these are the defaults; null turns one off
|
|
78
79
|
// | { "kind": "github", "prefix": "GH" } | { "kind": "none" }
|
|
79
80
|
"commits": { "docsUrl": "https://…/Git+Workflow" }, // types/extraScopes/requireSigned/exemptAuthors have defaults
|
|
80
81
|
"ci": { "checks": [{ "name": "translations", "paths": ["^libs/i18n/"], "run": "pnpm exec nx run-many -t check-translations" }] },
|
|
81
|
-
"testCases": { "dir": "docs/testing", "languages": ["en", "nl"] }
|
|
82
|
+
"testCases": { "dir": "docs/testing", "languages": ["en", "nl"] },
|
|
83
|
+
"design": { "url": "https://claude.ai/artifact/…" } // the project's design system; the `sync-theme` skill reads it, and stores the link when it is missing
|
|
82
84
|
}
|
|
83
85
|
```
|
|
84
86
|
|
|
@@ -106,22 +108,50 @@ Managed `.env` values use fixed keys: `COMPOSE_PROJECT_NAME`, `COMPOSE_PROFILES`
|
|
|
106
108
|
|
|
107
109
|
One worktree per ticket, each with its own Docker stack (own compose project, host ports = base + slot×10, own volumes), sharing the dev images with every checkout on the same dependency manifest. Worktrees live under `worktree.baseDir` (default `../<root-name>-worktrees`); slot 0 is the main checkout. A repo without `docker/docker-compose.dev.yml` gets worktrees without a stack.
|
|
108
110
|
|
|
109
|
-
- `hassan-devkit worktree:create <BRANCH> [--profiles a,b] [--no-up]` — prune merged worktrees, fetch `upstream`/`origin` `main`, add the worktree off it, allocate the lowest free slot (under a lock), write the managed `.env`, run the tracker hook, `pnpm install`, bootstrap husky (fails loudly if `.husky/_/pre-commit` is missing), build the images the tag lacks, `up`, wait for `worktree.ready.url`, run `worktree.seeds`.
|
|
111
|
+
- `hassan-devkit worktree:create <BRANCH> [--profiles a,b] [--no-up]` — prune merged worktrees, fetch `upstream`/`origin` `main`, add the worktree off it, allocate the lowest free slot (under a lock), write the managed `.env`, run the tracker hook, `pnpm install`, bootstrap husky (fails loudly if `.husky/_/pre-commit` is missing), build the images the tag lacks, `up`, wait for `worktree.ready.url`, run `worktree.seeds`. The stack is set up from the new worktree's own `package.json` and compose file (ports, profiles, `ready`, `seeds`, `env`), not from the checkout the command is run in, which may be behind the remote `main`; only `baseDir` and `maxSlot` are read from that checkout, and a note names the `worktree` keys on which the two differ. The seed step always prints a line: `seeding: pnpm <script> (service <service>)` before each script, `no seed scripts configured (worktree.seeds.scripts)` for an empty list, `not seeding: …` when scripts are configured and the stack was not started. A failing seed script fails the command.
|
|
110
112
|
- `hassan-devkit worktree:env [--slot N]` — refresh this checkout's managed block (keeps slot + profiles, recomputes the image tag, builds missing images, drops stale `node_modules` volumes). Refuses a slot another checkout holds. `docker:up` runs it implicitly.
|
|
111
113
|
- `hassan-devkit worktree:profiles list|add|remove <names>` — the compose profiles this stack runs (derived from the compose file; `worktree.profiles.required` cannot be removed).
|
|
114
|
+
- `hassan-devkit worktree:stop` — stop the stack of the checkout it is run from (`docker compose stop` across every profile) and keep everything: containers, volumes, slot and `.env`. `pnpm docker:dev:up` starts the same stack again. It stops only a stack the devkit manages for that checkout: without a compose file, with an empty `worktree` block or without a `.env` it says why, stops nothing and exits 0. A stop that fails exits 1. `/open-pr` runs it once the PR is open.
|
|
112
115
|
- `hassan-devkit worktree:remove <BRANCH> [--keep-data] [--force]` — stack down (volumes deleted unless `--keep-data`), worktree removed, branch kept, unreferenced image tags garbage-collected.
|
|
113
|
-
- `hassan-devkit worktree:prune [--dry-run]` — remove every worktree whose PR is merged (`gh pr list --head`, base repo = `upstream`); dirty trees are never force-removed.
|
|
116
|
+
- `hassan-devkit worktree:prune [--dry-run]` — remove every worktree whose PR is merged (`gh pr list --head`, base repo = `upstream`) and report `merged` to the tracker for its ticket; dirty trees are never force-removed.
|
|
114
117
|
- `hassan-devkit worktree:list` — worktrees with slot, ports, profiles, image tag; warns on duplicate slots.
|
|
115
118
|
|
|
116
119
|
### Tracker adapters (`tracker.kind`)
|
|
117
120
|
|
|
118
|
-
| kind | on `worktree:create` | credentials |
|
|
119
|
-
| --- | --- | --- |
|
|
120
|
-
| `jira` | assign the branch's `<PROJECT>-<n>` ticket to you; `To Do` → `In Progress` | `JIRA_EMAIL`, `JIRA_API_TOKEN`, `JIRA_URL` from the environment or `~/.config/jira/env` |
|
|
121
|
-
| `github` | `gh issue edit <n> --add-assignee @me` on the base repo for a `<PREFIX>-<n>-…` branch; PR bodies end with `Closes #<n>` | `gh auth` |
|
|
122
|
-
| `none` | nothing | — |
|
|
121
|
+
| kind | on `worktree:create` | PR opened / PR merged | credentials |
|
|
122
|
+
| --- | --- | --- | --- |
|
|
123
|
+
| `jira` | assign the branch's `<PROJECT>-<n>` ticket to you; `To Do` → `In Progress` | move the ticket to `tracker.transitions.prOpened` (default `In Review`) / `.merged` (default `Acceptance`) | `JIRA_EMAIL`, `JIRA_API_TOKEN`, `JIRA_URL` from the environment or `~/.config/jira/env` |
|
|
124
|
+
| `github` | `gh issue edit <n> --add-assignee @me` on the base repo for a `<PREFIX>-<n>-…` branch; PR bodies end with `Closes #<n>` | nothing: an open PR stays the progress signal | `gh auth` |
|
|
125
|
+
| `none` | nothing | nothing | — |
|
|
123
126
|
|
|
124
|
-
|
|
127
|
+
- `hassan-devkit tracker:transition <TICKET> <prOpened|merged>` — report a PR event for a ticket (a key, or a branch name starting with it). The jira adapter moves the ticket to the status `tracker.transitions` names for the event, looked up by target status name among the ticket's available transitions; a ticket already in or past that status is left alone, and a key set to `null` turns the transition off. Run it with `prOpened` after opening the PR (the `open-pr` skill does); `worktree:prune` reports `merged` itself for the ticket of every worktree it removes.
|
|
128
|
+
|
|
129
|
+
All best effort: a missing token or unreachable tracker prints a `note:` and never blocks the worktree or fails the command (in `tracker:transition`, an unknown event name is a usage error and exits 1). `init` renders `docs/agents/issue-tracker.md`, `triage-labels.md` and `domain.md` from this config for the engineering skills.
|
|
130
|
+
|
|
131
|
+
### Ticket dependency chart (`tickets:graph`)
|
|
132
|
+
|
|
133
|
+
`hassan-devkit tickets:graph [--epic <KEY>] [--out <file>]` reads the configured tracker and prints the ticket dependencies as a Mermaid flowchart: what blocks what, and what can be started next.
|
|
134
|
+
|
|
135
|
+
- **Scope**: every ticket that is not done, plus the tickets that block them directly, so a done blocker one hop away stays visible. `--epic DAZ-241` (a bare `241` or `#241` works too) narrows to one epic and keeps the blockers from other epics.
|
|
136
|
+
- **Chart**: one subgraph per epic, an arrow from a blocker to the ticket it blocks, nodes coloured by status category (to do, in progress, done). **Ready tickets** — not started, every blocker done — are highlighted; a blocker that is not a node (an epic, an issue that could not be read) still counts until it is done. An edge that a longer path of unfinished tickets already implies is dropped (transitive reduction), so a project-wide chart stays readable.
|
|
137
|
+
- **Output**: the chart on stdout (everything else goes to stderr, so it pipes) and a Markdown page around it — chart, colour key, the ready tickets by name — in `docs/tickets/dependencies.md`. That path is in the managed `.gitignore` block (written by `init` and on every install); the chart is never committed. `--out <file>` writes somewhere else, relative to the cwd; a `.mmd` / `.mermaid` file gets the chart alone.
|
|
138
|
+
|
|
139
|
+
| kind | tickets | blocking edges | epic | status category |
|
|
140
|
+
| --- | --- | --- | --- | --- |
|
|
141
|
+
| `jira` | the issues of `tracker.project` that are not done, plus the issues blocking them; sub-tasks are left out | `Blocks` issue links | the parent | the status's own category |
|
|
142
|
+
| `github` | the open issues of the base repo, plus the issues they reference | `Blocked by #<n>` lines in the body (`Blocked by: #1, #2` and a `## Blocked by` section count too; a mention inside a sentence or a code fence does not) | the `Part of #<n>` line or `## Parent` section | closed is done, open with an assignee is in progress, open without one is to do |
|
|
143
|
+
| `none` | — the command exits with a note | | | |
|
|
144
|
+
|
|
145
|
+
Credentials are those of the adapters above. Unlike the `worktree:create` hook this is not best effort: a tracker that cannot be read fails the command.
|
|
146
|
+
|
|
147
|
+
**Unlinked dependencies (the `ticket-graph` skill).** The chart shows the dependencies the tracker holds as links; one that is only stated in a ticket description is missing from it, and the ticket it blocks can look ready. The house skill `ticket-graph` covers that gap. Asking Claude for the ticket graph, what blocks what or what to start next triggers it (or type `/ticket-graph`):
|
|
148
|
+
|
|
149
|
+
1. It runs `tickets:graph`, with `--epic` when you named one, and shows the chart.
|
|
150
|
+
2. It reads the descriptions of the tickets on the chart and looks for dependencies that have no link. One that is already linked, that the chart implies through a path of unfinished tickets, or that has a done ticket at either end is left out.
|
|
151
|
+
3. It shows the chart again with those as dashed edges and lists each with the sentence it came from.
|
|
152
|
+
4. It asks which ones to record. The confirmed ones become the links the command reads — a `Blocks` link in Jira, a `Blocked by #<n>` line appended to the GitHub issue body — and the command runs again, which shows whether each write landed.
|
|
153
|
+
|
|
154
|
+
Nothing is written to the tracker before that answer, and only the dependencies you picked are recorded.
|
|
125
155
|
|
|
126
156
|
### Pre-commit chain
|
|
127
157
|
|
|
@@ -157,11 +187,45 @@ The hook never rewrites silently. lint-staged re-stages the fixes `eslint --fix`
|
|
|
157
187
|
|
|
158
188
|
`hassan-devkit claude:install` (run by `prepare` and by `init`) wires the house standards into Claude Code without copying content:
|
|
159
189
|
|
|
160
|
-
- one `@import` line in the project's `CLAUDE.md` (`.claude/CLAUDE.md` when it exists) pulling `node_modules/@coding-with-hassan/devkit/claude/standards.md` — Docker via scripts, worktrees, commit/push consent + commit-writer, tickets, the acceptance-case quality gate, lint/format/CI parity, domain docs. In-repo imports load at launch without an approval dialog;
|
|
190
|
+
- one `@import` line in the project's `CLAUDE.md` (`.claude/CLAUDE.md` when it exists) pulling `node_modules/@coding-with-hassan/devkit/claude/standards.md` — Docker via scripts, worktrees, commit/push consent + commit-writer, tickets, the acceptance-case quality gate, lint/format/CI parity, domain docs, grilling rounds asked through the question dialog; where a house rule and a skill body differ, the house rule wins. In-repo imports load at launch without an approval dialog;
|
|
161
191
|
- `.claude/agents/commit-writer.md` as a **stub** whose body says "read the shipped file and follow it" — the stub never changes, the content ships with the devkit version;
|
|
162
|
-
- one `.claude/skills/<name>/SKILL.md` stub per skill, same pattern: the house skills `implement-ticket` and `
|
|
192
|
+
- one `.claude/skills/<name>/SKILL.md` stub per skill, same pattern: the house skills `add-error-code`, `implement-ticket`, `merge-upstream`, `open-pr`, `project-setup`, `sync-theme` and `ticket-graph` (bodies shipped by the devkit; all model-invocable except `open-pr` and `project-setup`, which are user-typed only — `merge-upstream` runs only when the user asks to bring `main` in or fix a PR's conflicts, since that ask is the consent for the merge commit; `open-pr` takes a ticket branch from finished work to an open PR, see below; `project-setup` takes a fresh template clone to its setup PR, see below; `add-error-code` names no project: it finds the API app, the i18n lib and the frontends from `hassan-devkit config:show --json` and follows the error-code contract from there; `sync-theme` derives the theme library from the project's design system, see below; `ticket-graph` is described under [Ticket dependency chart](#ticket-dependency-chart-ticketsgraph)) and every skill of the project's `mattpocock-skills` dependency — `init` adds `github:mattpocock/skills#v1.2.3` to `devDependencies`, a GitHub tarball pinned to an upstream release tag that pnpm integrity-locks — except `implement` and `setup-matt-pocock-skills`, which the house skill and `init` replace. The stub copies the skill's frontmatter verbatim (user-invocable-only skills stay user-only) and points at the body under `node_modules`. Stubs are derived on every install and **gitignored** through a managed block (which also lists the `tickets:graph` chart), so nothing is committed and a bump changes nothing in git; they are what makes the skills reach every clone and the skill pickers that only scan `.claude/skills` (T3 Code). A `SKILL.md` the project wrote itself at one of those paths (anything that is not a stub) is the project's own copy: it is neither overwritten nor gitignored, and `claude:install` prints a note until the folder is deleted, after which the stub takes over. Renovate bumps the tag (the shared preset automerges it), so an upstream skills release needs no devkit release;
|
|
163
193
|
- two managed hook entries merged idempotently into `.claude/settings.json`, both running `hassan-devkit claude:hook <id>` from the checkout's `node_modules` (recognised by that id, so a reworded command replaces the entry and the inline `jq` hook of devkit ≤ 1.2 is dropped): `pre-bash` (`PreToolUse` on `Bash`) denies `gh pr create` without `--assignee`, `docker compose` run directly, `git worktree add|remove|prune|…` and `git commit` on `ci.baseBranch` — each with the house command to use instead; `post-edit` (`PostToolUse` on `Edit|Write|MultiEdit`) runs `format:file` on the edited file and tells Claude to re-read it when Prettier changed it. The rules live in the package, so a bump adds a guard with nothing to re-commit; every hook fails open (a broken hook never blocks a tool call).
|
|
164
194
|
|
|
195
|
+
**`/open-pr`** closes a ticket's work in one user-typed step. The skill has `disable-model-invocation: true`, so Claude can never start it: typing it is the explicit ask for the commits, the push and the PR that the consent rule requires. In order, stopping at the first failure and reporting it:
|
|
196
|
+
|
|
197
|
+
1. the `merge-upstream` skill (canonical `main` in, conflicts resolved);
|
|
198
|
+
2. `hassan-devkit ci:check` and `hassan-devkit ci:affected`, on the working tree, so pending work is checked before it is committed (and checked again when the pre-commit hook rewrote a staged file);
|
|
199
|
+
3. the pending work committed through the `commit-writer` plan (skipped when there is none);
|
|
200
|
+
4. `git push -u origin <branch>`, never forced;
|
|
201
|
+
5. no open PR for the branch: `gh pr create --assignee @me`, titled `<TICKET> <Short title>` from the branch name, with a body written with the `pr` skill and ending with the tracker's ticket reference (`Closes #<n>` for GitHub); a PR already open: its body rewritten for the branch as it is now;
|
|
202
|
+
6. `hassan-devkit tracker:transition <TICKET> prOpened`;
|
|
203
|
+
7. `hassan-devkit worktree:stop`: the checkout's stack is stopped while the PR waits for review, so it no longer holds Docker memory. Nothing is removed (`worktree:prune` does that once the PR is merged), and `pnpm docker:dev:up` starts it again when review feedback needs it. A failed stop is reported and does not fail the skill;
|
|
204
|
+
8. the PR link.
|
|
205
|
+
|
|
206
|
+
It refuses to run on the base branch. When uncommitted work collides with what the merge brings in, a bare `merge-upstream` stops; here the ask for the commits is given, so the pending work is checked and committed first, then merged, and the checks run again on the merged result. The `pr` skill ships with `mattpocock-skills` from v1.3; on an older tag the body is a plain one (what changed and why, how it was verified, what to review).
|
|
207
|
+
|
|
208
|
+
**`sync-theme`** keeps the theme library in line with the project's design system, so the translation is no longer redone by prompt for each project and again at every design change. Asking Claude to sync or update the theme, the brand colours, the fonts or the logo from the design system triggers it (or type `/sync-theme`):
|
|
209
|
+
|
|
210
|
+
1. It takes the design system link from `hassan-devkit.design.url`. When the key is missing it asks for the link and stores it in the root `package.json`, so the next run needs no question.
|
|
211
|
+
2. It reads the design system (a Claude design system, read through the artifact tool): colours per colour scheme, typography, radii, spacing and the logo assets.
|
|
212
|
+
3. It updates the PrimeNG preset of the theme library, the font setup of every frontend and their logo and favicon. Values come from the design system, the structure stays the project's; a logo is copied, never redrawn. Nothing is at a fixed path: the theme library and the frontends are found through `hassan-devkit config:show --json`.
|
|
213
|
+
4. It runs `hassan-devkit ci:affected`, updates the acceptance cases that state what changed (a brand name, a logo) and reports four lists: what changed, what it derived (a ramp from a single brand colour), what in the design system has no counterpart in the preset, and what the theme keeps that the design system says nothing about.
|
|
214
|
+
|
|
215
|
+
It runs in a ticket worktree like any other change, stops on the base branch and never commits. A design token the theme has no place for is reported, not given a new token group: growing the theme stays your decision. A design system that cannot be read stops the skill; no value is guessed.
|
|
216
|
+
|
|
217
|
+
**`/project-setup`** turns a repository freshly created from the template into its project, up to the **setup PR**. Run it once, in the fresh clone after `pnpm install`. Like `/open-pr` it has `disable-model-invocation: true`: it writes outside the working tree (a ticket, a worktree, the repository's settings), so only you can start it. Every step first checks whether it is already done, so after an interruption you type it again and it continues where it stopped (the last step, the checks, runs on every run):
|
|
218
|
+
|
|
219
|
+
1. It asks for the project name, the tracker (a Jira project, or GitHub issues with a ticket key), the languages and a concept brief (a file or pasted text). It derives the slug, the database name and a set of host ports that collide with none of the projects checked out next to it, and shows them for correction.
|
|
220
|
+
2. It creates the setup ticket in the tracker, with the answers and the brief as its description, and the setup worktree: `hassan-devkit worktree:create <TICKET>-Project-Setup --no-up`.
|
|
221
|
+
3. It renames the template's placeholders in that worktree: the `hassan-devkit` config block, the project name (`template`, `Template`), the ticket key (`TPL`, and with it the `tpl-i18n` package), the host ports and the languages. Generated files are regenerated, not edited: the lockfile, the managed block of `.env.dist` and `docs/agents/*.md` (`hassan-devkit init --only env,agents`), the API spec and its packages (from the worktree's own stack, which starts here under the project's name), the acceptance workbooks.
|
|
222
|
+
4. It runs the `grill-with-docs` skill on the concept brief, which writes `CONTEXT.md` and an ADR for each decision the brief forces. `grill-with-docs` is user-typed only; typing `/project-setup` is the ask for it here.
|
|
223
|
+
5. It runs the `sync-theme` skill (skipped, and reported, when there is no design system yet).
|
|
224
|
+
6. It sets the repository settings: merge commits as the only merge method (a squash or a rebase drops the commits' signatures and standard subjects) and delete branch on merge. Branch rules are not set: they are unavailable on private repositories on the free plan. For Renovate it removes the template's own automerge rule from `renovate.json` and gives you the link to add the repository to the Renovate app, which a personal token cannot do.
|
|
225
|
+
7. It runs `hassan-devkit ci:check` and `hassan-devkit ci:affected`, then reports and hands over: you type `/open-pr` for the setup PR.
|
|
226
|
+
|
|
227
|
+
It never commits or pushes. Its report ends with what to do once the setup PR is merged: run `hassan-devkit worktree:prune` in the main checkout before bringing `main` in, because the setup worktree was created under the template's `worktree.baseDir` and the devkit stops looking there once the project's own config is in. The report also names what the merge does not reach: the main checkout's own `.env`, and with a Jira tracker the ticket's `merged` transition. Specs and tickets come after it, with the `to-spec` and `to-tickets` skills; deployment configuration is out of scope.
|
|
228
|
+
|
|
165
229
|
Project-specific rules stay in the project's own `CLAUDE.md` below the import. A devkit bump therefore changes what Claude does with nothing to re-commit.
|
|
166
230
|
|
|
167
231
|
### Acceptance test cases (`test-cases:generate`)
|
|
@@ -184,6 +248,7 @@ import { tc, type Area, type KnownIssue, type Readme } from '@coding-with-hassan
|
|
|
184
248
|
- **CI**: `init --only ci --force` writes the thin workflow; delete hand-rolled affected/cache scripts. Commit scopes are derived from the workspace (`commits:show`).
|
|
185
249
|
- **Claude**: `init --only claude,agents` adds the standards import, the stubs, the PR-assignee hook and regenerates `docs/agents`; trim your `CLAUDE.md` to project specifics.
|
|
186
250
|
- **Skills** (1.1): `init --only config` adds the `mattpocock-skills` devDependency; `pnpm install` then writes the skill stubs and the `.gitignore` block, and `claude:install` prints the one-off `git rm --cached` for the `implement-ticket` stub you committed under 1.0. With the plugin still enabled in `~/.claude`, a bare `/grilling` runs the project stub and `/mattpocock-skills:grilling` the plugin (same body).
|
|
251
|
+
- **`add-error-code`** (1.5): the skill ships with the devkit. A project with its own committed `.claude/skills/add-error-code/` keeps it, and `claude:install` says so on every install. To switch: `git rm -r .claude/skills/add-error-code`, `pnpm install` (writes the stub and adds the folder to the `.gitignore` block), commit the deletion with `.gitignore`. Keep the project's `.claude/rules/api-errors.md`: the shipped skill reads the project-specific names from it.
|
|
187
252
|
- Adopt piece by piece with `init --only <part>`; `ci:doctor` reports what is not adopted yet.
|
|
188
253
|
|
|
189
254
|
## Layout-agnostic commands
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-error-code
|
|
3
|
+
description: "Add a client-facing API error code end to end, the house error-code contract: the ErrorCode enum member in the API app, the text in every language's ERRORS catalog of the i18n lib plus the ERROR_CODES / ERROR_CODE_PARAMS mirrors, the spec and generated API packages regenerated from THIS worktree's running API, the reachability note and the acceptance cases. Use whenever a new failure needs a code, or check-translations fails on catalog/enum drift."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# add-error-code (body shipped by @coding-with-hassan/devkit)
|
|
7
|
+
|
|
8
|
+
The contract: the API returns codes, never user-facing text; the frontends translate each code
|
|
9
|
+
from one shared `ERRORS` catalog. A project that has adopted the contract states its own
|
|
10
|
+
version of it in `.claude/rules/api-errors.md` and the ADR that file names. When the file
|
|
11
|
+
exists, read both first: they give the names this file cannot know (the pipe that renders an
|
|
12
|
+
error, the scripts), and where they are more specific than this file, they win.
|
|
13
|
+
|
|
14
|
+
## 1. Find the pieces
|
|
15
|
+
|
|
16
|
+
Run `hassan-devkit config:show --json` from the checkout root. `derived.projects[]` lists every
|
|
17
|
+
workspace project with its `name`, `dir`, `kind` and `packageName`; nothing below is at a fixed
|
|
18
|
+
path, so take every path from there.
|
|
19
|
+
|
|
20
|
+
- **API app**: the project with `kind: "api"`. Its `src` holds the `ErrorCode` enum
|
|
21
|
+
(`grep -rn "enum ErrorCode" <api dir>/src`) and, next to it, `DomainException`. With more
|
|
22
|
+
than one `api` project, the one that holds the enum.
|
|
23
|
+
- **i18n lib**: the `kind: "lib"` project whose `src/errors/` holds the catalogs, one
|
|
24
|
+
`<lang>.json` per supported language. Those files are the language list: list the folder,
|
|
25
|
+
never assume a count. The same lib holds the mirrors `src/error-codes.ts` (`ERROR_CODES`) and
|
|
26
|
+
`src/error-code-params.ts` (`ERROR_CODE_PARAMS`), and its `README.md` has the "Register per
|
|
27
|
+
language" table.
|
|
28
|
+
- **Frontends**: every project with `kind: "spa"`, web and mobile alike.
|
|
29
|
+
- **Acceptance cases**: `config.testCases.dir` and `config.testCases.languages`.
|
|
30
|
+
`config.testCases` is `null` in a project that has not configured its acceptance cases.
|
|
31
|
+
|
|
32
|
+
Stop and report when a piece is missing (no `api` project, no `ErrorCode` enum, no
|
|
33
|
+
`src/errors/` catalogs). The project has not adopted the contract then; this skill adds a code
|
|
34
|
+
to an existing contract, and introducing the contract is a design decision for the user.
|
|
35
|
+
|
|
36
|
+
## 2. One change, in this order
|
|
37
|
+
|
|
38
|
+
Every partial state fails `check-translations` or the pre-commit guard.
|
|
39
|
+
|
|
40
|
+
1. **API**: add the enum member as `NAME = 'NAME'` (value equals name; append it to its domain
|
|
41
|
+
block) with a JSDoc line giving the HTTP status and, when it carries params, a
|
|
42
|
+
`` Params: `a`, `b` `` note. Throw it with
|
|
43
|
+
`new DomainException(ErrorCode.NAME, 'English debug message', HttpStatus.X, { a, b })`.
|
|
44
|
+
2. **Catalog**: add the text to every `<lang>.json` under the i18n lib's `src/errors/`, in the
|
|
45
|
+
register its README sets for that language, with counts phrased count-neutrally (never
|
|
46
|
+
`file(s)`). Add the code to `ERROR_CODES`. If the text interpolates `{{a}}`, add the code to
|
|
47
|
+
`ERROR_CODE_PARAMS`: the placeholders must be identical in every language, equal that entry,
|
|
48
|
+
and appear in the member's `Params:` note. Never add a catalog-only key: `UNKNOWN` is the
|
|
49
|
+
only one (hard-coded in the project's error-translations check script).
|
|
50
|
+
3. **Contract**: with THIS worktree's stack running (`pnpm docker:dev:up`, then
|
|
51
|
+
`pnpm docker:dev:logs` until the API has recompiled), run the project's contract script
|
|
52
|
+
(`pnpm api:types`; the root `package.json` and `.claude/rules/api-contract.md` name it). It
|
|
53
|
+
regenerates the OpenAPI spec and the generated API packages from this worktree's own port.
|
|
54
|
+
The regenerated files belong in the same commit as the enum change: the enum file is a
|
|
55
|
+
contract file, so the pre-commit guard rejects it without the spec, and the check fails
|
|
56
|
+
while the committed spec's `ErrorCode` enum differs from the API enum.
|
|
57
|
+
4. **Cache**: nothing to bump. The catalog is served un-hashed with `Cache-Control: no-cache`,
|
|
58
|
+
and every frontend's translation loader takes the frozen `I18N_CATALOG_VERSION` from the
|
|
59
|
+
i18n lib (`grep -rn I18N_CATALOG_VERSION` over the `spa` dirs finds them). Never reintroduce
|
|
60
|
+
a per-app `version` literal.
|
|
61
|
+
5. **Reachability**: every code must be reachable from some UI, or its enum JSDoc must state
|
|
62
|
+
that it is server-side-only (jobs, webhooks, mock-only endpoints).
|
|
63
|
+
6. **Acceptance cases**: cover the new user-visible failure in the `tc-data-*.ts` files under
|
|
64
|
+
`testCases.dir`, in every one of `testCases.languages`, then run
|
|
65
|
+
`hassan-devkit test-cases:generate`. With `testCases` `null`, skip this step and say in
|
|
66
|
+
the report that the failure has no acceptance case.
|
|
67
|
+
|
|
68
|
+
## 3. Verify before reporting
|
|
69
|
+
|
|
70
|
+
- `pnpm exec nx run-many -t check-translations` (catalog ↔ enum, mirrors, placeholders, the
|
|
71
|
+
language mirror and the committed spec's `ErrorCode` enum) and the contract drift check
|
|
72
|
+
(`pnpm api:types:check`).
|
|
73
|
+
- The new code is thrown from the API path that needs it and rendered by the UI that reaches
|
|
74
|
+
it, through `toErrorTranslation` and the pipe or component the project's
|
|
75
|
+
`.claude/rules/api-errors.md` names. Never a string literal, in the comparison or the text.
|
|
76
|
+
- Do not commit: report the change set as ready for review (the enum, the catalogs, the
|
|
77
|
+
mirrors, the spec and the generated packages, the acceptance cases).
|
|
@@ -6,8 +6,9 @@ description: "Bring the canonical remote's main into the current checkout the ho
|
|
|
6
6
|
# merge-upstream (body shipped by @coding-with-hassan/devkit)
|
|
7
7
|
|
|
8
8
|
Bring the canonical `main` into the checkout you are in. Run it only when the user asks for
|
|
9
|
-
it in their own words, in the current request: typing `/merge-upstream`,
|
|
10
|
-
`main` in, update the branch or fix its PR's
|
|
9
|
+
it in their own words, in the current request: typing `/merge-upstream`, typing `/open-pr`
|
|
10
|
+
(this skill is its first step), or asking to bring `main` in, update the branch or fix its PR's
|
|
11
|
+
conflicts. That ask is the consent for exactly one
|
|
11
12
|
commit, the merge commit. A branch that is merely behind, or a PR you notice conflicts, is never
|
|
12
13
|
a reason to run it unasked: report it and let the user decide. Never rebase (branches are shared
|
|
13
14
|
through their PRs and the house merges).
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: open-pr
|
|
3
|
+
description: "From finished work to an open pull request in one go, the house way: bring the canonical main in, run ci:check and ci:affected, commit the pending work through the commit-writer plan, push, open the PR (or rewrite the body of the one already open), report it to the tracker and stop the checkout's Docker stack. User-typed only: typing /open-pr is the explicit ask for the commits, the push and the PR."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# open-pr (body shipped by @coding-with-hassan/devkit)
|
|
8
|
+
|
|
9
|
+
Take the branch you are on from finished work to an open pull request. Only the user starts
|
|
10
|
+
this skill: typing `/open-pr` in the current request is their explicit ask for everything
|
|
11
|
+
below — the commits (the merge commit of step 1 among them), the push and the PR. If you are
|
|
12
|
+
reading this file for any other reason (another skill or a plan pointed here, the work looks
|
|
13
|
+
ready to you), stop: that is not consent.
|
|
14
|
+
|
|
15
|
+
Run the steps in order. Stop at the first failure and report it: the step, the output that
|
|
16
|
+
shows the failure, and what is already done (merged, committed, pushed). Do not repair a failed
|
|
17
|
+
check and carry on; the one exception is the hook rewrite in step 3. Step 7 is the one step
|
|
18
|
+
whose failure does not stop the skill. Never get past a step by going around it
|
|
19
|
+
(`--no-verify`, a forced push).
|
|
20
|
+
|
|
21
|
+
## Before step 1: where you are
|
|
22
|
+
|
|
23
|
+
- Run everything from the checkout's root (`git rev-parse --show-toplevel`).
|
|
24
|
+
- Canonical remote: `upstream` when it exists (`git remote get-url upstream`), else `origin`.
|
|
25
|
+
Base branch: `ci.baseBranch` from `hassan-devkit config:show --json` (default `main`).
|
|
26
|
+
- Branch: `git branch --show-current`. On the base branch, or on no branch at all, refuse: stop
|
|
27
|
+
and say that ticket work lives in a worktree (`hassan-devkit worktree:create
|
|
28
|
+
<TICKET>-<Short-Title>`). Nothing is merged, committed or pushed.
|
|
29
|
+
- Ticket: the key the branch name starts with (`<TICKET>-<Short-Title>`; `hassan-devkit
|
|
30
|
+
commits:show` prints its pattern). With the tracker `none` there is no ticket: the title and
|
|
31
|
+
the body in step 5 then carry none.
|
|
32
|
+
|
|
33
|
+
## 1. Bring `main` in
|
|
34
|
+
|
|
35
|
+
Run the `merge-upstream` skill, with these differences:
|
|
36
|
+
|
|
37
|
+
- Typing `/open-pr` is the consent for its merge commit.
|
|
38
|
+
- Up to date is not a stop here: go on with step 2.
|
|
39
|
+
- It stops when an incoming path is also modified and uncommitted in this checkout. Here the
|
|
40
|
+
user has asked for the commits, so do steps 2 and 3 first (check the pending work, then
|
|
41
|
+
commit it), run the merge again and resolve what conflicts, then run step 2 again on the
|
|
42
|
+
merged result. Nothing is committed unchecked, and nothing unchecked is pushed.
|
|
43
|
+
- Do not send its report. Keep the facts (range merged, conflicts resolved, installs run) for
|
|
44
|
+
step 8.
|
|
45
|
+
|
|
46
|
+
## 2. Run what CI runs
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
hassan-devkit ci:check
|
|
50
|
+
hassan-devkit ci:affected
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Both read the working tree, so the uncommitted work is checked too. A failure in either one:
|
|
54
|
+
stop and report it.
|
|
55
|
+
|
|
56
|
+
## 3. Commit the pending work
|
|
57
|
+
|
|
58
|
+
`git status --porcelain` prints nothing: there is nothing to commit, go to step 4.
|
|
59
|
+
|
|
60
|
+
Otherwise invoke the `commit-writer` agent on the full pending change set BEFORE staging
|
|
61
|
+
anything, giving it the ticket. Execute its plan verbatim: per commit, stage the listed files
|
|
62
|
+
and commit with the drafted message, one commit at a time, in order. Commits are signed and
|
|
63
|
+
carry no AI attribution.
|
|
64
|
+
|
|
65
|
+
When the pre-commit hook aborts because it rewrote staged files, the fixes are already staged:
|
|
66
|
+
review them (`git diff --cached`), run step 2 again because the tree changed, then run the same
|
|
67
|
+
commit again. Any other hook or signing failure: stop and report it.
|
|
68
|
+
|
|
69
|
+
## 4. Push
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
git push -u origin <branch>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`origin` is where your branches go: the canonical repository, or your fork of it. A rejected
|
|
76
|
+
push means the remote branch has commits this checkout lacks: stop and report it.
|
|
77
|
+
|
|
78
|
+
## 5. Open the PR, or bring the open one up to date
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
gh pr list --head <branch> --state open --json number,url
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Write the body to a temporary file outside the checkout, then:
|
|
85
|
+
|
|
86
|
+
- **No open PR**: `gh pr create --assignee @me --base <base> --title "<title>" --body-file <file>`.
|
|
87
|
+
The title is the branch's ticket followed by its short title as words:
|
|
88
|
+
`<TICKET>-Fix-Login-Redirect` becomes `<TICKET> Fix login redirect`.
|
|
89
|
+
- **The body** describes the whole branch as it is now, from `git log <remote>/<base>..HEAD`
|
|
90
|
+
and `git diff <remote>/<base>...HEAD`: not the latest commits, not the conversation. Write it
|
|
91
|
+
with the `pr` skill when the project has one (`.claude/skills/pr/SKILL.md`); without it, say
|
|
92
|
+
what changed and why, how it was verified, and what a reviewer should look at. Its last line
|
|
93
|
+
is the tracker's ticket reference: `Closes #<n>` for GitHub issues, so the issue closes on
|
|
94
|
+
merge; the ticket key on a line of its own for a tracker without a closing keyword.
|
|
95
|
+
- **A PR already open**: `gh pr edit <number> --body-file <file>`. Rewrite the whole body the
|
|
96
|
+
same way; do not append an update note to the old one.
|
|
97
|
+
|
|
98
|
+
## 6. Report the PR to the tracker
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
hassan-devkit tracker:transition <TICKET> prOpened
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Run it whether the PR was created or updated; the branch name works as `<TICKET>`. The command
|
|
105
|
+
is best effort by design: it exits 0, and a `note:` means the tracker moved nothing. Pass the
|
|
106
|
+
note on in step 8; it is not a failure. Skip this step with the tracker `none`.
|
|
107
|
+
|
|
108
|
+
## 7. Stop the stack
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
hassan-devkit worktree:stop
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Run it whether the PR was created or updated. The PR now waits for review, and until then the
|
|
115
|
+
checkout's containers only hold Docker memory that every session on the machine shares. The
|
|
116
|
+
command stops them and removes nothing: the containers, their data, the slot and `.env` stay,
|
|
117
|
+
and `pnpm docker:dev:up` from the checkout's root starts the same stack again. Removing the
|
|
118
|
+
stack is not part of this skill; `hassan-devkit worktree:prune` does that once the PR is
|
|
119
|
+
merged. Where the checkout has no stack of its own the command says why, stops nothing and
|
|
120
|
+
exits 0.
|
|
121
|
+
|
|
122
|
+
A non-zero exit here is not a failure of the skill: the PR is open. Keep the output for step 8
|
|
123
|
+
and do not try another way to stop the stack.
|
|
124
|
+
|
|
125
|
+
## 8. Report
|
|
126
|
+
|
|
127
|
+
The PR link first. Then, briefly: created or updated, what step 1 merged (or that the branch
|
|
128
|
+
was up to date), the commits made, and any `note:` from step 6. Last, what step 7 did, one of:
|
|
129
|
+
|
|
130
|
+
- the stack is stopped, and `pnpm docker:dev:up` starts it again;
|
|
131
|
+
- nothing was stopped, with the reason the command gave;
|
|
132
|
+
- `note:` the stop failed and the stack is still running, with the command's output.
|