feat(cpa): add --agent flag for coding agent skill installation#16278
Merged
feat(cpa): add --agent flag for coding agent skill installation#16278
Conversation
…tallation Replace hard-coded .cursor/rules and AGENTS.md in templates with a dynamic --agent/-a flag that downloads the Payload skill at project creation time for the selected coding agent (claude, codex, cursor).
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
paulpopus
approved these changes
Apr 15, 2026
Contributor
|
🚀 This is included in version v3.83.0 |
milamer
pushed a commit
to milamer/payload
that referenced
this pull request
Apr 20, 2026
…oadcms#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 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Replace hard-coded
.cursor/rulesandAGENTS.mdfiles in templates with a dynamic--agentflag increate-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. ACLAUDE.mdorAGENTS.mdis written at the project root to point the agent to the skill.Supports
claude,codex,cursorinitially.Key Changes
New
--agent/-aflag and--no-agentflagclaude,codex, andcursoras agent values--no-agentskips the prompt entirely, matching the--no-deps/--no-gitpatternRuntime skill download via GitHub tarball
download-skill.tsmodule reuses the samecodeload.github.comtarball + filter approach asdownload-template.tstools/claude-plugin/skills/payload/and extracts it to the agent's skill directory.claude/skills/payload/, Codex and Cursor use.agents/skills/payload/Agent config file at project root
CLAUDE.md, Codex/Cursor →AGENTS.md(never both)Removed static agent files from templates
templates/_agents/directory (source for copied rules)AGENTS.mdand.cursor/rules/from all 8 templates (~43k lines removed)skipAgents/copyAgentsFileslogic fromgenerate-template-variations.tsAdded Common Gotchas and Best Practices to SKILL.md
AGENTS.md— same 10 gotchas and 5 best-practice categories now in the skillDesign Decisions
Agent selection follows the existing
select-db.tspattern: 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
mainbranch without requiring a CPA release. The--branchflag (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 singleagentChoicesarray inselect-agent.ts.The old
AGENTS.mdwas a single 1,141-line file loaded automatically by agents. The new skill is 393 lines inSKILL.mdplus 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 toSKILL.md. A root-levelCLAUDE.mdorAGENTS.mdpoints agents to the skill for discoverability.Overall Flow
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