@next-friday/create-app 2.1.9 → 4.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 (129) hide show
  1. package/package.json +1 -1
  2. package/templates/base/.agents/agents.json +7 -0
  3. package/templates/base/.agents/hooks/agent-format-after-edit.sh +15 -0
  4. package/templates/base/.agents/hooks/agent-production-gate.sh +10 -0
  5. package/templates/base/.agents/hooks/agent-test-edit-gate.sh +25 -0
  6. package/templates/base/.agents/review.md +21 -0
  7. package/templates/base/.agents/rules/no-suppression.md +1 -1
  8. package/templates/base/.agents/skills/babysit-pr/SKILL.md +8 -0
  9. package/templates/base/.agents/skills/brand-policy/SKILL.md +12 -0
  10. package/templates/base/.agents/skills/compliance-policy/SKILL.md +12 -0
  11. package/templates/base/{.cursor/rules/git-workflow.mdc → .agents/skills/git-workflow/SKILL.md} +2 -2
  12. package/templates/base/{.cursor/rules/script-driven-changes.mdc → .agents/skills/script-driven-changes/SKILL.md} +2 -2
  13. package/templates/base/.agents/skills/security-policy/SKILL.md +12 -0
  14. package/templates/base/.agents/skills/ux-policy/SKILL.md +12 -0
  15. package/templates/base/.agents/skills/write-intent/SKILL.md +30 -0
  16. package/templates/base/.agents/skills/write-spec/SKILL.md +12 -0
  17. package/templates/base/.claude/managed-settings.example.json +26 -0
  18. package/templates/base/.claude/settings.json +31 -0
  19. package/templates/base/.claude/skills/babysit-pr/SKILL.md +8 -0
  20. package/templates/base/.claude/skills/brand-policy/SKILL.md +12 -0
  21. package/templates/base/.claude/skills/compliance-policy/SKILL.md +12 -0
  22. package/templates/base/{.agents/rules/git-workflow.md → .claude/skills/git-workflow/SKILL.md} +5 -0
  23. package/templates/base/{.agents/rules/script-driven-changes.md → .claude/skills/script-driven-changes/SKILL.md} +5 -0
  24. package/templates/base/.claude/skills/security-policy/SKILL.md +12 -0
  25. package/templates/base/.claude/skills/ux-policy/SKILL.md +12 -0
  26. package/templates/base/.claude/skills/write-intent/SKILL.md +30 -0
  27. package/templates/base/.claude/skills/write-spec/SKILL.md +12 -0
  28. package/templates/base/.cursor/BUGBOT.md +3 -2
  29. package/templates/base/.cursor/hooks.json +15 -0
  30. package/templates/base/.cursor/rules/no-suppression.mdc +1 -1
  31. package/templates/base/.cursor/skills/babysit-pr/SKILL.md +8 -0
  32. package/templates/base/.cursor/skills/brand-policy/SKILL.md +12 -0
  33. package/templates/base/.cursor/skills/compliance-policy/SKILL.md +12 -0
  34. package/templates/base/.cursor/skills/git-workflow/SKILL.md +15 -0
  35. package/templates/base/.cursor/skills/script-driven-changes/SKILL.md +12 -0
  36. package/templates/base/.cursor/skills/security-policy/SKILL.md +12 -0
  37. package/templates/base/.cursor/skills/ux-policy/SKILL.md +12 -0
  38. package/templates/base/.cursor/skills/write-intent/SKILL.md +30 -0
  39. package/templates/base/.cursor/skills/write-spec/SKILL.md +12 -0
  40. package/templates/base/.github/workflows/agent-evals.yml +128 -0
  41. package/templates/base/.github/workflows/claude.yml +39 -0
  42. package/templates/base/.github/zizmor.yml +1 -1
  43. package/templates/base/REVIEW.md +21 -0
  44. package/templates/base/SETUP.md +108 -0
  45. package/templates/base/bands.yaml +10 -0
  46. package/templates/base/evals/README.md +15 -0
  47. package/templates/base/evals/check.sh +17 -0
  48. package/templates/base/intent/README.md +8 -0
  49. package/templates/base/lessons/README.md +3 -0
  50. package/templates/base/scripts/sync-agent-rules.ts +111 -1
  51. package/templates/nestjs/.agents/agents/verifier.md +1 -0
  52. package/templates/nestjs/.agents/rules.json +23 -9
  53. package/templates/nestjs/.claude/agents/verifier.md +7 -0
  54. package/templates/nestjs/.claude/rules/constitution-changes.md +25 -0
  55. package/templates/nestjs/.claude/rules/diagnostics-and-error-handling.md +13 -0
  56. package/templates/nestjs/.claude/rules/structured-logging.md +9 -0
  57. package/templates/nestjs/.cursor/agents/verifier.md +7 -0
  58. package/templates/{base → nestjs}/.cursor/rules/constitution-changes.mdc +2 -1
  59. package/templates/{base → nestjs}/.cursor/rules/diagnostics-and-error-handling.mdc +2 -1
  60. package/templates/{base → nestjs}/.cursor/rules/structured-logging.mdc +2 -1
  61. package/templates/nestjs/.github/workflows/ci.yml +44 -0
  62. package/templates/nestjs/AGENTS.md +17 -4
  63. package/templates/nestjs/README.md +1 -16
  64. package/templates/nextjs/.agents/agents/verifier.md +1 -0
  65. package/templates/nextjs/.agents/mcp.json +8 -0
  66. package/templates/nextjs/.agents/rules.json +23 -9
  67. package/templates/nextjs/.claude/agents/verifier.md +7 -0
  68. package/templates/nextjs/.claude/rules/constitution-changes.md +25 -0
  69. package/templates/nextjs/.claude/rules/diagnostics-and-error-handling.md +15 -0
  70. package/templates/nextjs/.claude/rules/structured-logging.md +11 -0
  71. package/templates/nextjs/.cursor/agents/verifier.md +7 -0
  72. package/templates/nextjs/.cursor/mcp.json +8 -0
  73. package/templates/nextjs/.cursor/rules/constitution-changes.mdc +11 -0
  74. package/templates/nextjs/.cursor/rules/diagnostics-and-error-handling.mdc +13 -0
  75. package/templates/nextjs/.cursor/rules/structured-logging.mdc +9 -0
  76. package/templates/nextjs/.github/workflows/ci.yml +44 -0
  77. package/templates/nextjs/.mcp.json +8 -0
  78. package/templates/nextjs/AGENTS.md +17 -4
  79. package/templates/nextjs/README.md +1 -16
  80. package/templates/nodejs/.agents/agents/verifier.md +1 -0
  81. package/templates/nodejs/.agents/rules.json +23 -9
  82. package/templates/nodejs/.claude/agents/verifier.md +7 -0
  83. package/templates/nodejs/.claude/rules/constitution-changes.md +25 -0
  84. package/templates/nodejs/.claude/rules/diagnostics-and-error-handling.md +13 -0
  85. package/templates/nodejs/.claude/rules/structured-logging.md +9 -0
  86. package/templates/nodejs/.cursor/agents/verifier.md +7 -0
  87. package/templates/nodejs/.cursor/rules/constitution-changes.mdc +11 -0
  88. package/templates/nodejs/.cursor/rules/diagnostics-and-error-handling.mdc +13 -0
  89. package/templates/nodejs/.cursor/rules/structured-logging.mdc +9 -0
  90. package/templates/nodejs/.github/workflows/ci.yml +44 -0
  91. package/templates/nodejs/AGENTS.md +17 -4
  92. package/templates/nodejs/README.md +1 -16
  93. package/templates/payload/.agents/agents/verifier.md +1 -0
  94. package/templates/payload/.agents/mcp.json +8 -0
  95. package/templates/payload/.agents/rules.json +23 -9
  96. package/templates/payload/.claude/agents/verifier.md +7 -0
  97. package/templates/payload/.claude/rules/constitution-changes.md +25 -0
  98. package/templates/payload/.claude/rules/diagnostics-and-error-handling.md +15 -0
  99. package/templates/payload/.claude/rules/structured-logging.md +11 -0
  100. package/templates/payload/.cursor/agents/verifier.md +7 -0
  101. package/templates/payload/.cursor/mcp.json +8 -0
  102. package/templates/payload/.cursor/rules/constitution-changes.mdc +11 -0
  103. package/templates/payload/.cursor/rules/diagnostics-and-error-handling.mdc +13 -0
  104. package/templates/payload/.cursor/rules/structured-logging.mdc +9 -0
  105. package/templates/payload/.github/workflows/ci.yml +44 -0
  106. package/templates/payload/.mcp.json +8 -0
  107. package/templates/payload/AGENTS.md +17 -4
  108. package/templates/payload/README.md +1 -16
  109. package/templates/turborepo/.agents/agents/verifier.md +1 -0
  110. package/templates/turborepo/.agents/mcp.json +8 -0
  111. package/templates/turborepo/.agents/rules.json +23 -9
  112. package/templates/turborepo/.claude/agents/verifier.md +7 -0
  113. package/templates/turborepo/.claude/rules/constitution-changes.md +25 -0
  114. package/templates/turborepo/.claude/rules/diagnostics-and-error-handling.md +15 -0
  115. package/templates/turborepo/.claude/rules/structured-logging.md +11 -0
  116. package/templates/turborepo/.cursor/agents/verifier.md +7 -0
  117. package/templates/turborepo/.cursor/mcp.json +8 -0
  118. package/templates/turborepo/.cursor/rules/constitution-changes.mdc +11 -0
  119. package/templates/turborepo/.cursor/rules/diagnostics-and-error-handling.mdc +13 -0
  120. package/templates/turborepo/.cursor/rules/structured-logging.mdc +9 -0
  121. package/templates/turborepo/.github/workflows/ci.yml +44 -0
  122. package/templates/turborepo/.mcp.json +8 -0
  123. package/templates/turborepo/AGENTS.md +17 -4
  124. package/templates/turborepo/README.md +1 -16
  125. package/templates/base/.claude/rules/constitution-changes.md +0 -1
  126. package/templates/base/.claude/rules/diagnostics-and-error-handling.md +0 -1
  127. package/templates/base/.claude/rules/git-workflow.md +0 -1
  128. package/templates/base/.claude/rules/script-driven-changes.md +0 -1
  129. package/templates/base/.claude/rules/structured-logging.md +0 -1
@@ -164,6 +164,50 @@ jobs:
164
164
  environment: dev
165
165
  commit_sha: ${{ github.sha }}
166
166
 
167
+ triage:
168
+ name: Triage failed build
169
+ needs:
170
+ - checks
171
+ - image
172
+ if: failure() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
173
+ runs-on: ubuntu-latest
174
+ timeout-minutes: 15
175
+ permissions:
176
+ actions: read # Needed to read the logs of the failed jobs.
177
+ id-token: write # Needed to authenticate to Anthropic with the workflow's OIDC token.
178
+ pull-requests: write # Needed to post the summary on the pull request.
179
+ steps:
180
+ - name: Collect the build log
181
+ env:
182
+ GH_TOKEN: ${{ github.token }}
183
+ REPOSITORY: ${{ github.repository }}
184
+ RUN_ID: ${{ github.run_id }}
185
+ run: |
186
+ mkdir -p out
187
+ for job in $(gh api "repos/$REPOSITORY/actions/runs/$RUN_ID/jobs" --paginate --jq '.jobs[] | select(.conclusion == "failure") | .id'); do
188
+ gh api "repos/$REPOSITORY/actions/jobs/$job/logs" >> out/build.log
189
+ done
190
+ - name: Triage failed build
191
+ id: triage
192
+ uses: anthropics/claude-code-action@61a9c274fa7110a66dfafc1bbbced03833eb25fe # v1.0.269
193
+ with:
194
+ anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
195
+ anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
196
+ prompt: >
197
+ Read the build log at out/build.log. Identify the most
198
+ likely cause, say whether the failure looks flaky or real, and write a
199
+ three-line summary for the PR thread.
200
+ claude_args: >-
201
+ --allowedTools "Read"
202
+ --json-schema '{"type":"object","properties":{"summary":{"type":"string"}},"required":["summary"]}'
203
+ - name: Post the summary
204
+ env:
205
+ GH_TOKEN: ${{ github.token }}
206
+ PR_NUMBER: ${{ github.event.pull_request.number }}
207
+ REPOSITORY: ${{ github.repository }}
208
+ SUMMARY: ${{ fromJSON(steps.triage.outputs.structured_output).summary }}
209
+ run: gh pr comment "$PR_NUMBER" --repo "$REPOSITORY" --body "$SUMMARY"
210
+
167
211
  ci:
168
212
  name: All Checks
169
213
  if: always()
@@ -13,18 +13,31 @@ TypeScript HTTP service on `node:http`, without a framework, on pnpm and Node.js
13
13
  | Every check | `pnpm verify` |
14
14
  | Render rules after a change | `pnpm rules:sync` |
15
15
 
16
- ## How it fits together
16
+ ## Verifying your work
17
+
18
+ - Build: `pnpm build` (prints nothing after `$ tsc -p tsconfig.build.json`)
19
+ - Test: `pnpm test:coverage` (all green, then the coverage summary; never skip or delete a failing test)
20
+ - Lint: `pnpm verify:static` (ESLint allows zero warnings; prints `✔ no dependency violations found`)
21
+
22
+ Run all three before reporting any task complete, and paste the output. `pnpm verify` runs all three.
23
+ If a test fails, fix the code, not the test.
24
+
25
+ ## Architecture
17
26
 
18
27
  - `src/main.ts` starts `createAppServer()` from `src/server.ts` on `parsePort(process.env.PORT)`, and on `SIGTERM` or `SIGINT` stops accepting connections and closes any left after 10 seconds.
19
28
  - `src/server.ts` answers `GET` and `HEAD` `/health` and returns 404 for every other request. Routes go there.
20
29
 
21
- ## Mandatory rules
30
+ ## Conventions
22
31
 
23
- 1. **Follow `.agents/rules/`.** `.agents/rules.json` gives each rule's scope; Claude Code and Cursor load them. After changing either, run `pnpm rules:sync`; `pnpm check` fails on stale copies.
32
+ 1. **Follow `.agents/rules/`.** `.agents/rules.json` gives each rule's scope; Claude Code and Cursor load them. After changing either, or a skill or subagent in `.agents/skills/` or `.agents/agents/`, run `pnpm rules:sync`; `pnpm check` fails on stale copies.
24
33
  2. **Put tests next to the code as `src/**/*.test.ts`.** Vitest collects only that pattern.
25
34
  3. **Read configuration from environment variables and fail when one is missing**, as `parsePort` does. Document each variable in `.env.example`; `pnpm start` and `pnpm start:dev` load `.env`.
35
+ 4. **Start from the accepted spec, in plan mode.** Claude Code starts every session in plan mode (`.claude/settings.json`); in Cursor, switch to Plan Mode before the first edit. Give the plan the change's `intent/<change>/intent.md` and `spec.md`, and have it name the files that change, the order of the work, and the tests that prove it. Commit the approved plan as `intent/<change>/plan.md`. When implementation departs from the plan, update `plan.md` in the same commit.
36
+ 5. **Start a bug fix with a failing test.** Reproduce the bug as a test, run it, and confirm it fails for the reason you expect. Commit that test. Then create `.git/bug-fix-in-progress`, so `.agents/hooks/agent-test-edit-gate.sh` blocks test edits, and make the test pass without editing it. Delete `.git/bug-fix-in-progress` when the fix is done.
37
+
38
+ ## Things Claude gets wrong
26
39
 
27
- ## Known pitfalls
40
+ When Claude makes a mistake twice, add the correction here.
28
41
 
29
42
  - **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that writes to a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`. It is a convenience, not a security boundary: CI and code-owner review are the boundary.
30
43
 
@@ -14,22 +14,7 @@ The server listens on the port set by `PORT` in `.env`, which the CLI created fr
14
14
 
15
15
  ## After creating a project from this template
16
16
 
17
- 1. Install gitleaks and jq (see [CONTRIBUTING.md](CONTRIBUTING.md)). Make the first commit on `main` and push it. The Git hooks allow only this first commit and push on `main`; work on branches after that.
18
-
19
- ```sh
20
- git add --all
21
- git commit -m "chore(repo): start from template"
22
- git push --set-upstream origin main
23
- ```
24
-
25
- 2. Add your team as the owner of every file in `.github/CODEOWNERS`, and replace the owner placeholder in `.github/zizmor.yml`.
26
- 3. Replace the template's description and owner: `package.json#description`, `repository.url`, and `author`. Change `license` from `UNLICENSED` if the project is open source.
27
- 4. In the repository settings:
28
- - **Actions → General → Workflow permissions:** select **Read repository contents and packages permissions**. Every workflow requests the extra permissions it needs.
29
- - **Advanced Security:** enable private vulnerability reporting, Dependabot alerts, Dependabot security updates, secret scanning, and push protection. `SECURITY.md` sends reporters to private vulnerability reporting.
30
- - **Cursor Bugbot:** enable the repository at [Bugbot](https://cursor.com/automations/from-cursor/bugbot). Bugbot reviews pull requests against the rules linked from `.cursor/BUGBOT.md`.
31
- - **Rules → Rulesets:** protect `main` with squash merges only, a linear history, no force pushes or deletion, and the required checks `All Checks` and `Validate pull request title`. Rulesets in a private repository need GitHub Pro, Team, or Enterprise; on GitHub Free, make the repository public or upgrade.
32
- - Create the `needs triage` label, which the issue forms apply: `gh label create "needs triage"`.
17
+ Follow [SETUP.md](SETUP.md) in order. It sets up the repository, the reviews, and the AI-native SDLC.
33
18
 
34
19
  ## Scripts
35
20
 
@@ -0,0 +1 @@
1
+ Start the app with `pnpm dev`. Exercise the changed behavior and the two nearest neighboring flows. Report what you ran, what you saw, and any behavior that does not match plan.md. Do not fix anything; report only.
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "playwright": {
4
+ "command": "npx",
5
+ "args": ["@playwright/mcp@0.0.83"]
6
+ }
7
+ }
8
+ }
@@ -12,7 +12,25 @@
12
12
  "description": "Codebase hygiene: modify existing code instead of accumulating new code"
13
13
  },
14
14
  "constitution-changes": {
15
- "description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
15
+ "description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue",
16
+ "globs": [
17
+ ".agents/rules/**",
18
+ ".agents/rules.json",
19
+ ".agents/hooks/**",
20
+ ".claude/settings.json",
21
+ ".claude/rules/**",
22
+ ".cursor/rules/**",
23
+ ".cursor/hooks/**",
24
+ ".cursor/hooks.json",
25
+ "scripts/sync-agent-rules.ts",
26
+ "scripts/check-agent-gates.ts",
27
+ ".husky/**",
28
+ ".commitlintrc.json",
29
+ ".prettierrc.json",
30
+ "eslint.config.ts",
31
+ ".lintstagedrc.json",
32
+ ".gitleaks.toml"
33
+ ]
16
34
  },
17
35
  "current-state-authority": {
18
36
  "description": "Current state: implement from user requirements and the working tree"
@@ -32,28 +50,24 @@
32
50
  "globs": ["**/*.test.ts", "**/*.test.tsx"]
33
51
  },
34
52
  "diagnostics-and-error-handling": {
35
- "description": "Diagnostics: fix runtime failures at the source and keep the root cause"
53
+ "description": "Diagnostics: fix runtime failures at the source and keep the root cause",
54
+ "globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
36
55
  },
37
56
  "evidence-before-claims": {
38
57
  "description": "Evidence: verify and cite a claim before stating or writing it"
39
58
  },
40
- "git-workflow": {
41
- "description": "Git workflow: trunk-based branches, commits, and pull requests"
42
- },
43
59
  "no-suppression": {
44
60
  "description": "Findings: fix scanner and linter reports without inline suppressions"
45
61
  },
46
62
  "platform-and-library-first": {
47
63
  "description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
48
64
  },
49
- "script-driven-changes": {
50
- "description": "Scripts: apply a repeated edit across many files with a script"
51
- },
52
65
  "single-author-style": {
53
66
  "description": "Sibling style: match layout, naming, and composition in the same project"
54
67
  },
55
68
  "structured-logging": {
56
- "description": "Logging: log through a logging library in structured, durable records"
69
+ "description": "Logging: log through a logging library in structured, durable records",
70
+ "globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
57
71
  },
58
72
  "typescript-first": {
59
73
  "description": "TypeScript-first: write source, tests, and scripts as .ts or .tsx",
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: verifier
3
+ description: Runs the app and checks the change works before the session reports done
4
+ tools: Bash, Read
5
+ ---
6
+
7
+ Start the app with `pnpm dev`. Exercise the changed behavior and the two nearest neighboring flows. Report what you ran, what you saw, and any behavior that does not match plan.md. Do not fix anything; report only.
@@ -0,0 +1,25 @@
1
+ ---
2
+ paths:
3
+ - ".agents/rules/**"
4
+ - ".agents/rules.json"
5
+ - ".agents/hooks/**"
6
+ - ".claude/settings.json"
7
+ - ".claude/rules/**"
8
+ - ".cursor/rules/**"
9
+ - ".cursor/hooks/**"
10
+ - ".cursor/hooks.json"
11
+ - "scripts/sync-agent-rules.ts"
12
+ - "scripts/check-agent-gates.ts"
13
+ - ".husky/**"
14
+ - ".commitlintrc.json"
15
+ - ".prettierrc.json"
16
+ - "eslint.config.ts"
17
+ - ".lintstagedrc.json"
18
+ - ".gitleaks.toml"
19
+ ---
20
+
21
+ # Constitution Changes
22
+
23
+ The constitution is the set of files that agent settings deny to agents: rules, hooks, lint, format, and commit configuration, and the agent settings themselves. It is company policy.
24
+
25
+ A developer changes the constitution through a dedicated issue, never inside a feature pull request. When a task needs a constitution change, propose it to the user, reference that issue, and wait for it to merge before the task depends on it.
@@ -0,0 +1,15 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ts"
4
+ - "**/*.tsx"
5
+ - "**/*.js"
6
+ - "**/*.jsx"
7
+ ---
8
+
9
+ # Diagnostics
10
+
11
+ Resolve runtime failures at the source with the language's standard narrowing, validation, and error types. For missing third-party types, take upstream definitions or a narrow adapter in the established location.
12
+
13
+ Surface errors at the caller or process boundary with diagnostic context. Handle an error to add context, recover, or translate it at an application boundary. Retain the root cause through the language's exception mechanism.
14
+
15
+ Report unresolved type, declaration, or rule conflicts to the user. Findings follow `no-suppression.md`.
@@ -0,0 +1,11 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ts"
4
+ - "**/*.tsx"
5
+ - "**/*.js"
6
+ - "**/*.jsx"
7
+ ---
8
+
9
+ # Logging
10
+
11
+ Application code logs through the stack's logging library or the framework's logger, never `console.*`. Write structured records, and send them to a store that keeps them longer than the host does.
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: verifier
3
+ description: Runs the app and checks the change works before the session reports done
4
+ readonly: true
5
+ ---
6
+
7
+ Start the app with `pnpm dev`. Exercise the changed behavior and the two nearest neighboring flows. Report what you ran, what you saw, and any behavior that does not match plan.md. Do not fix anything; report only.
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "playwright": {
4
+ "command": "npx",
5
+ "args": ["@playwright/mcp@0.0.83"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
3
+ globs: ".agents/rules/**,.agents/rules.json,.agents/hooks/**,.claude/settings.json,.claude/rules/**,.cursor/rules/**,.cursor/hooks/**,.cursor/hooks.json,scripts/sync-agent-rules.ts,scripts/check-agent-gates.ts,.husky/**,.commitlintrc.json,.prettierrc.json,eslint.config.ts,.lintstagedrc.json,.gitleaks.toml"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Constitution Changes
8
+
9
+ The constitution is the set of files that agent settings deny to agents: rules, hooks, lint, format, and commit configuration, and the agent settings themselves. It is company policy.
10
+
11
+ A developer changes the constitution through a dedicated issue, never inside a feature pull request. When a task needs a constitution change, propose it to the user, reference that issue, and wait for it to merge before the task depends on it.
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: "Diagnostics: fix runtime failures at the source and keep the root cause"
3
+ globs: "**/*.ts,**/*.tsx,**/*.js,**/*.jsx"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Diagnostics
8
+
9
+ Resolve runtime failures at the source with the language's standard narrowing, validation, and error types. For missing third-party types, take upstream definitions or a narrow adapter in the established location.
10
+
11
+ Surface errors at the caller or process boundary with diagnostic context. Handle an error to add context, recover, or translate it at an application boundary. Retain the root cause through the language's exception mechanism.
12
+
13
+ Report unresolved type, declaration, or rule conflicts to the user. Findings follow `no-suppression.md`.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: "Logging: log through a logging library in structured, durable records"
3
+ globs: "**/*.ts,**/*.tsx,**/*.js,**/*.jsx"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Logging
8
+
9
+ Application code logs through the stack's logging library or the framework's logger, never `console.*`. Write structured records, and send them to a store that keeps them longer than the host does.
@@ -189,6 +189,50 @@ jobs:
189
189
  environment: dev
190
190
  commit_sha: ${{ github.sha }}
191
191
 
192
+ triage:
193
+ name: Triage failed build
194
+ needs:
195
+ - checks
196
+ - image
197
+ if: failure() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
198
+ runs-on: ubuntu-latest
199
+ timeout-minutes: 15
200
+ permissions:
201
+ actions: read # Needed to read the logs of the failed jobs.
202
+ id-token: write # Needed to authenticate to Anthropic with the workflow's OIDC token.
203
+ pull-requests: write # Needed to post the summary on the pull request.
204
+ steps:
205
+ - name: Collect the build log
206
+ env:
207
+ GH_TOKEN: ${{ github.token }}
208
+ REPOSITORY: ${{ github.repository }}
209
+ RUN_ID: ${{ github.run_id }}
210
+ run: |
211
+ mkdir -p out
212
+ for job in $(gh api "repos/$REPOSITORY/actions/runs/$RUN_ID/jobs" --paginate --jq '.jobs[] | select(.conclusion == "failure") | .id'); do
213
+ gh api "repos/$REPOSITORY/actions/jobs/$job/logs" >> out/build.log
214
+ done
215
+ - name: Triage failed build
216
+ id: triage
217
+ uses: anthropics/claude-code-action@61a9c274fa7110a66dfafc1bbbced03833eb25fe # v1.0.269
218
+ with:
219
+ anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
220
+ anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
221
+ prompt: >
222
+ Read the build log at out/build.log. Identify the most
223
+ likely cause, say whether the failure looks flaky or real, and write a
224
+ three-line summary for the PR thread.
225
+ claude_args: >-
226
+ --allowedTools "Read"
227
+ --json-schema '{"type":"object","properties":{"summary":{"type":"string"}},"required":["summary"]}'
228
+ - name: Post the summary
229
+ env:
230
+ GH_TOKEN: ${{ github.token }}
231
+ PR_NUMBER: ${{ github.event.pull_request.number }}
232
+ REPOSITORY: ${{ github.repository }}
233
+ SUMMARY: ${{ fromJSON(steps.triage.outputs.structured_output).summary }}
234
+ run: gh pr comment "$PR_NUMBER" --repo "$REPOSITORY" --body "$SUMMARY"
235
+
192
236
  ci:
193
237
  name: All Checks
194
238
  if: always()
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "playwright": {
4
+ "command": "npx",
5
+ "args": ["@playwright/mcp@0.0.83"]
6
+ }
7
+ }
8
+ }
@@ -16,20 +16,33 @@ Payload CMS on Next.js App Router and PostgreSQL, in TypeScript on pnpm and Node
16
16
  | Every check | `pnpm verify` |
17
17
  | Render rules after a change | `pnpm rules:sync` |
18
18
 
19
- ## How it fits together
19
+ ## Verifying your work
20
+
21
+ - Build: `pnpm build` (prints the `Route (app)` table)
22
+ - Test: `pnpm test:coverage` (all green, then the coverage summary; never skip or delete a failing test)
23
+ - Lint: `pnpm verify:static` (ESLint allows zero warnings; prints `✔ no dependency violations found`)
24
+
25
+ Run all three before reporting any task complete, and paste the output. `pnpm verify` runs all three.
26
+ If a test fails, fix the code, not the test.
27
+
28
+ ## Architecture
20
29
 
21
30
  - `src/payload.config.ts` wires the collections in `src/collections/` to PostgreSQL. The site lives in `src/app/(frontend)/`, and `src/app/health/route.ts` serves `/health`.
22
31
  - In development, Payload applies collection changes to the database directly. In production, the server applies the migrations in `src/migrations/` when it starts.
23
32
 
24
- ## Mandatory rules
33
+ ## Conventions
25
34
 
26
- 1. **Follow `.agents/rules/`.** `.agents/rules.json` gives each rule's scope; Claude Code and Cursor load them. After changing either, run `pnpm rules:sync`; `pnpm check` fails on stale copies.
35
+ 1. **Follow `.agents/rules/`.** `.agents/rules.json` gives each rule's scope; Claude Code and Cursor load them. After changing either, or a skill or subagent in `.agents/skills/` or `.agents/agents/`, run `pnpm rules:sync`; `pnpm check` fails on stale copies.
27
36
  2. **Change the schema only through collections, then regenerate and commit.** Payload generates `src/app/(payload)/`, `src/payload-types.ts`, and `src/migrations/`; run `pnpm generate:types`, `pnpm generate:importmap`, and `pnpm migrate:create <name>`. Do not edit those files by hand.
28
37
  3. **Put unit tests next to the code as `src/**/*.test.{ts,tsx}` and Playwright end-to-end tests in `test/` as `*.e2e.test.ts`.** Vitest collects only the first pattern.
29
38
  4. **Ask the user before adding component tests.** They need a DOM test environment, and Vitest runs in Node.js.
30
39
  5. **Read configuration through `requireEnvironment` in `src/environment.ts`.** Document each variable in `.env.example`.
40
+ 6. **Start from the accepted spec, in plan mode.** Claude Code starts every session in plan mode (`.claude/settings.json`); in Cursor, switch to Plan Mode before the first edit. Give the plan the change's `intent/<change>/intent.md` and `spec.md`, and have it name the files that change, the order of the work, and the tests that prove it. Commit the approved plan as `intent/<change>/plan.md`. When implementation departs from the plan, update `plan.md` in the same commit.
41
+ 7. **Start a bug fix with a failing test.** Reproduce the bug as a test, run it, and confirm it fails for the reason you expect. Commit that test. Then create `.git/bug-fix-in-progress`, so `.agents/hooks/agent-test-edit-gate.sh` blocks test edits, and make the test pass without editing it. Delete `.git/bug-fix-in-progress` when the fix is done.
42
+
43
+ ## Things Claude gets wrong
31
44
 
32
- ## Known pitfalls
45
+ When Claude makes a mistake twice, add the correction here.
33
46
 
34
47
  - **Database for `pnpm dev` and end-to-end tests**: both need a PostgreSQL database in `DATABASE_URL` and `PAYLOAD_SECRET` in `.env`; the README lists every variable. Run `pnpm exec playwright install chromium` once before the first `pnpm test:e2e`.
35
48
  - **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that writes to a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`. It is a convenience, not a security boundary: CI and code-owner review are the boundary.
@@ -24,22 +24,7 @@ In development, Payload applies collection changes to the database directly. In
24
24
 
25
25
  ## After creating a project from this template
26
26
 
27
- 1. Install gitleaks and jq (see [CONTRIBUTING.md](CONTRIBUTING.md)). Make the first commit on `main` and push it. The Git hooks allow only this first commit and push on `main`; work on branches after that.
28
-
29
- ```sh
30
- git add --all
31
- git commit -m "chore(repo): start from template"
32
- git push --set-upstream origin main
33
- ```
34
-
35
- 2. Add your team as the owner of every file in `.github/CODEOWNERS`, and replace the owner placeholder in `.github/zizmor.yml`.
36
- 3. Replace the template's description and owner: `package.json#description`, `repository.url`, and `author`, and the `Next Friday Payload template` text in `src/app/(frontend)/layout.tsx`, `src/app/(frontend)/page.tsx`, and their tests. Change `license` from `UNLICENSED` if the project is open source.
37
- 4. In the repository settings:
38
- - **Actions → General → Workflow permissions:** select **Read repository contents and packages permissions**. Every workflow requests the extra permissions it needs.
39
- - **Advanced Security:** enable private vulnerability reporting, Dependabot alerts, Dependabot security updates, secret scanning, and push protection. `SECURITY.md` sends reporters to private vulnerability reporting.
40
- - **Cursor Bugbot:** enable the repository at [Bugbot](https://cursor.com/automations/from-cursor/bugbot). Bugbot reviews pull requests against the rules linked from `.cursor/BUGBOT.md`.
41
- - **Rules → Rulesets:** protect `main` with squash merges only, a linear history, no force pushes or deletion, and the required checks `All Checks` and `Validate pull request title`. Rulesets in a private repository need GitHub Pro, Team, or Enterprise; on GitHub Free, make the repository public or upgrade.
42
- - Create the `needs triage` label, which the issue forms apply: `gh label create "needs triage"`.
27
+ Follow [SETUP.md](SETUP.md) in order. It sets up the repository, the reviews, and the AI-native SDLC. In step 1, also replace the `Next Friday Payload template` text in `src/app/(frontend)/layout.tsx`, `src/app/(frontend)/page.tsx`, and their tests.
43
28
 
44
29
  ## Scripts
45
30
 
@@ -0,0 +1 @@
1
+ Start the app with `pnpm dev`. Exercise the changed behavior and the two nearest neighboring flows. Report what you ran, what you saw, and any behavior that does not match plan.md. Do not fix anything; report only.
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "playwright": {
4
+ "command": "npx",
5
+ "args": ["@playwright/mcp@0.0.83"]
6
+ }
7
+ }
8
+ }
@@ -12,7 +12,25 @@
12
12
  "description": "Codebase hygiene: modify existing code instead of accumulating new code"
13
13
  },
14
14
  "constitution-changes": {
15
- "description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
15
+ "description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue",
16
+ "globs": [
17
+ ".agents/rules/**",
18
+ ".agents/rules.json",
19
+ ".agents/hooks/**",
20
+ ".claude/settings.json",
21
+ ".claude/rules/**",
22
+ ".cursor/rules/**",
23
+ ".cursor/hooks/**",
24
+ ".cursor/hooks.json",
25
+ "scripts/sync-agent-rules.ts",
26
+ "scripts/check-agent-gates.ts",
27
+ ".husky/**",
28
+ ".commitlintrc.json",
29
+ "prettier.config.ts",
30
+ "eslint.config.ts",
31
+ ".lintstagedrc.json",
32
+ ".gitleaks.toml"
33
+ ]
16
34
  },
17
35
  "current-state-authority": {
18
36
  "description": "Current state: implement from user requirements and the working tree"
@@ -32,28 +50,24 @@
32
50
  "globs": ["**/*.test.ts", "**/*.test.tsx"]
33
51
  },
34
52
  "diagnostics-and-error-handling": {
35
- "description": "Diagnostics: fix runtime failures at the source and keep the root cause"
53
+ "description": "Diagnostics: fix runtime failures at the source and keep the root cause",
54
+ "globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
36
55
  },
37
56
  "evidence-before-claims": {
38
57
  "description": "Evidence: verify and cite a claim before stating or writing it"
39
58
  },
40
- "git-workflow": {
41
- "description": "Git workflow: trunk-based branches, commits, and pull requests"
42
- },
43
59
  "no-suppression": {
44
60
  "description": "Findings: fix scanner and linter reports without inline suppressions"
45
61
  },
46
62
  "platform-and-library-first": {
47
63
  "description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
48
64
  },
49
- "script-driven-changes": {
50
- "description": "Scripts: apply a repeated edit across many files with a script"
51
- },
52
65
  "single-author-style": {
53
66
  "description": "Sibling style: match layout, naming, and composition in the same project"
54
67
  },
55
68
  "structured-logging": {
56
- "description": "Logging: log through a logging library in structured, durable records"
69
+ "description": "Logging: log through a logging library in structured, durable records",
70
+ "globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
57
71
  },
58
72
  "typescript-first": {
59
73
  "description": "TypeScript-first: write source, tests, and scripts as .ts or .tsx",
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: verifier
3
+ description: Runs the app and checks the change works before the session reports done
4
+ tools: Bash, Read
5
+ ---
6
+
7
+ Start the app with `pnpm dev`. Exercise the changed behavior and the two nearest neighboring flows. Report what you ran, what you saw, and any behavior that does not match plan.md. Do not fix anything; report only.
@@ -0,0 +1,25 @@
1
+ ---
2
+ paths:
3
+ - ".agents/rules/**"
4
+ - ".agents/rules.json"
5
+ - ".agents/hooks/**"
6
+ - ".claude/settings.json"
7
+ - ".claude/rules/**"
8
+ - ".cursor/rules/**"
9
+ - ".cursor/hooks/**"
10
+ - ".cursor/hooks.json"
11
+ - "scripts/sync-agent-rules.ts"
12
+ - "scripts/check-agent-gates.ts"
13
+ - ".husky/**"
14
+ - ".commitlintrc.json"
15
+ - "prettier.config.ts"
16
+ - "eslint.config.ts"
17
+ - ".lintstagedrc.json"
18
+ - ".gitleaks.toml"
19
+ ---
20
+
21
+ # Constitution Changes
22
+
23
+ The constitution is the set of files that agent settings deny to agents: rules, hooks, lint, format, and commit configuration, and the agent settings themselves. It is company policy.
24
+
25
+ A developer changes the constitution through a dedicated issue, never inside a feature pull request. When a task needs a constitution change, propose it to the user, reference that issue, and wait for it to merge before the task depends on it.
@@ -0,0 +1,15 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ts"
4
+ - "**/*.tsx"
5
+ - "**/*.js"
6
+ - "**/*.jsx"
7
+ ---
8
+
9
+ # Diagnostics
10
+
11
+ Resolve runtime failures at the source with the language's standard narrowing, validation, and error types. For missing third-party types, take upstream definitions or a narrow adapter in the established location.
12
+
13
+ Surface errors at the caller or process boundary with diagnostic context. Handle an error to add context, recover, or translate it at an application boundary. Retain the root cause through the language's exception mechanism.
14
+
15
+ Report unresolved type, declaration, or rule conflicts to the user. Findings follow `no-suppression.md`.
@@ -0,0 +1,11 @@
1
+ ---
2
+ paths:
3
+ - "**/*.ts"
4
+ - "**/*.tsx"
5
+ - "**/*.js"
6
+ - "**/*.jsx"
7
+ ---
8
+
9
+ # Logging
10
+
11
+ Application code logs through the stack's logging library or the framework's logger, never `console.*`. Write structured records, and send them to a store that keeps them longer than the host does.
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: verifier
3
+ description: Runs the app and checks the change works before the session reports done
4
+ readonly: true
5
+ ---
6
+
7
+ Start the app with `pnpm dev`. Exercise the changed behavior and the two nearest neighboring flows. Report what you ran, what you saw, and any behavior that does not match plan.md. Do not fix anything; report only.
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "playwright": {
4
+ "command": "npx",
5
+ "args": ["@playwright/mcp@0.0.83"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
3
+ globs: ".agents/rules/**,.agents/rules.json,.agents/hooks/**,.claude/settings.json,.claude/rules/**,.cursor/rules/**,.cursor/hooks/**,.cursor/hooks.json,scripts/sync-agent-rules.ts,scripts/check-agent-gates.ts,.husky/**,.commitlintrc.json,prettier.config.ts,eslint.config.ts,.lintstagedrc.json,.gitleaks.toml"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Constitution Changes
8
+
9
+ The constitution is the set of files that agent settings deny to agents: rules, hooks, lint, format, and commit configuration, and the agent settings themselves. It is company policy.
10
+
11
+ A developer changes the constitution through a dedicated issue, never inside a feature pull request. When a task needs a constitution change, propose it to the user, reference that issue, and wait for it to merge before the task depends on it.
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: "Diagnostics: fix runtime failures at the source and keep the root cause"
3
+ globs: "**/*.ts,**/*.tsx,**/*.js,**/*.jsx"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Diagnostics
8
+
9
+ Resolve runtime failures at the source with the language's standard narrowing, validation, and error types. For missing third-party types, take upstream definitions or a narrow adapter in the established location.
10
+
11
+ Surface errors at the caller or process boundary with diagnostic context. Handle an error to add context, recover, or translate it at an application boundary. Retain the root cause through the language's exception mechanism.
12
+
13
+ Report unresolved type, declaration, or rule conflicts to the user. Findings follow `no-suppression.md`.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: "Logging: log through a logging library in structured, durable records"
3
+ globs: "**/*.ts,**/*.tsx,**/*.js,**/*.jsx"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Logging
8
+
9
+ Application code logs through the stack's logging library or the framework's logger, never `console.*`. Write structured records, and send them to a store that keeps them longer than the host does.