@next-friday/create-app 2.1.5 → 2.1.7
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/package.json +1 -1
- package/templates/base/.agents/rules/agent-owned-work.md +3 -0
- package/templates/base/.agents/rules/constitution-changes.md +5 -0
- package/templates/base/.agents/rules/dependency-security.md +1 -1
- package/templates/base/.agents/rules/evidence-before-claims.md +3 -0
- package/templates/base/.agents/rules/platform-and-library-first.md +9 -0
- package/templates/base/.agents/rules/structured-logging.md +3 -0
- package/templates/base/.claude/rules/agent-owned-work.md +1 -0
- package/templates/base/.claude/rules/constitution-changes.md +1 -0
- package/templates/base/.claude/rules/dependency-security.md +1 -1
- package/templates/base/.claude/rules/evidence-before-claims.md +1 -0
- package/templates/base/.claude/rules/platform-and-library-first.md +1 -0
- package/templates/base/.claude/rules/structured-logging.md +1 -0
- package/templates/base/.cursor/BUGBOT.md +5 -0
- package/templates/base/.cursor/rules/agent-owned-work.mdc +8 -0
- package/templates/base/.cursor/rules/constitution-changes.mdc +10 -0
- package/templates/base/.cursor/rules/dependency-security.mdc +1 -1
- package/templates/base/.cursor/rules/evidence-before-claims.mdc +8 -0
- package/templates/base/.cursor/rules/platform-and-library-first.mdc +14 -0
- package/templates/base/.cursor/rules/structured-logging.mdc +8 -0
- package/templates/nestjs/.agents/rules.json +15 -0
- package/templates/nestjs/AGENTS.md +33 -5
- package/templates/nextjs/.agents/rules.json +15 -0
- package/templates/nextjs/AGENTS.md +34 -5
- package/templates/nodejs/.agents/rules.json +15 -0
- package/templates/nodejs/AGENTS.md +31 -5
- package/templates/payload/.agents/rules.json +15 -0
- package/templates/payload/AGENTS.md +37 -6
- package/templates/turborepo/.agents/rules.json +15 -0
- package/templates/turborepo/AGENTS.md +35 -12
package/package.json
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Agent-Owned Work
|
|
2
|
+
|
|
3
|
+
Do the work that an agent, a script, or an API can do; do not hand it to the user. Before you ask the user, check the code, data, docs, and tools that already exist. Ask only for what no one else can provide, such as payment, legal identity, or a business fact recorded nowhere. Constitution edits follow `constitution-changes.md`.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Constitution Changes
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Dependencies
|
|
2
2
|
|
|
3
|
-
Add a dependency when active code, tests, build tooling, or a documented contract uses it, and
|
|
3
|
+
Add a dependency when active code, tests, build tooling, or a documented contract uses it, and neither the platform nor existing project code covers the need. A maintained library that replaces custom code meets this test; `platform-and-library-first.md` sets the order. Assess cadence, license, advisories, compatibility, and transitives first. Place it in the manifest of the project that imports it, in the ecosystem category that matches its role.
|
|
4
4
|
|
|
5
5
|
Resolve a vulnerability that Dependabot or OSV-Scanner reports by upgrading the dependency. For a transitive dependency, add a pnpm override in `pnpm-workspace.yaml`. When no fix exists, record the accepted risk as `no-suppression.md` describes.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Evidence
|
|
2
|
+
|
|
3
|
+
Verify a claim about files, commands, APIs, versions, or limits before you state or write it, and cite its source: `path:line`, command output, or an official documentation URL. Do not write a value without a source into code or docs; state it as unverified and give the reason.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Platform and Library First
|
|
2
|
+
|
|
3
|
+
Meet a need with the first option that covers it:
|
|
4
|
+
|
|
5
|
+
1. A built-in feature of the framework or platform.
|
|
6
|
+
2. A maintained library or an official template.
|
|
7
|
+
3. Custom code. State in the pull request why the first two fall short.
|
|
8
|
+
|
|
9
|
+
Add a library as `dependency-security.md` describes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../../.agents/rules/agent-owned-work.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../../.agents/rules/constitution-changes.md
|
|
@@ -7,6 +7,6 @@ paths:
|
|
|
7
7
|
|
|
8
8
|
# Dependencies
|
|
9
9
|
|
|
10
|
-
Add a dependency when active code, tests, build tooling, or a documented contract uses it, and
|
|
10
|
+
Add a dependency when active code, tests, build tooling, or a documented contract uses it, and neither the platform nor existing project code covers the need. A maintained library that replaces custom code meets this test; `platform-and-library-first.md` sets the order. Assess cadence, license, advisories, compatibility, and transitives first. Place it in the manifest of the project that imports it, in the ecosystem category that matches its role.
|
|
11
11
|
|
|
12
12
|
Resolve a vulnerability that Dependabot or OSV-Scanner reports by upgrading the dependency. For a transitive dependency, add a pnpm override in `pnpm-workspace.yaml`. When no fix exists, record the accepted risk as `no-suppression.md` describes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../../.agents/rules/evidence-before-claims.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../../.agents/rules/platform-and-library-first.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../../.agents/rules/structured-logging.md
|
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
Review pull requests against the project's agent guide and rules:
|
|
4
4
|
|
|
5
5
|
- [Agent guide](../AGENTS.md)
|
|
6
|
+
- [Agent-Owned Work](../.agents/rules/agent-owned-work.md)
|
|
6
7
|
- [Owned Checks](../.agents/rules/automation-owned-checks.md)
|
|
7
8
|
- [Required Comments](../.agents/rules/code-comments.md)
|
|
8
9
|
- [Codebase Hygiene](../.agents/rules/codebase-hygiene.md)
|
|
10
|
+
- [Constitution Changes](../.agents/rules/constitution-changes.md)
|
|
9
11
|
- [Current State](../.agents/rules/current-state-authority.md)
|
|
10
12
|
- [Demand-Driven Configuration](../.agents/rules/demand-driven-configuration.md)
|
|
11
13
|
- [Dependencies](../.agents/rules/dependency-security.md)
|
|
12
14
|
- [Descriptive Naming](../.agents/rules/descriptive-naming.md)
|
|
13
15
|
- [Test Admission](../.agents/rules/deterministic-testing.md)
|
|
14
16
|
- [Diagnostics](../.agents/rules/diagnostics-and-error-handling.md)
|
|
17
|
+
- [Evidence](../.agents/rules/evidence-before-claims.md)
|
|
15
18
|
- [Git Workflow](../.agents/rules/git-workflow.md)
|
|
16
19
|
- [Findings](../.agents/rules/no-suppression.md)
|
|
20
|
+
- [Platform and Library First](../.agents/rules/platform-and-library-first.md)
|
|
17
21
|
- [Scripts](../.agents/rules/script-driven-changes.md)
|
|
18
22
|
- [Sibling Style](../.agents/rules/single-author-style.md)
|
|
23
|
+
- [Logging](../.agents/rules/structured-logging.md)
|
|
19
24
|
- [TypeScript-First](../.agents/rules/typescript-first.md)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Agent-owned work: do what an agent, script, or API can do instead of asking the user"
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent-Owned Work
|
|
7
|
+
|
|
8
|
+
Do the work that an agent, a script, or an API can do; do not hand it to the user. Before you ask the user, check the code, data, docs, and tools that already exist. Ask only for what no one else can provide, such as payment, legal identity, or a business fact recorded nowhere. Constitution edits follow `constitution-changes.md`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Constitution Changes
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
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.
|
|
@@ -6,6 +6,6 @@ alwaysApply: false
|
|
|
6
6
|
|
|
7
7
|
# Dependencies
|
|
8
8
|
|
|
9
|
-
Add a dependency when active code, tests, build tooling, or a documented contract uses it, and
|
|
9
|
+
Add a dependency when active code, tests, build tooling, or a documented contract uses it, and neither the platform nor existing project code covers the need. A maintained library that replaces custom code meets this test; `platform-and-library-first.md` sets the order. Assess cadence, license, advisories, compatibility, and transitives first. Place it in the manifest of the project that imports it, in the ecosystem category that matches its role.
|
|
10
10
|
|
|
11
11
|
Resolve a vulnerability that Dependabot or OSV-Scanner reports by upgrading the dependency. For a transitive dependency, add a pnpm override in `pnpm-workspace.yaml`. When no fix exists, record the accepted risk as `no-suppression.md` describes.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Evidence: verify and cite a claim before stating or writing it"
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Evidence
|
|
7
|
+
|
|
8
|
+
Verify a claim about files, commands, APIs, versions, or limits before you state or write it, and cite its source: `path:line`, command output, or an official documentation URL. Do not write a value without a source into code or docs; state it as unverified and give the reason.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Platform and library first: use built-in features, then maintained libraries, then custom code"
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Platform and Library First
|
|
7
|
+
|
|
8
|
+
Meet a need with the first option that covers it:
|
|
9
|
+
|
|
10
|
+
1. A built-in feature of the framework or platform.
|
|
11
|
+
2. A maintained library or an official template.
|
|
12
|
+
3. Custom code. State in the pull request why the first two fall short.
|
|
13
|
+
|
|
14
|
+
Add a library as `dependency-security.md` describes.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Logging: log through a logging library in structured, durable records"
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Logging
|
|
7
|
+
|
|
8
|
+
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.
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"agent-owned-work": {
|
|
3
|
+
"description": "Agent-owned work: do what an agent, script, or API can do instead of asking the user"
|
|
4
|
+
},
|
|
2
5
|
"automation-owned-checks": {
|
|
3
6
|
"description": "Owned checks: hooks and CI define what must pass; run checks by hand to verify"
|
|
4
7
|
},
|
|
@@ -8,6 +11,9 @@
|
|
|
8
11
|
"codebase-hygiene": {
|
|
9
12
|
"description": "Codebase hygiene: modify existing code instead of accumulating new code"
|
|
10
13
|
},
|
|
14
|
+
"constitution-changes": {
|
|
15
|
+
"description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
|
|
16
|
+
},
|
|
11
17
|
"current-state-authority": {
|
|
12
18
|
"description": "Current state: implement from user requirements and the working tree"
|
|
13
19
|
},
|
|
@@ -28,18 +34,27 @@
|
|
|
28
34
|
"diagnostics-and-error-handling": {
|
|
29
35
|
"description": "Diagnostics: fix runtime failures at the source and keep the root cause"
|
|
30
36
|
},
|
|
37
|
+
"evidence-before-claims": {
|
|
38
|
+
"description": "Evidence: verify and cite a claim before stating or writing it"
|
|
39
|
+
},
|
|
31
40
|
"git-workflow": {
|
|
32
41
|
"description": "Git workflow: trunk-based branches, commits, and pull requests"
|
|
33
42
|
},
|
|
34
43
|
"no-suppression": {
|
|
35
44
|
"description": "Findings: fix scanner and linter reports without inline suppressions"
|
|
36
45
|
},
|
|
46
|
+
"platform-and-library-first": {
|
|
47
|
+
"description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
|
|
48
|
+
},
|
|
37
49
|
"script-driven-changes": {
|
|
38
50
|
"description": "Scripts: apply a repeated edit across many files with a script"
|
|
39
51
|
},
|
|
40
52
|
"single-author-style": {
|
|
41
53
|
"description": "Sibling style: match layout, naming, and composition in the same project"
|
|
42
54
|
},
|
|
55
|
+
"structured-logging": {
|
|
56
|
+
"description": "Logging: log through a logging library in structured, durable records"
|
|
57
|
+
},
|
|
43
58
|
"typescript-first": {
|
|
44
59
|
"description": "TypeScript-first: write source, tests, and scripts as .ts",
|
|
45
60
|
"globs": ["**/*.ts", "**/*.js"]
|
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
# Agent guide
|
|
2
2
|
|
|
3
|
-
NestJS
|
|
3
|
+
NestJS HTTP API in TypeScript on pnpm and Node.js `>=24.15.0 <25`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Task | Command |
|
|
8
|
+
| :-------------------------- | :-------------------------------------------------- |
|
|
9
|
+
| Start with reload | `pnpm start:dev` |
|
|
10
|
+
| One test | `pnpm vitest run src/port.test.ts -t "<test name>"` |
|
|
11
|
+
| Unit tests | `pnpm test`, or `pnpm test:coverage` |
|
|
12
|
+
| End-to-end tests | `pnpm test:e2e` |
|
|
13
|
+
| What `pre-push` runs | `pnpm check` |
|
|
14
|
+
| Every check | `pnpm verify` |
|
|
15
|
+
| Render rules after a change | `pnpm rules:sync` |
|
|
16
|
+
|
|
17
|
+
## How it fits together
|
|
18
|
+
|
|
19
|
+
- `src/main.ts` creates the app from `AppModule` on `parsePort(process.env.PORT)` with Nest's `ConsoleLogger`, which writes JSON lines when `NODE_ENV` is `production`.
|
|
20
|
+
- `AppModule` imports `HealthModule`, whose Terminus controller serves `/health`. Add a feature as its own module and import it in `AppModule`.
|
|
21
|
+
|
|
22
|
+
## Mandatory rules
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
2. **Put unit tests next to the code as `src/**/*.test.ts` and end-to-end tests in `test/` as `*.e2e.test.ts`.** `vitest.config.ts` and `vitest.e2e.config.ts` collect only those patterns.
|
|
26
|
+
3. **Read configuration from environment variables and fail when one is missing**, as `parsePort` does. Document each variable in `.env.example`.
|
|
27
|
+
4. **Log through Nest's `Logger`.** It goes to the `ConsoleLogger` set in `src/main.ts`.
|
|
28
|
+
|
|
29
|
+
## Known pitfalls
|
|
30
|
+
|
|
31
|
+
- **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that names a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`, even when it only reads.
|
|
32
|
+
|
|
33
|
+
## Related documentation
|
|
34
|
+
|
|
35
|
+
- [README.md](README.md): scripts, container, deploy
|
|
36
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): prerequisites, Git hooks, pull requests
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"agent-owned-work": {
|
|
3
|
+
"description": "Agent-owned work: do what an agent, script, or API can do instead of asking the user"
|
|
4
|
+
},
|
|
2
5
|
"automation-owned-checks": {
|
|
3
6
|
"description": "Owned checks: hooks and CI define what must pass; run checks by hand to verify"
|
|
4
7
|
},
|
|
@@ -8,6 +11,9 @@
|
|
|
8
11
|
"codebase-hygiene": {
|
|
9
12
|
"description": "Codebase hygiene: modify existing code instead of accumulating new code"
|
|
10
13
|
},
|
|
14
|
+
"constitution-changes": {
|
|
15
|
+
"description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
|
|
16
|
+
},
|
|
11
17
|
"current-state-authority": {
|
|
12
18
|
"description": "Current state: implement from user requirements and the working tree"
|
|
13
19
|
},
|
|
@@ -28,18 +34,27 @@
|
|
|
28
34
|
"diagnostics-and-error-handling": {
|
|
29
35
|
"description": "Diagnostics: fix runtime failures at the source and keep the root cause"
|
|
30
36
|
},
|
|
37
|
+
"evidence-before-claims": {
|
|
38
|
+
"description": "Evidence: verify and cite a claim before stating or writing it"
|
|
39
|
+
},
|
|
31
40
|
"git-workflow": {
|
|
32
41
|
"description": "Git workflow: trunk-based branches, commits, and pull requests"
|
|
33
42
|
},
|
|
34
43
|
"no-suppression": {
|
|
35
44
|
"description": "Findings: fix scanner and linter reports without inline suppressions"
|
|
36
45
|
},
|
|
46
|
+
"platform-and-library-first": {
|
|
47
|
+
"description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
|
|
48
|
+
},
|
|
37
49
|
"script-driven-changes": {
|
|
38
50
|
"description": "Scripts: apply a repeated edit across many files with a script"
|
|
39
51
|
},
|
|
40
52
|
"single-author-style": {
|
|
41
53
|
"description": "Sibling style: match layout, naming, and composition in the same project"
|
|
42
54
|
},
|
|
55
|
+
"structured-logging": {
|
|
56
|
+
"description": "Logging: log through a logging library in structured, durable records"
|
|
57
|
+
},
|
|
43
58
|
"typescript-first": {
|
|
44
59
|
"description": "TypeScript-first: write source, tests, and scripts as .ts or .tsx",
|
|
45
60
|
"globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
# Agent guide
|
|
2
2
|
|
|
3
|
-
Next.js App Router
|
|
3
|
+
Next.js App Router web app with React and Tailwind CSS, in TypeScript on pnpm and Node.js `>=24.15.0 <25`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Task | Command |
|
|
8
|
+
| :-------------------------- | :---------------------------------------------------------- |
|
|
9
|
+
| Start with reload | `pnpm dev` |
|
|
10
|
+
| One test | `pnpm vitest run app/health/route.test.ts -t "<test name>"` |
|
|
11
|
+
| Unit tests | `pnpm test`, or `pnpm test:coverage` |
|
|
12
|
+
| End-to-end tests | `pnpm test:e2e` |
|
|
13
|
+
| What `pre-push` runs | `pnpm check` |
|
|
14
|
+
| Every check | `pnpm verify` |
|
|
15
|
+
| Render rules after a change | `pnpm rules:sync` |
|
|
16
|
+
|
|
17
|
+
## How it fits together
|
|
18
|
+
|
|
19
|
+
- Routes live in `app/`. `app/health/route.ts` serves `/health`.
|
|
20
|
+
- `next.config.ts` builds `output: "standalone"`, enables Cache Components, and sets the security headers. `pnpm start` copies the static assets into `.next/standalone` and serves it.
|
|
21
|
+
|
|
22
|
+
## Mandatory rules
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
2. **Put unit tests next to the code as `app/**/*.test.{ts,tsx}` and Playwright end-to-end tests in `test/` as `*.e2e.test.ts`.** Vitest collects only the first pattern.
|
|
26
|
+
3. **Ask the user before adding component tests.** They need a DOM test environment, and Vitest runs in Node.js.
|
|
27
|
+
4. **Read configuration from environment variables and fail when one is missing.** Document each variable in `.env.example`.
|
|
28
|
+
|
|
29
|
+
## Known pitfalls
|
|
30
|
+
|
|
31
|
+
- **First end-to-end run**: run `pnpm exec playwright install chromium` once. `pnpm test:e2e` starts the development server unless one is already running.
|
|
32
|
+
- **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that names a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`, even when it only reads.
|
|
33
|
+
|
|
34
|
+
## Related documentation
|
|
35
|
+
|
|
36
|
+
- [README.md](README.md): scripts, container, deploy
|
|
37
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): prerequisites, Git hooks, pull requests
|
|
9
38
|
|
|
10
39
|
<!-- BEGIN:nextjs-agent-rules -->
|
|
11
40
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"agent-owned-work": {
|
|
3
|
+
"description": "Agent-owned work: do what an agent, script, or API can do instead of asking the user"
|
|
4
|
+
},
|
|
2
5
|
"automation-owned-checks": {
|
|
3
6
|
"description": "Owned checks: hooks and CI define what must pass; run checks by hand to verify"
|
|
4
7
|
},
|
|
@@ -8,6 +11,9 @@
|
|
|
8
11
|
"codebase-hygiene": {
|
|
9
12
|
"description": "Codebase hygiene: modify existing code instead of accumulating new code"
|
|
10
13
|
},
|
|
14
|
+
"constitution-changes": {
|
|
15
|
+
"description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
|
|
16
|
+
},
|
|
11
17
|
"current-state-authority": {
|
|
12
18
|
"description": "Current state: implement from user requirements and the working tree"
|
|
13
19
|
},
|
|
@@ -28,18 +34,27 @@
|
|
|
28
34
|
"diagnostics-and-error-handling": {
|
|
29
35
|
"description": "Diagnostics: fix runtime failures at the source and keep the root cause"
|
|
30
36
|
},
|
|
37
|
+
"evidence-before-claims": {
|
|
38
|
+
"description": "Evidence: verify and cite a claim before stating or writing it"
|
|
39
|
+
},
|
|
31
40
|
"git-workflow": {
|
|
32
41
|
"description": "Git workflow: trunk-based branches, commits, and pull requests"
|
|
33
42
|
},
|
|
34
43
|
"no-suppression": {
|
|
35
44
|
"description": "Findings: fix scanner and linter reports without inline suppressions"
|
|
36
45
|
},
|
|
46
|
+
"platform-and-library-first": {
|
|
47
|
+
"description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
|
|
48
|
+
},
|
|
37
49
|
"script-driven-changes": {
|
|
38
50
|
"description": "Scripts: apply a repeated edit across many files with a script"
|
|
39
51
|
},
|
|
40
52
|
"single-author-style": {
|
|
41
53
|
"description": "Sibling style: match layout, naming, and composition in the same project"
|
|
42
54
|
},
|
|
55
|
+
"structured-logging": {
|
|
56
|
+
"description": "Logging: log through a logging library in structured, durable records"
|
|
57
|
+
},
|
|
43
58
|
"typescript-first": {
|
|
44
59
|
"description": "TypeScript-first: write source, tests, and scripts as .ts",
|
|
45
60
|
"globs": ["**/*.ts", "**/*.js"]
|
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
# Agent guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript HTTP service on `node:http`, without a framework, on pnpm and Node.js `>=24.15.0 <25`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Task | Command |
|
|
8
|
+
| :-------------------------- | :-------------------------------------------------- |
|
|
9
|
+
| Start with reload | `pnpm start:dev` |
|
|
10
|
+
| One test | `pnpm vitest run src/port.test.ts -t "<test name>"` |
|
|
11
|
+
| Unit tests | `pnpm test`, or `pnpm test:coverage` |
|
|
12
|
+
| What `pre-push` runs | `pnpm check` |
|
|
13
|
+
| Every check | `pnpm verify` |
|
|
14
|
+
| Render rules after a change | `pnpm rules:sync` |
|
|
15
|
+
|
|
16
|
+
## How it fits together
|
|
17
|
+
|
|
18
|
+
- `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
|
+
- `src/server.ts` answers `GET` and `HEAD` `/health` and returns 404 for every other request. Routes go there.
|
|
20
|
+
|
|
21
|
+
## Mandatory rules
|
|
22
|
+
|
|
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.
|
|
24
|
+
2. **Put tests next to the code as `src/**/*.test.ts`.** Vitest collects only that pattern.
|
|
25
|
+
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`.
|
|
26
|
+
|
|
27
|
+
## Known pitfalls
|
|
28
|
+
|
|
29
|
+
- **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that names a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`, even when it only reads.
|
|
30
|
+
|
|
31
|
+
## Related documentation
|
|
32
|
+
|
|
33
|
+
- [README.md](README.md): scripts, container, deploy
|
|
34
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): prerequisites, Git hooks, pull requests
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"agent-owned-work": {
|
|
3
|
+
"description": "Agent-owned work: do what an agent, script, or API can do instead of asking the user"
|
|
4
|
+
},
|
|
2
5
|
"automation-owned-checks": {
|
|
3
6
|
"description": "Owned checks: hooks and CI define what must pass; run checks by hand to verify"
|
|
4
7
|
},
|
|
@@ -8,6 +11,9 @@
|
|
|
8
11
|
"codebase-hygiene": {
|
|
9
12
|
"description": "Codebase hygiene: modify existing code instead of accumulating new code"
|
|
10
13
|
},
|
|
14
|
+
"constitution-changes": {
|
|
15
|
+
"description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
|
|
16
|
+
},
|
|
11
17
|
"current-state-authority": {
|
|
12
18
|
"description": "Current state: implement from user requirements and the working tree"
|
|
13
19
|
},
|
|
@@ -28,18 +34,27 @@
|
|
|
28
34
|
"diagnostics-and-error-handling": {
|
|
29
35
|
"description": "Diagnostics: fix runtime failures at the source and keep the root cause"
|
|
30
36
|
},
|
|
37
|
+
"evidence-before-claims": {
|
|
38
|
+
"description": "Evidence: verify and cite a claim before stating or writing it"
|
|
39
|
+
},
|
|
31
40
|
"git-workflow": {
|
|
32
41
|
"description": "Git workflow: trunk-based branches, commits, and pull requests"
|
|
33
42
|
},
|
|
34
43
|
"no-suppression": {
|
|
35
44
|
"description": "Findings: fix scanner and linter reports without inline suppressions"
|
|
36
45
|
},
|
|
46
|
+
"platform-and-library-first": {
|
|
47
|
+
"description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
|
|
48
|
+
},
|
|
37
49
|
"script-driven-changes": {
|
|
38
50
|
"description": "Scripts: apply a repeated edit across many files with a script"
|
|
39
51
|
},
|
|
40
52
|
"single-author-style": {
|
|
41
53
|
"description": "Sibling style: match layout, naming, and composition in the same project"
|
|
42
54
|
},
|
|
55
|
+
"structured-logging": {
|
|
56
|
+
"description": "Logging: log through a logging library in structured, durable records"
|
|
57
|
+
},
|
|
43
58
|
"typescript-first": {
|
|
44
59
|
"description": "TypeScript-first: write source, tests, and scripts as .ts or .tsx",
|
|
45
60
|
"globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
# Agent guide
|
|
2
2
|
|
|
3
|
-
Payload CMS on Next.js App Router and PostgreSQL,
|
|
3
|
+
Payload CMS on Next.js App Router and PostgreSQL, in TypeScript on pnpm and Node.js `>=24.22.1 <25`. The API is REST at `/api`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Task | Command |
|
|
8
|
+
| :---------------------------- | :--------------------------------------------------------- |
|
|
9
|
+
| Start with reload | `pnpm dev` |
|
|
10
|
+
| One test | `pnpm vitest run src/environment.test.ts -t "<test name>"` |
|
|
11
|
+
| Unit tests | `pnpm test`, or `pnpm test:coverage` |
|
|
12
|
+
| End-to-end tests | `pnpm test:e2e` |
|
|
13
|
+
| Regenerate after a collection | `pnpm generate:types`, `pnpm generate:importmap` |
|
|
14
|
+
| Create a migration | `pnpm migrate:create <name>` |
|
|
15
|
+
| What `pre-push` runs | `pnpm check` |
|
|
16
|
+
| Every check | `pnpm verify` |
|
|
17
|
+
| Render rules after a change | `pnpm rules:sync` |
|
|
18
|
+
|
|
19
|
+
## How it fits together
|
|
20
|
+
|
|
21
|
+
- `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
|
+
- In development, Payload applies collection changes to the database directly. In production, the server applies the migrations in `src/migrations/` when it starts.
|
|
23
|
+
|
|
24
|
+
## Mandatory rules
|
|
25
|
+
|
|
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.
|
|
27
|
+
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
|
+
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
|
+
4. **Ask the user before adding component tests.** They need a DOM test environment, and Vitest runs in Node.js.
|
|
30
|
+
5. **Read configuration through `requireEnvironment` in `src/environment.ts`.** Document each variable in `.env.example`.
|
|
31
|
+
|
|
32
|
+
## Known pitfalls
|
|
33
|
+
|
|
34
|
+
- **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
|
+
- **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that names a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`, even when it only reads.
|
|
36
|
+
|
|
37
|
+
## Related documentation
|
|
38
|
+
|
|
39
|
+
- [README.md](README.md): environment variables, scripts, container, deploy
|
|
40
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): prerequisites, Git hooks, pull requests
|
|
10
41
|
|
|
11
42
|
<!-- BEGIN:nextjs-agent-rules -->
|
|
12
43
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"agent-owned-work": {
|
|
3
|
+
"description": "Agent-owned work: do what an agent, script, or API can do instead of asking the user"
|
|
4
|
+
},
|
|
2
5
|
"automation-owned-checks": {
|
|
3
6
|
"description": "Owned checks: hooks and CI define what must pass; run checks by hand to verify"
|
|
4
7
|
},
|
|
@@ -8,6 +11,9 @@
|
|
|
8
11
|
"codebase-hygiene": {
|
|
9
12
|
"description": "Codebase hygiene: modify existing code instead of accumulating new code"
|
|
10
13
|
},
|
|
14
|
+
"constitution-changes": {
|
|
15
|
+
"description": "Constitution changes: change rules, hooks, and agent settings only through a dedicated issue"
|
|
16
|
+
},
|
|
11
17
|
"current-state-authority": {
|
|
12
18
|
"description": "Current state: implement from user requirements and the working tree"
|
|
13
19
|
},
|
|
@@ -28,18 +34,27 @@
|
|
|
28
34
|
"diagnostics-and-error-handling": {
|
|
29
35
|
"description": "Diagnostics: fix runtime failures at the source and keep the root cause"
|
|
30
36
|
},
|
|
37
|
+
"evidence-before-claims": {
|
|
38
|
+
"description": "Evidence: verify and cite a claim before stating or writing it"
|
|
39
|
+
},
|
|
31
40
|
"git-workflow": {
|
|
32
41
|
"description": "Git workflow: trunk-based branches, commits, and pull requests"
|
|
33
42
|
},
|
|
34
43
|
"no-suppression": {
|
|
35
44
|
"description": "Findings: fix scanner and linter reports without inline suppressions"
|
|
36
45
|
},
|
|
46
|
+
"platform-and-library-first": {
|
|
47
|
+
"description": "Platform and library first: use built-in features, then maintained libraries, then custom code"
|
|
48
|
+
},
|
|
37
49
|
"script-driven-changes": {
|
|
38
50
|
"description": "Scripts: apply a repeated edit across many files with a script"
|
|
39
51
|
},
|
|
40
52
|
"single-author-style": {
|
|
41
53
|
"description": "Sibling style: match layout, naming, and composition in the same project"
|
|
42
54
|
},
|
|
55
|
+
"structured-logging": {
|
|
56
|
+
"description": "Logging: log through a logging library in structured, durable records"
|
|
57
|
+
},
|
|
43
58
|
"typescript-first": {
|
|
44
59
|
"description": "TypeScript-first: write source, tests, and scripts as .ts or .tsx",
|
|
45
60
|
"globs": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
# Agent guide
|
|
2
2
|
|
|
3
|
-
Turborepo workspace on pnpm. `apps/app` is
|
|
3
|
+
Turborepo workspace in TypeScript on pnpm and Node.js `>=24.22.1 <25`. `apps/app` is a Next.js site on port 3000. `apps/backoffice` is a Payload CMS on PostgreSQL on port 3001, with a REST API at `/api`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Rule files, agent hooks, and agent settings are company policy: propose a change to the user, who edits them.
|
|
7
|
-
- Put unit tests next to the code as `*.test.ts`. Put Playwright end-to-end tests in `apps/app/test/` and `apps/backoffice/test/` as `*.e2e.test.ts`. Component tests need a DOM test environment, which is not set up yet; ask the user before adding one.
|
|
8
|
-
- The Next.js site lives in `apps/app/app/`. The backoffice site lives in `apps/backoffice/src/app/(frontend)/`, collections in `apps/backoffice/src/collections/`, and the Payload config in `apps/backoffice/src/payload.config.ts`.
|
|
9
|
-
- Payload generates `apps/backoffice/src/app/(payload)/`, `apps/backoffice/src/payload-types.ts`, and `apps/backoffice/src/migrations/`. After changing a collection, regenerate them with `pnpm generate:types`, `pnpm generate:importmap`, and `pnpm migrate:create <name>`, and commit the results.
|
|
10
|
-
- Read backoffice configuration through `requireEnvironment` in `apps/backoffice/src/environment.ts`. Document each variable in `.env.example`.
|
|
5
|
+
## Commands
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
| Task | Command |
|
|
8
|
+
| :---------------------------- | :----------------------------------------------------------------------------------------- |
|
|
9
|
+
| Start both apps with reload | `pnpm dev` |
|
|
10
|
+
| One test | `pnpm --filter ./apps/backoffice exec vitest run src/environment.test.ts -t "<test name>"` |
|
|
11
|
+
| Tests in one app | `TURBO_FILTER=--filter=./apps/app pnpm test` |
|
|
12
|
+
| Unit tests | `pnpm test`, or `pnpm test:coverage` |
|
|
13
|
+
| End-to-end tests | `pnpm test:e2e` |
|
|
14
|
+
| Regenerate after a collection | `pnpm generate:types`, `pnpm generate:importmap` |
|
|
15
|
+
| Create a migration | `pnpm migrate:create <name>` |
|
|
16
|
+
| What `pre-push` runs | `pnpm check` |
|
|
17
|
+
| Every check | `pnpm verify` |
|
|
18
|
+
| Render rules after a change | `pnpm rules:sync` |
|
|
13
19
|
|
|
14
|
-
##
|
|
20
|
+
## How it fits together
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
- Root scripts run lint, format, Knip, and the agent checks once for the workspace, and hand `build`, `test`, `typecheck`, and `depcruise` to Turborepo for each app. `TURBO_FILTER` narrows them; the default is every app.
|
|
23
|
+
- The site lives in `apps/app/app/`. The backoffice site lives in `apps/backoffice/src/app/(frontend)/`, its collections in `apps/backoffice/src/collections/`, and its config in `apps/backoffice/src/payload.config.ts`. The root `generate:*` and `migrate*` scripts run in the backoffice.
|
|
24
|
+
- In development, Payload applies collection changes to the database directly. In production, the backoffice applies the migrations in `apps/backoffice/src/migrations/` when it starts.
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
## Mandatory rules
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
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.
|
|
29
|
+
2. **Change the backoffice schema only through collections, then regenerate and commit.** Payload generates `apps/backoffice/src/app/(payload)/`, `apps/backoffice/src/payload-types.ts`, and `apps/backoffice/src/migrations/`; run `pnpm generate:types`, `pnpm generate:importmap`, and `pnpm migrate:create <name>`. Do not edit those files by hand.
|
|
30
|
+
3. **Put unit tests next to the code and Playwright end-to-end tests in `apps/app/test/` and `apps/backoffice/test/` as `*.e2e.test.ts`.** Vitest collects `apps/app/app/**/*.test.{ts,tsx}` and `apps/backoffice/src/**/*.test.{ts,tsx}`.
|
|
31
|
+
4. **Ask the user before adding component tests.** They need a DOM test environment, and Vitest runs in Node.js.
|
|
32
|
+
5. **Read backoffice configuration through `requireEnvironment` in `apps/backoffice/src/environment.ts`.** Document each variable in `.env.example`.
|
|
33
|
+
|
|
34
|
+
## Known pitfalls
|
|
35
|
+
|
|
36
|
+
- **Next.js docs live per app**: this Next.js version differs from your training data. Read the guide in `apps/app/node_modules/next/dist/docs/` or `apps/backoffice/node_modules/next/dist/docs/` before writing Next.js code; the workspace root has no `next` package.
|
|
37
|
+
- **Database for `pnpm dev` and end-to-end tests**: the backoffice needs 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`.
|
|
38
|
+
- **Agent shell gate**: `.agents/hooks/agent-shell-gate.sh` blocks a shell command that names a protected path such as `.agents`, `.cursor`, `.claude/rules`, or `.husky`, even when it only reads.
|
|
39
|
+
|
|
40
|
+
## Related documentation
|
|
41
|
+
|
|
42
|
+
- [README.md](README.md): environment variables, scripts, CI caching, container, deploy
|
|
43
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md): prerequisites, Git hooks, pull requests
|