projx / cli
CLAUDE.md71 starsChanged 4 months agoMITView on GitHub
Stack-scoped notes. The root ../CLAUDE.md is the primary reference for the CLI's behavior (commands, template engine, ORM addons, feature templates) — this file carries the local dev shapes. Read both. Unlike the sibling stack dirs, cli/ is not a copied template — it's the engine. It's excluded from the component copy (EXCLUDE in src/utils.ts) and is the only section that gates the CLI itself.
In this repository15 other files it gives its agents.
- admin-panel/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- e2e/CLAUDE.mdCLAUDE.md
- express/CLAUDE.mdCLAUDE.md
- fastapi/CLAUDE.mdCLAUDE.md
- fastify/CLAUDE.mdCLAUDE.md
- go/CLAUDE.mdCLAUDE.md
- infra/CLAUDE.mdCLAUDE.md
- laravel/CLAUDE.mdCLAUDE.md
- mobile/CLAUDE.mdCLAUDE.md
- nextjs/CLAUDE.mdCLAUDE.md
- rust/CLAUDE.mdCLAUDE.md
- scripts/CLAUDE.mdCLAUDE.md
- vitejs/CLAUDE.mdCLAUDE.md
- projxSkill
The file
Files
cli — create-projx CLI source (projx engine)
Stack-scoped notes. The root
../CLAUDE.mdis the primary reference for the CLI's behavior (commands, template engine, ORM addons, feature templates) — this file carries the local dev shapes. Read both.Unlike the sibling stack dirs,
cli/is not a copied template — it's the engine. It's excluded from the component copy (EXCLUDEinsrc/utils.ts) and is the only section that gates the CLI itself.
Stack
- Runtime — Node, TypeScript ESM
- Build —
tsup(--format esm --target node18) - Test — Vitest + v8 coverage; ≥80% enforced (statements/branches/functions/lines) in
vitest.config.ts - Lint / format — eslint + prettier
- Published as —
create-projx(npm);package.json#filesships onlydist+src/templates
Layout
| Path | What it holds |
src/index.ts | parseArgs + subcommand dispatch (create/update/add/init/pin/unpin/diff/doctor/gen/sync) |
src/scaffold.ts | Base scaffold flow (copy components, render templates, install) |
src/baseline.ts | applyOrmAddon — ORM addon dispatch (Node packageOverrides / Go gomodOverrides) |
src/gen.ts | Entity generators incl. append<Orm>Entity |
src/features.ts | Feature-overlay application (--<feature>=<targets>) |
src/detect.ts, src/doctor.ts, src/diff.ts, src/sync.ts, src/pin.ts, src/init.ts, src/add.ts, src/update.ts | One file per subcommand / concern |
src/prompts.ts | Interactive prompts (@clack/prompts) |
src/utils.ts | Hand-rolled template engine (render), provider constants, copy filters (EXCLUDE/EXCLUDE_FILES), pm commands |
src/templates/*.ejs | Shared scaffold files rendered at scaffold time (ci.yml, setup.sh, docker-compose, pre-commit, README) |
tests/*.test.ts | One suite per src/ module |
Conventions
- The template engine is intentionally minimal —
render()insrc/utils.tssupports only<% if %>,<% for %>,<%= expr %>. Do not add a dependency on real EJS. - Subcommands, flags, ORM addons, and feature templates are documented once in root — extend there when adding behavior. Adding an ORM/feature touches
ORM_PROVIDERS/KNOWN_FEATURESinsrc/utils.tsand the help string insrc/index.ts. - Addons / features / component dirs are fetched from the repo tarball at runtime, not bundled — use
--local <path>during dev. - pnpm is the default package manager (
DEFAULT_PACKAGE_MANAGERinsrc/utils.ts) for new JS scaffolds —create/initdefault to it; npm/yarn/bun stay selectable. On scaffold, JS components get"packageManager": "pnpm@<PNPM_VERSION>"stamped intopackage.json(stampPackageManagerinsrc/baseline.ts, pnpm-only). The pinned version lives once aspmCommands(pm).version(PNPM_VERSION, currentlypnpm@11.5.2+sha512…) and also renders the Dockerfilecorepack prepareline — including the ORM-addon Dockerfile inormNodeDockerfileSource(pm.version, not a literal) — so don't re-hardcode it. pnpm-specific config lives in each template'spnpm-workspace.yaml(overrides:for security pins,allowBuilds:for build-script approval), not the package.jsonpnpmfield — pnpm 11 stopped reading that field, and a frozen install mismatches a lockfile that recorded the oldpnpm.overrides. Back-compat:add/update/gen/diffstill read the PM from the project's.projx(missing field → npm), so existing projects never flip. - Shipped artifacts never hard-code a component directory (root §"Never hard-code a component directory in a shipped artifact"). Rendered
.ejsuse<%= paths.<type> %>/ iterate*Instances;resolvePrimarySourceDirs(paths)insrc/utils.tsis injected into everyrenderEjsInDircall asbackendSourceDir/frontendSourceDir(for infra's single-pipeline / tfvars assumption). Static shell (scripts/projx-dirs.sh,validate-nginx-config.sh) is added to thestaticScriptscopy list insrc/utils.ts. Covered bytests/instance-aware-dirs.test.ts.
Testing — the CLI test pattern
- Never
vi.mock('@clack/prompts')— it pollutes the module cache across files. Spy onutilsModuleinstead (see existing suites). - Mirror one
tests/<name>.test.tspersrc/<name>.ts. New behavior ships with a failing test first (root §"TDD"). - The entrypoint guard is only exercisable via the built binary —
tests/entrypoint.test.tsrunsdist/index.jsthrough a symlink (thenpx/.binpath); function-importing unit tests bypass it. Build first, and never assert CLI behavior only by real-path invocation.
Quality gates (root §"Local development loop")
pnpm --dir cli build → pnpm --dir cli exec tsc --noEmit → pnpm --dir cli exec eslint src/ tests/ → pnpm --dir cli test (vitest, v8 ≥80%). Green or not done.
Things that bite
pnpm execafter a pipe (| tail/head) masks exit codes — use${PIPESTATUS[0]}or no pipe when verifying success.- The 80% coverage threshold is hard — new
src/code without tests drops the aggregate and fails the gate. - In production the CLI is only reached through a
binsymlink (npx create-projx,npm create projx, a global install →node_modules/.bin/create-projx→dist/index.js), but every gate invokes it by its real path (node cli/dist/index.js— the dev loop,scripts/scaffold-fuzz.py, the dispatch tests) or imports its functions directly. So an entrypoint break is invisible to CI. TheisMainEntrypoint()guard insrc/index.tsmustrealpathSync(process.argv[1])before comparing toimport.meta.url— through a symlink the two differ, a naive compare is always false, andmain()never runs, so every command silently exits 0 with no output. This was latent from v1.7.4 to v1.9.3. Regression-guarded bytests/entrypoint.test.ts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

