Commit 9f9f343
authored
feat(cpa): add --agent flag for coding agent skill installation (#16278)
# Overview
Replace hard-coded `.cursor/rules` and `AGENTS.md` files in templates
with a dynamic `--agent` flag in `create-payload-app`. When a user
selects a coding agent during project creation, the Payload skill
(`SKILL.md` + `reference/` docs) is downloaded from GitHub and placed in
the correct directory for that agent. A `CLAUDE.md` or `AGENTS.md` is
written at the project root to point the agent to the skill.
Supports `claude`, `codex`, `cursor` initially.
<img width="514" height="386" alt="image"
src="https://github.com/user-attachments/assets/c5bc9e68-0c02-4881-ae6c-957e465e9f96"
/>
## Key Changes
- **New `--agent` / `-a` flag and `--no-agent` flag**
- Supports `claude`, `codex`, and `cursor` as agent values
- Interactive prompt shown when no flag is provided, with a "None"
option to skip
- `--no-agent` skips the prompt entirely, matching the `--no-deps` /
`--no-git` pattern
- **Runtime skill download via GitHub tarball**
- New `download-skill.ts` module reuses the same `codeload.github.com`
tarball + filter approach as `download-template.ts`
- Downloads `tools/claude-plugin/skills/payload/` and extracts it to the
agent's skill directory
- Claude uses `.claude/skills/payload/`, Codex and Cursor use
`.agents/skills/payload/`
- Non-fatal on failure — project creation continues with a warning
- **Agent config file at project root**
- Claude → `CLAUDE.md`, Codex/Cursor → `AGENTS.md` (never both)
- Points the agent to the installed skill location for discoverability
- Only written on successful skill download
- **Removed static agent files from templates**
- Deleted `templates/_agents/` directory (source for copied rules)
- Deleted `AGENTS.md` and `.cursor/rules/` from all 8 templates (~43k
lines removed)
- Stripped `skipAgents` / `copyAgentsFiles` logic from
`generate-template-variations.ts`
- **Added Common Gotchas and Best Practices to SKILL.md**
- Closes a content gap vs. the old `AGENTS.md` — same 10 gotchas and 5
best-practice categories now in the skill
## Design Decisions
Agent selection follows the existing `select-db.ts` pattern: check CLI
flag first, validate, fall back to interactive prompt. This keeps the
codebase consistent and the new feature immediately familiar to anyone
who has worked on CPA.
The skill is downloaded at runtime rather than bundled into the CPA
package. This means the skill content always matches the latest `main`
branch without requiring a CPA release. The `--branch` flag (already
used for template downloads) controls which branch the skill is fetched
from, keeping template and skill versions in sync.
Codex and Cursor both use `.agents/skills/` (the universal skills
directory convention), while Claude uses its own `.claude/skills/`. The
mapping is defined in a single `agentChoices` array in
`select-agent.ts`.
The old `AGENTS.md` was a single 1,141-line file loaded automatically by
agents. The new skill is 393 lines in `SKILL.md` plus 6,243 lines across
11 reference docs (6,636 total). To preserve the quick-hit value of the
old file, Common Gotchas and Best Practices sections were added to
`SKILL.md`. A root-level `CLAUDE.md` or `AGENTS.md` points agents to the
skill for discoverability.
## Overall Flow
```mermaid
sequenceDiagram
participant User
participant CPA as create-payload-app
participant GitHub
User->>CPA: npx create-payload-app --agent claude
CPA->>CPA: Parse template, select DB
CPA->>CPA: selectAgent() — validates flag or shows prompt
CPA->>CPA: Download template, configure config, manage env
CPA->>GitHub: GET codeload.github.com/.../tar.gz/main
GitHub-->>CPA: Tarball (filtered to skills/payload/)
CPA->>CPA: Extract to .claude/skills/payload/
CPA->>CPA: Write CLAUDE.md at project root
CPA->>CPA: Install deps, init git
CPA-->>User: Project ready with Payload skill installed
```1 parent 62aa42b commit 9f9f343
134 files changed
Lines changed: 234 additions & 43346 deletions
File tree
- packages/create-payload-app/src
- lib
- utils
- templates
- _agents
- rules
- blank
- .cursor/rules
- ecommerce
- .cursor/rules
- website
- .cursor/rules
- with-cloudflare-d1
- .cursor/rules
- with-postgres
- .cursor/rules
- with-vercel-mongodb
- .cursor/rules
- with-vercel-postgres
- .cursor/rules
- with-vercel-website
- .cursor/rules
- tools
- claude-plugin/skills/payload
- scripts/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | | - | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| |||
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
173 | 202 | | |
174 | 203 | | |
175 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| |||
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| 240 | + | |
| 241 | + | |
234 | 242 | | |
| 243 | + | |
235 | 244 | | |
236 | 245 | | |
237 | 246 | | |
| |||
255 | 264 | | |
256 | 265 | | |
257 | 266 | | |
| 267 | + | |
258 | 268 | | |
| 269 | + | |
259 | 270 | | |
260 | 271 | | |
261 | 272 | | |
| |||
266 | 277 | | |
267 | 278 | | |
268 | 279 | | |
| 280 | + | |
269 | 281 | | |
270 | 282 | | |
| 283 | + | |
271 | 284 | | |
272 | 285 | | |
273 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| 99 | + | |
| 100 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
0 commit comments