# Build a SpacePress app

You are helping someone build a TypeScript application that compiles directly into native PHP, SQL migrations, and WordPress plugins — headful WordPress by default, zero Node.js in production. Finish with a working local WordPress site they can open and inspect.

## 1. Inspect the current directory

Look at what is already in the workspace before scaffolding or asking questions. If the goal is still unclear, ask **one** concise question: *What are you building, and what should editors manage in WordPress?* Do not re-ask anything the user already told you.

Choose the matching path:

- **Already a SpacePress project (`typedpress.config.ts` exists):** Read `AGENTS.md` and use the `typedpress` MCP server (`schema`, `check`, `docs_search`, `docs_read`). Do not scaffold over it.
- **Migrating an existing schema (EmDash, Payload, Sanity, or Zero):** Run `npx typedpress migrate config --from emdash|payload|sanity|zero <input> --out typedpress.config.ts` to convert statically without executing source code.
- **Brand new project:** Scaffold with `npm create typedpress@0.3.0 <dir>` (uses the pre-release identifier `typedpress` for CLI, config file, and imports; requires Node.js 22+, no Docker or Rust toolchain). It writes `AGENTS.md`, `.mcp.json`, and 12 skills into `.agents/skills/` and `.claude/skills/`.
- **Different existing app:** Ask before replacing its framework or files.

## 2. Read the compiler rules first

Read [https://spacepress.dev/rules.md](https://spacepress.dev/rules.md) before writing TypeScript so you follow the exact TS-to-PHP subset, import boundaries, access rules, and safe migration conventions on the first try.

## 3. Build one complete vertical slice

1. **Model the data:** Use `collection()` (or `wp.posts.extend()`) for editorial content backed by WordPress posts (Gutenberg, drafts, revisions, `sync: "content/**/*.md"`), and `table()` for relational SQL data with explicit `access` rules.
2. **Add server logic & pages:** Export `action()` RPC endpoints or `job()` queues from `tp/`, and build at least one headful server-rendered TSX page in `tp/app/` (plus a `"use client"` island if interactivity is needed). Only generate/wire an external frontend (`tp/_generated/client/` or `@typedpress/astro`) if the user explicitly wants headless.
3. **Compile and check:** Run `npx typedpress check` after every edit (`npx typedpress check --fix` fixes lint warnings like `capital_P_dangit`), and `npx typedpress init` after changing `typedpress.config.ts` so `AGENTS.md` stays in sync.
4. **Boot local WordPress and verify:** Run `npm run dev` (or `npx typedpress dev --detach`). Confirm the local site and `/wp-admin/new/` respond cleanly.
5. **Hand back:** Share the local site URL, `/wp-admin/new/` admin URL, what is editable, and any remaining caveats. Do not create production credentials or push to a live site without explicit user approval.

## 4. Reference & discovery

- Compiler rules: https://spacepress.dev/rules.md
- Full documentation index: https://spacepress.dev/llms.txt
- Full documentation corpus: https://spacepress.dev/llms-full.txt
- Agent skills catalog: https://spacepress.dev/.well-known/agent-skills/index.json
- Local dev MCP server: `npx --no-install typedpress mcp` (read-only docs, live schema, check, and local queries; separate from a running site's authenticated runtime MCP at `<site>/wp-json/mcp/typedpress-<app>`).
