# Oh My IDEtch > Complete guides to the Oh My IDEtch LocalWP Devkit and Etch Agent MCP workflows. This file contains all documentation content in a single document following the llmstxt.org standard. ## LocalWP Devkit The Oh My IDEtch LocalWP Devkit is a reusable workspace for building code-owned Etch sites against LocalWP. Local owns WordPress, PHP, MySQL, routing, SSL, Mailpit, and Site Shell. The devkit owns project source, agent instructions, verification commands, sync, WP-CLI wrappers, and deployable plugin ZIPs. Start by downloading the LocalWP devkit ZIP from your [OhMyEtch account](https://ohmyetch.com/my-account/): ```text oh-my-idetch-localwp-devkit-.zip ``` Extract it once, keep it as a long-lived workspace, and create one project folder per LocalWP site. ## Mental Model The devkit has two surfaces: | Surface | Purpose | | --- | --- | | Devkit root | Shared commands, generated agent instructions, project templates, and package scripts. Open this folder in your agent. | | `projects/` | The source of truth for one website: PHP site builders, CMS JSON, project notes, tests, reports, and project ZIP output. | The Local site receives only a synced runtime plugin copy at: ```text wp-content/plugins/oh-my-idetch ``` Do not edit that synced plugin copy as your source. Edit the project under `projects/`, check it, sync it, then verify in LocalWP. ## What Is Not Bundled The devkit does not include premium or user-owned runtime files. Install these in your own Local site when your project needs them: | Dependency | Ownership | | --- | --- | | Etch | User-owned runtime plugin. | | Etch Theme | User-owned theme/runtime dependency. | | OhMyEtch | User-owned component plugin. | | AutomaticCSS | User-owned styling system. | | ACF Pro or other CMS field plugins | User-owned CMS dependency. | | Local Blueprints | Private user-created Local artifacts, not Oh My IDEtch release artifacts. | Use `bun run localwp:doctor -- --project ` and `bun run localwp:capabilities -- --project ` before assuming those runtime capabilities are available. ## Typed Builder Authoring All Etch presentation is authored with the typed PHP builders from the Composer package `honestlydesign/etch-builders`, pinned per devkit release. Fluent builders compose blocks, styles, loops, components, and CMS-backed content, and their guardrails reject lazy HTML dumps before anything reaches WordPress. The project template ships runnable builder examples under `examples/builders/`. ## The Core Loop Every project change follows the same order: ```sh bun run project:check -- --project bun run localwp:sync -- --project bun run localwp:verify -- --project ``` The check lints PHP, runs PHPStan, and compiles the project site definition without writing to WordPress. The check must run before sync: the Local site never receives unchecked project source. After a successful sync, `localwp:verify` runs a fast read-only runtime check of compiled digests, recorded ownership, required capabilities, and the installed Builder contract. For deeper inspection, use the browser, WordPress admin, or WP-CLI: ```sh bun run localwp:wp -- --project -- plugin list ``` ## Start Here 1. [Install and Prepare](/oh-my-idetch/localwp-devkit/install-and-prepare) explains what to install before opening the devkit in an agent. 2. [First Project](/oh-my-idetch/localwp-devkit/first-project) walks through `/new-project` and manual setup commands. 3. [Daily Workflow](/oh-my-idetch/localwp-devkit/daily-workflow) covers the build, check, sync, and verify loop. 4. [Command Reference](/oh-my-idetch/localwp-devkit/command-reference) lists every devkit command. 5. [Troubleshooting](/oh-my-idetch/localwp-devkit/troubleshooting) covers the common blockers. 6. [Ship a Plugin ZIP](/oh-my-idetch/localwp-devkit/ship-plugin-zip) explains the production ZIP path. --- ## Install and Prepare The LocalWP Devkit expects you to bring a working Local site and the runtime plugins you own. It is not a Local site import, a Local Blueprint, or a bundle of premium plugin files. ## Prerequisites Install these on your machine before creating a project: | Requirement | Notes | | --- | --- | | LocalWP | Creates and runs the WordPress site. | | Node.js 20 or newer | Required by the devkit package engine and related JavaScript tooling. | | Bun | Runs devkit package scripts. Use the version declared by the devkit `packageManager` field when possible. | | Composer | Used when a project needs PHP dependencies for checks such as PHPStan. If `project:check` reports missing dependencies, run the exact `composer install --working-dir=...` command it prints. | | Git | Recommended for tracking the long-lived devkit workspace and each project under `projects/`. | | The devkit ZIP | Download `oh-my-idetch-localwp-devkit-.zip` from your [OhMyEtch account](https://ohmyetch.com/my-account/). | | User-owned runtime plugins | Etch, Etch Theme, OhMyEtch, AutomaticCSS, ACF Pro, WooCommerce, or other project dependencies as needed. | LocalWP provides the WordPress runtime, PHP, MySQL, WP-CLI Site Shell, SSL, Mailpit, and the bound local domain. The devkit does not replace those services; it runs checks and syncs project source into the Local site. The devkit can continue without optional browser automation. When available, browser automation lets agents open the bound LocalWP domain, inspect pages, and capture screenshots after sync. ## Extract the Devkit Extract the ZIP into a durable working directory: ```text oh-my-idetch-localwp-devkit/ ``` Then install dependencies: ```sh bun install ``` Initialize your own Git history for the devkit workspace: ```sh git init git add . git commit -m "Initial LocalWP devkit" ``` The devkit ships with a `.gitignore`, but it does not ship with your repository history. ## Prepare a Local Site Create or reuse a LocalWP site. Install and activate the runtime dependencies this project needs in that Local site. At minimum, an Etch site normally needs Etch and Etch Theme. If the project uses OhMyEtch components, AutomaticCSS, ACF Pro, WooCommerce, or other plugins, install and license them in Local before expecting the devkit to use those capabilities. You can save a private Local Blueprint after the site is configured: 1. Create a clean Local site. 2. Install and license your user-owned runtime plugins. 3. Confirm the site is ready with `localwp:doctor` after binding a project. 4. In Local, save the site as a Blueprint for your own future work. That Blueprint remains private to you. It is not part of the Oh My IDEtch devkit. ## Open the Right Folder Open the devkit root in your agent: ```text oh-my-idetch-localwp-devkit/ ``` Do not open the synced plugin directory inside the Local site as your working source: ```text ~/Local Sites//app/public/wp-content/plugins/oh-my-idetch ``` That directory is output from `localwp:sync`. Your editable project source lives under `projects/`. ## Update the Devkit Later When a newer devkit ZIP is released, plan the update with a dry run: ```sh bun run devkit:update -- --zip /path/to/oh-my-idetch-localwp-devkit-.zip ``` Apply the update after reviewing the plan: ```sh bun run devkit:update -- --zip /path/to/oh-my-idetch-localwp-devkit-.zip --apply ``` The updater never changes `projects/**`, `.git/**`, `.env*`, `node_modules/**`, `dist/**`, or `var/**`. It updates only devkit-owned tooling, generated agent guidance, and the project template. --- ## First Project Start a LocalWP-backed project from the devkit root. The easiest path is to let your agent run the built-in onboarding workflow. ## Recommended Agent Flow Open the devkit root in your agent and send: ```text /new-project ``` The agent should ask for only the missing setup details: | Input | How it is used | | --- | --- | | Local site name | The agent matches it against LocalWP sites. | | Build brief | The agent records what the site should become. | | Project slug | Usually inferred from the Local site name. The agent asks only if the inferred slug is invalid, already exists, ambiguous, or you want a custom one. | | Browser automation choice | Optional. Used for page previews and screenshots after sync when not already installed. | If the Local site does not exist, create it in Local first. The devkit does not create Local sites, ship premium plugins, provide licenses, or generate Local Blueprints for you. ## What `/new-project` Does The workflow creates and binds a project, then checks the initial runtime surface before the first sync: ```sh bun run localwp:list bun run project:create -- bun run localwp:bind -- --project --site "" bun run project:check -- --project bun run localwp:sync -- --project bun run localwp:doctor -- --project bun run localwp:capabilities -- --project ``` It may also try to activate the synced plugin: ```sh bun run localwp:wp -- --project -- plugin activate oh-my-idetch ``` If WP-CLI is unavailable because Local has not generated a Site Shell entry, open Local, choose the site, select **Open Site Shell**, and rerun the command or activate the plugin in WordPress admin. ## Manual Setup Use the manual commands when you do not want the agent onboarding flow: ```sh bun run localwp:list ``` Create the project: ```sh bun run project:create -- my-site ``` Bind it to a Local site: ```sh bun run localwp:bind -- --project my-site --site "My Site" ``` Run the first check and sync: ```sh bun run project:check -- --project my-site bun run localwp:sync -- --project my-site ``` Inspect readiness and installed capabilities: ```sh bun run localwp:doctor -- --project my-site bun run localwp:capabilities -- --project my-site ``` ## Project Files After setup, use the project directory as the site source: ```text projects/my-site/ project.json AGENTS.project.md oh-my-idetch.php src/ cms/ examples/ tests/ tools/ var/ ``` The template also ships `composer.json`, `composer.lock`, `phpstan.neon.dist`, and `phpunit.xml.dist` for project-local PHP tooling, plus runnable typed-builder examples under `examples/builders/`. Keep project-specific brief notes, constraints, runtime expectations, and Local binding notes in `projects/my-site/AGENTS.project.md` so future agent sessions start with the right context. --- ## Daily Workflow The LocalWP Devkit is file-first. Build in the project folder, check the project, sync the runtime plugin copy into LocalWP, then verify against the bound Local site. ## Edit Project Source Work under: ```text projects/ ``` Common project source paths are: | Path | Purpose | | --- | --- | | `src/Site/**` | Typed Etch presentation builders and site composition, authored with `honestlydesign/etch-builders`. | | `cms/acf-json/**` | Field group JSON that can be synced through WordPress. | | `tests/**` | Project-local test support. | | `AGENTS.project.md` | Project brief, Local binding notes, and user-owned runtime expectations. | Do not use the synced Local plugin copy as the source of truth. It is replaced by sync. ## Check Before Sync Run the project verification gate: ```sh bun run project:check -- --project ``` This validates the runtime surface, rejects unsafe links, lints PHP files, runs PHPStan with a default `1G` memory limit, and compiles the exact project site definition without writing to WordPress. If the check reports missing PHPStan dependencies, run the exact `composer install --working-dir=...` command it prints, then rerun `project:check`. ## Sync to LocalWP Only sync after the check passes: ```sh bun run localwp:sync -- --project ``` Sync writes the project runtime plugin surface into the bound Local site: ```text wp-content/plugins/oh-my-idetch ``` It does not sync project notes, tests, tools, package metadata, agent files, local environment files, or user-owned premium plugins. Sync reruns the no-write project check, copies the runtime surface, and applies the compiled site definition in WordPress. It fails closed when the check, the runtime preflight, the copy, or the apply fails, and a successful sync prints exact `applied` and `unchanged` evidence. ## Verify After Sync Run the fast read-only runtime verification after every successful sync: ```sh bun run localwp:verify -- --project ``` It checks the compiled entity/resource digests, recorded ownership, required active capabilities, and the installed Builder contract, without browser E2E. Add a single lightweight frontend availability check only when it is part of the task: ```sh bun run localwp:verify -- --project --path / ``` ## Verify Runtime Behavior Use the bound LocalWP domain shown by Local or recorded in `project.json`. Do not assume a fixed localhost port. Use WP-CLI through the devkit wrapper: ```sh bun run localwp:wp -- --project -- plugin list bun run localwp:wp -- --project -- option get home ``` Check site readiness: ```sh bun run localwp:doctor -- --project ``` Inspect runtime capabilities: ```sh bun run localwp:capabilities -- --project ``` For visual or interactive work, verify in the browser after sync. OhMyEtch CSS, JavaScript, dropdowns, drawers, facets, Woo Store API behavior, checkout gateways, and fixed runtime styles need the active LocalWP site; project checks alone do not prove those runtime behaviors. ## Safe Agent Handoff When handing a project to an agent, include: - the devkit root path; - the project slug; - the exact Local site name; - the current build brief; - user-owned dependencies that should be active; - whether browser automation is available; - the last `project:check`, `localwp:sync`, `localwp:doctor`, and `localwp:capabilities` result. The agent should start in the devkit root and treat `projects/` as the editable source. --- ## Command Reference Run these commands from the devkit root unless noted otherwise. ## Project Setup ### `/new-project` Starts the agent-guided onboarding flow. Use it when creating or binding a LocalWP-backed project. ```text /new-project ``` The flow matches a Local site, infers a project slug, creates `projects/` when needed, binds it, checks it, syncs it, runs readiness checks, and records project notes. ### `localwp:list` Lists LocalWP sites visible on the machine. ```sh bun run localwp:list ``` Use this before binding when you need the exact Local site name, domain, or path. ### `project:create` Creates a project from the devkit project template. ```sh bun run project:create -- my-site ``` The slug must use lowercase letters, numbers, and dashes. The command fails if the project already exists. ### `localwp:bind` Binds a project to one Local site. ```sh bun run localwp:bind -- --project my-site --site "My Site" ``` You can also bind by site ID or web root when needed: ```sh bun run localwp:bind -- --project my-site --site-id bun run localwp:bind -- --project my-site --web-root "/Users/me/Local Sites/my-site/app/public" ``` Binding writes the Local web root and target plugin path into `projects/my-site/project.json`. ## Build and Sync ### `project:check` Checks the project runtime source before sync or packaging. ```sh bun run project:check -- --project my-site ``` Run this before every sync after changing `src/**` or `cms/**`. ### `localwp:sync` Copies checked runtime plugin files into the bound Local site. ```sh bun run localwp:sync -- --project my-site ``` Sync output goes to the Local site plugin path: ```text wp-content/plugins/oh-my-idetch ``` ## LocalWP and WordPress Inspection ### `localwp:wp` Runs WP-CLI through Local's Site Shell environment when available. ```sh bun run localwp:wp -- --project my-site -- plugin list bun run localwp:wp -- --project my-site -- plugin is-active oh-my-idetch bun run localwp:wp -- --project my-site -- option get home ``` If Local has not generated the shell entry, open Local, select the site, choose **Open Site Shell**, and run the printed fallback command manually. ### `localwp:doctor` Reports project and Local site readiness. ```sh bun run localwp:doctor -- --project my-site ``` It checks binding, web root availability, WP-CLI availability, WordPress environment type, synced plugin state, plugin activation, and runtime plugin status when WP-CLI works. ### `localwp:capabilities` Prints JSON describing active runtime capabilities. ```sh bun run localwp:capabilities -- --project my-site ``` Use it before assuming Etch, OhMyEtch, AutomaticCSS, CMS fields, or WooCommerce support exists in the bound Local site. ### `localwp:verify` Runs the fast read-only runtime verification after sync. ```sh bun run localwp:verify -- --project my-site ``` It checks the compiled entity/resource digests, recorded ownership, required active capabilities, and the installed Builder contract, without browser E2E. Add one lightweight frontend availability check only when it is part of the task: ```sh bun run localwp:verify -- --project my-site --path / ``` ## Devkit Updates ### `devkit:update` Plans and applies updates from a newer devkit ZIP. Always dry-run first: ```sh bun run devkit:update -- --zip /path/to/oh-my-idetch-localwp-devkit-.zip ``` Apply the update after reviewing the plan: ```sh bun run devkit:update -- --zip /path/to/oh-my-idetch-localwp-devkit-.zip --apply ``` The updater never changes `projects/**`, `.git/**`, `.env*`, `node_modules/**`, `dist/**`, or `var/**`. It updates only devkit-owned tooling, generated agent guidance, and the project template. ## Builder Authoring Queries Offline queries against the verified authoring knowledge of the pinned `honestlydesign/etch-builders` package. Use them to confirm the real builder API surface instead of guessing it. ### `builder:help` Shows what an authoring capability allows: ```sh bun run builder:help -- --intent ``` ### `builder:component` Looks up a component contract: ```sh bun run builder:component -- --key ``` ### `builder:explain` Explains a builder diagnostic code: ```sh bun run builder:explain ``` ### `builder:escape` Checks whether an intent has a sanctioned checked-escape path and prints its guidance: ```sh bun run builder:escape -- --intent ``` ## CMS Commands CMS operations for the bound Local site. The project directory `cms/acf-json/**` is the source of truth for field groups. ### `cms:acf:status`, `cms:acf:sync`, `cms:acf:import`, `cms:acf:export` ```sh bun run cms:acf:status -- --project my-site bun run cms:acf:sync -- --project my-site bun run cms:acf:import -- --project my-site bun run cms:acf:export -- --project my-site ``` Report, sync, import, and export ACF field group JSON between the project and WordPress. ### `cms:rewrite` Flushes WordPress rewrite rules through the checked wrapper: ```sh bun run cms:rewrite -- --project my-site ``` ### `cms:post:generate` and `cms:term:generate` Generate posts and taxonomy terms for content modeling: ```sh bun run cms:post:generate -- --project my-site bun run cms:term:generate -- --project my-site ``` ### `cms:media:import` and `cms:media:featured` Import media files into WordPress and attach featured images to posts: ```sh bun run cms:media:featured -- --project my-site -- --file= --post_id= [--title=] ``` ## Packaging ### `build:zip -- --project` Checks and packages one project as a production plugin ZIP. ```sh bun run build:zip -- --project my-site ``` The ZIP is written under: ```text projects/my-site/dist/oh-my-idetch-<version>.zip ``` Use this ZIP as the deployable project plugin artifact. --- ## Troubleshooting Most LocalWP Devkit issues fall into four groups: the wrong folder is open, the project is not bound, Local has not exposed WP-CLI automation yet, or required runtime plugins are not installed in the Local site. ## The Agent Is Editing the Wrong Folder Use the devkit root as the agent workspace: ```text oh-my-idetch-localwp-devkit/ ``` Project source lives here: ```text projects/<slug> ``` The synced Local plugin copy is not source: ```text ~/Local Sites/<site>/app/public/wp-content/plugins/oh-my-idetch ``` If changes were made directly in the synced plugin copy, move the intended source changes back into `projects/<slug>`, then run: ```sh bun run project:check -- --project <slug> bun run localwp:sync -- --project <slug> ``` ## Project Is Not Bound If `localwp:sync`, `localwp:wp`, or `localwp:doctor` says the project is unbound, bind it to a Local site: ```sh bun run localwp:list bun run localwp:bind -- --project <slug> --site "<Local site name>" ``` Use the exact Local site name shown by `localwp:list` or the Local app. ## WP-CLI Is Unavailable `localwp:wp` depends on Local's generated Site Shell entry. If the command prints a fallback, open Local, select the site, choose **Open Site Shell**, then rerun the devkit command. You can still continue with WordPress admin checks when WP-CLI is unavailable. Report the WP-CLI blocker clearly so the next session knows what happened. ## Runtime Plugin Is Missing or Inactive If `localwp:doctor` warns that the plugin root is missing, sync first: ```sh bun run project:check -- --project <slug> bun run localwp:sync -- --project <slug> ``` Then activate the plugin: ```sh bun run localwp:wp -- --project <slug> -- plugin activate oh-my-idetch ``` If WP-CLI is unavailable, activate `oh-my-idetch` in WordPress admin. ## Premium Dependencies Are Missing The devkit does not bundle Etch, Etch Theme, OhMyEtch, AutomaticCSS, ACF Pro, WooCommerce, or other premium/user-owned plugins. Install and license those in the Local site. Check the current runtime state: ```sh bun run localwp:doctor -- --project <slug> bun run localwp:capabilities -- --project <slug> ``` Missing optional plugins can be warnings when the project does not need them. They are blockers when the build depends on that runtime capability. ## Runtime Verification Fails If `localwp:verify` fails, the runtime state in the bound Local site does not match the compiled project source. The check fails closed, so do not treat it as a warning. Rerun the full loop: ```sh bun run project:check -- --project <slug> bun run localwp:sync -- --project <slug> bun run localwp:verify -- --project <slug> ``` If verification still fails, run `bun run localwp:doctor -- --project <slug>` and fix the reported LocalWP blocker before continuing. ## PHPStan Dependencies Are Missing If `project:check` reports a missing PHPStan binary, run the exact Composer command from the error. It will look like: ```sh composer install --working-dir=projects/<slug> ``` Then rerun: ```sh bun run project:check -- --project <slug> ``` ## Browser Verification Does Not Work Browser automation is optional. If it was not installed or failed to install, the project can still be created, checked, synced, and verified through LocalWP and WordPress admin. Use the bound LocalWP domain from Local or `project.json`; do not assume a fixed localhost port. ## The Local Site Shows Old Output Confirm that the source changed under `projects/<slug>`, not only in the synced plugin copy. Then run the required loop: ```sh bun run project:check -- --project <slug> bun run localwp:sync -- --project <slug> ``` If the page still shows old output, verify the `oh-my-idetch` plugin is active and the browser is loading the bound LocalWP domain. --- ## Ship a Plugin ZIP When a LocalWP Devkit project is ready to deliver, build a project plugin ZIP from the devkit root: ```sh bun run build:zip -- --project <slug> ``` The command runs the project check before packaging. If the check fails, fix the project and rerun the command. ## Output The ZIP is written inside the project: ```text projects/<slug>/dist/oh-my-idetch-<version>.zip ``` The ZIP root is: ```text oh-my-idetch/ ``` This is the runtime plugin artifact for that project. ## What Goes Into the ZIP The project ZIP contains the runtime plugin surface: | Included | Purpose | | --- | --- | | `oh-my-idetch.php` | WordPress plugin entry file. | | `src/**` | Project runtime PHP source. | | `cms/acf-json/**` | Project CMS field JSON when present. | | `flags.json` | Production mode marker with `MODE=PROD`. | The ZIP does not include devkit tooling, project notes, tests, generated agent skills, local environment files, Local site backups, Local Blueprints, or premium plugin files. ## Before You Ship Run the normal LocalWP verification loop first: ```sh bun run project:check -- --project <slug> bun run localwp:sync -- --project <slug> bun run localwp:verify -- --project <slug> bun run localwp:doctor -- --project <slug> bun run localwp:capabilities -- --project <slug> ``` Then verify the site in LocalWP using the bound Local domain. For WooCommerce, facets, dropdowns, drawers, checkout gateways, or other interactive OhMyEtch behavior, browser/runtime verification is required; the project ZIP command only proves the package can be built from checked source. ## Keep the Devkit Do not duplicate the whole devkit for every site. Keep the devkit as the long-lived workspace and create a new `projects/<slug>` folder for each site. Each project can build its own deployable plugin ZIP. --- ## Etch Agent MCP The Etch Agent (`etch-agent`) is an MCP server that lets AI agents such as Claude Code, Codex, and opencode work inside the Etch builder directly. Instead of screenshots and clipboard round-trips, the agent reads and edits your Etch documents through typed tools, follows the same read-then-edit flow you would, and saves only when you say so. It ships as a small ZIP you unzip once per machine. No browser extension, no model API keys, no global CLI install. ## Mental Model ```text your agent (Claude Code / Codex / opencode / …) │ MCP (stdio) etch-agent server ←→ shared local connector (127.0.0.1:7331) │ │ │ your authenticated browser └── typed tools ──► Etch builder tab (AI Connector enabled) ``` - The **server** is launched by your harness with Bun and exposes 81 typed Etch tools (as of 2.1.0). - The **connector** links the server to an Etch builder tab you already have open. You click **AI Connector** in the Etch builder; the browser dials out to `127.0.0.1:7331`. Your authenticated browser session is the only credential - the agent never sees your WordPress login. - **Project Memory** is a machine-local store keyed by your site URL, so every session starts by recalling what was previously decided and done on that site. ## What you need | Requirement | Notes | | --- | --- | | Bun 1.3.14 or newer | Runs the MCP server. Install it from [bun.sh/docs/installation](https://bun.sh/docs/installation). | | An active Etch license | The connector package (`@digital-gravy/etch-connector`) is installed locally under Digital Gravy's license terms. | | An authenticated Etch builder tab | Open the Etch builder for the page or template you want to edit, then click **AI Connector**. | | The etch-agent ZIP | Download `etch-agent-<version>.zip` from your [OhMyEtch account](https://ohmyetch.com/my-account/). | | Any MCP-capable agent | Claude Code, Codex, and opencode are documented here; any other MCP client works with the same pattern. | ## How editing works The agent never silently publishes changes. Tools split into three effect classes: | Effect | Tools | When it lands | | --- | --- | --- | | Read | trees, blocks, styles, components, fields, memory | Never changes anything. | | Buffered document edit | block, style, and loop tools | Applied in the open builder document only - visible immediately, saved only when you approve an explicit save. | | Immediate persist | stylesheets, components, custom fields, Project Memory | Written to the database right away. | Every step is reversible before saving: `etch_undo` walks the document back, and switching posts or templates is refused until buffered changes are saved or undone. See [First Session](./first-session.mdx) for the flow in practice. ## Where to go next - [Install](./install.mdx) - unzip, run one install command, wire up your harness. - [First Session](./first-session.mdx) - connect a builder tab and make your first (safe) edit. - [Daily Workflow](./daily-workflow.mdx) - memory, ACSS-aware styling, skills, multiple targets. - [Tool Reference](./tool-reference.mdx) - all 81 tools grouped by area. - [Troubleshooting](./troubleshooting.mdx) - empty target lists, port conflicts, safe-mode limits. --- ## Install The fastest path: unzip the package and tell your agent to read the bundled `onboarding.md`. It detects the harness, merges the config, and verifies the connection for you. This page is the same procedure written out for humans, with Claude Code, Codex, and opencode as the worked examples - any other MCP client follows the same shape. ## Unzip and install the runtime Extract `etch-agent-<version>.zip` into a durable location, for example: ```text etch-agent/ ├── README.md ├── AGENTS.md ├── CHANGELOG.md ├── onboarding.md ├── LICENSE └── mcp/ ├── server.js ← the MCP server your harness launches ├── package.json ← locked runtime manifest ├── bun.lock └── skills/ ← core and user agent skills ``` The unzipped folder name is version-agnostic, so a future release can be dropped over the same path without touching your MCP config. The version lives in the ZIP filename and `CHANGELOG.md`. Then install the locked runtime from the package root: ```sh bun install --cwd mcp --frozen-lockfile --no-save ``` This installs the connector (`@digital-gravy/etch-connector`), `ws`, and `zod` locally inside `mcp/node_modules/`. The ZIP deliberately contains no connector code - it is installed on your machine, under its own license terms, at review-pinned versions. Check your Bun version first (`bun --version`); **1.3.14 or newer** is required. ## Values every config needs Two absolute paths go into every harness config: | Placeholder | Meaning | How to get it | | --- | --- | --- | | `SERVER_PATH` | Absolute path to `mcp/server.js` inside the unzipped package. | Run `pwd` inside `mcp/` and append `/server.js`. | | `BUN_PATH` | Absolute path to the `bun` binary. | Run `which bun`. If the harness inherits your shell PATH, the plain string `"bun"` works. | Also pick a `--client-name` value (e.g. `claude`, `codex`, `opencode`) - it only labels the instance in startup logs. ## Claude Code Project-scoped config in `.mcp.json` at the project root, or a global entry under the top-level `mcpServers` object of `~/.claude.json`: ```json { "mcpServers": { "etch-agent": { "command": "BUN_PATH", "args": ["SERVER_PATH", "--client-name", "claude"] } } } ``` Merge into the existing `mcpServers` object; do not overwrite other entries. Restart Claude Code afterwards. ## Codex Config file: `~/.codex/config.toml`. TOML, not JSON: ```toml [mcp_servers.etch-agent] command = "BUN_PATH" args = ["SERVER_PATH", "--client-name", "codex"] ``` Append to the existing file; do not overwrite other `[mcp_servers.*]` blocks. Restart Codex afterwards. ## opencode Config file: `~/.config/opencode/opencode.json`. Note the shape differs from Claude Code: a single `command` array under `mcp`, no separate `args`: ```json { "mcp": { "etch-agent": { "type": "local", "command": ["BUN_PATH", "SERVER_PATH", "--client-name", "opencode"] } } } ``` Restart opencode afterwards. ## Other harnesses Most MCP clients use the Claude Code JSON shape - put `etch-agent` under the client's own `mcpServers` key: | Harness | Config location | | --- | --- | | Claude Desktop | `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/`, Windows: `%APPDATA%\Claude\`) | | Cursor | `.cursor/mcp.json` | | Windsurf | `~/.codeium/windsurf/mcp_config.json` | | ZCode | Settings UI → MCP Servers → paste the entry into **Full configuration** (scope: User) | The ZCode entry uses this JSON in the UI: ```json { "etch-agent": { "type": "stdio", "command": "BUN_PATH", "args": ["SERVER_PATH", "--client-name", "zcode"], "env": {} } } ``` ## Run several harnesses at once The connector is shared, not exclusive. The first harness to start becomes the connector host (it owns ports `7331` and `7332`); any harness started afterwards detects it and reuses it. You can install `etch-agent` into Claude Code, Codex, and opencode at the same time and run them simultaneously. Two rules: - **Only one agent should mutate the same Etch target at a time.** Two agents editing the same builder tab will collide. Different targets in different tabs are fine. - For an isolated instance (a scratch harness that must not share the connector), add a distinct port argument such as `--connector-ws-port 17331`. A custom port runs standalone: it hosts nothing and reuses nothing. ## Verify the installation 1. **Connector is up.** The first harness's startup log should read `[etch-agent:<name>] hosting the connector (host mode)`; any harness started later should read `reusing an existing connector (client mode)`. 2. **A target answers.** Log into WordPress, open the Etch builder for a page or template, and click **AI Connector** in the builder. Then ask your agent to call `etch_list_targets` - your tab should appear with its URL and title. If `etch_list_targets` comes back empty, see [Troubleshooting](./troubleshooting.mdx). --- ## First Session This page walks through one complete loop: connect a target, read the document, make a harmless edit, undo it, then make a real edit and save it on purpose. The same loop is what your agent should repeat for every task. ## 1. Connect the builder tab With the MCP server registered in your harness: 1. Log into WordPress and open the Etch builder for the page or template you want to edit. 2. Enable AI Connector in Etch if the builder asks for it, then click **AI Connector**. The tab dials out to the local connector - nothing is exposed to the internet. 3. Ask your agent to list targets and pick yours: ```text etch_list_targets → shows every connected builder tab etch_select_target → e.g. targetId "etch-base" ``` Each target carries its URL, title, and a heartbeat. The selected target is the working target for all following tools. ## 2. Recall Project Memory Before any status check or editing, the agent should call: ```text etch_recall_project_memory ``` On a brand-new site this returns an empty brief. From the second session on, it returns the Project Digest (a short narrative of the project's purpose, conventions, recent work, and open threads) plus a record Brief of stored facts. This is what makes sessions continuous instead of amnesiac. See [Daily Workflow](./daily-workflow.mdx#project-memory). ## 3. Read before writing ```text etch_get_status → Etch availability, runtime, unsaved-changes state etch_get_document_tree → the full block tree with ids etch_get_selected_block → whatever you have selected in the builder ``` Reading never changes anything. The tree gives the agent the block ids every later edit needs. ## 4. A harmless edit, then undo Ask for something visible but trivial - for example, re-apply a heading's current text. Under the hood the agent calls `etch_update_block` with the block's current text: a content no-op that still exercises the buffered edit path and the history stack. Then: ```text etch_undo → walks the document back etch_get_status → post-undo health check ``` The edit was buffered: it appeared in the open builder document, but nothing was saved. If you had closed the tab instead, WordPress would be untouched. ## 5. A real edit, reviewed, then saved 1. Ask for the actual change - a section rebuilt, new blocks inserted, a style adjusted. Block, style, and loop tools all land in the buffered document. 2. Review it in the Etch builder tab like any hand-made edit. Ask for `etch_undo` (repeatable) or further edits as needed. 3. When you are happy, say so. Only then does the agent call: ```text etch_save_document ``` Saving is always explicit. No tool in the buffered-edit class saves on its own, and the agent should never call save without your approval. ## What persists without saving Not everything is buffered. These tool classes write to the database immediately when called: - **Global stylesheets** (`etch_create_stylesheet`, `etch_update_stylesheet`, `etch_append_stylesheet`, `etch_delete_stylesheet`, `etch_add_custom_media`) - **Components** (`etch_upsert_agent_component`, `etch_delete_agent_component`, `etch_save_component_edit_mode`) - **Custom fields** (field groups, fields, and field values) - **Project Memory** (remember, correct, forget, digest writes) If an agent's plan involves these, expect changes to stick right away rather than waiting for a save. ## Safety rails to know - **Unsaved-changes guard.** Switching to another post or template (`etch_open_post`, `etch_open_template`) is refused while buffered changes exist; save or undo first. - **No credentials.** The agent never asks for your WordPress login. Your authenticated browser tab is the only credential, and the agent reaches it only through the connector. - **One agent per target.** Two agents editing the same builder tab will collide; keep one mutating agent per target. - **Typed payloads.** Block, style, component, and loop inputs are validated against the official Etch public API schemas before they reach the builder - malformed input returns a structured error in the same response instead of corrupting the document. --- ## Daily Workflow(Mcp) ## Start every session the same way A session that starts with recall inherits everything previous sessions learned: ```text etch_recall_project_memory → digest + record brief first, always etch_get_status → availability, unsaved changes etch_get_document_tree → current document ``` If recall reports the digest stale (records advanced 10+ revisions or the digest is older than 7 days), refresh it near the end of the session with `etch_write_project_digest`. ## Project Memory Project Memory is a bounded, machine-local store keyed by one normalized site URL. Staging and production URLs are separate keys with separate records; moving between them is an explicit rebind, never an automatic merge. | Tool | Use | | --- | --- | | `etch_recall_project_memory` | Read the digest and brief. Always first. | | `etch_remember_project_memory` | Store a confirmed Decision, Observation, or Reference the user stated. | | `etch_inspect_project_memory` | Audit exactly what is stored, per project. | | `etch_correct_project_memory` | Fix a stored record's payload under an expected revision. | | `etch_forget_project_memory` | Delete one record or a confirmed aggregate. | | `etch_write_project_digest` | Write/refresh the narrative digest (purpose, conventions, recent work, open threads). | | `etch_recover_project_memory` | Explicitly rebind after a URL change, or quarantine a corrupt store. | What it stores: bounded, allowlisted facts - decisions, observations, references, a digest, and an activity log (the last 50 successful non-read operations per project). What it never stores: credentials, raw page payloads, or your user skill files. Successful non-read calls are appended to the activity log automatically, so a returning session can see what was recently done. Two habits keep it healthy: - Confirm before remembering. The tool stores user-confirmed statements, not agent guesses. - If a staging site becomes production (or a domain changes), the agent runs a recover preview first and applies the rebind only after confirming the target is empty and both URLs are the same project. ## ACSS-aware styling On sites running [Automatic.css](https://automaticcss.com/), the agent should work in tokens, not invented values: ```text etch_detect_acss → detected, version, stylesheet URLs, sample palette/scale variables ``` When detection reports ACSS, the bundled `acss` core skill takes over styling: variables first (`var(--token)`), the t-shirt spacing scale, the 7-step shade system, contextual backgrounds with automatic text color, the `.scheme--dark` + `light-dark()` dark-mode flow, and `b:/s:/m:/l:/xl:/xxl:` breakpoint prefixes. Detection needs the builder tab to allow page probing. If AI tooling is connected in safe mode, `etch_detect_acss` reports that the sandbox withheld page access - switch the tooling to unsafe mode to enable detection, or confirm ACSS manually and let the agent read the bundled skill anyway. See [Troubleshooting](./troubleshooting.mdx#acss-detection-returns-a-safe-mode-error). For global CSS - `@keyframes`, `@property`, `@font-face`, utility classes, root variables - the stylesheet tools persist immediately, so prefer them for site-wide CSS and buffered styles for document-specific rules. ## Agent skills The server ships skills that teach agents the correct Etch workflow, and your agent should read the core skill before its first edit on a site: | Skill | Contents | | --- | --- | | `etchapi` | The 13 block variants, safe block shapes, read-then-write flow, stylesheets, loops, components, CSS authoring rules. | | `acss` | The ACSS token-first workflow and the full variable catalogue. | Your own conventions go into user skills - markdown files under `mcp/skills/user/<slug>/SKILL.md`, manageable through the tools (`etch_create_local_skill`, `etch_update_local_skill`, `etch_validate_local_skills`) or by hand. User skills are local to the machine and never leave it. `etch_list_skills` shows everything available. ## Working across targets and documents - **Multiple tabs.** Every builder tab with AI Connector clicked appears in `etch_list_targets`; the agent selects the working target explicitly. Different agents may work different targets simultaneously. - **Navigation.** `etch_go_to` moves the builder between areas (builder, templates, style manager, content hub, loop manager, asset manager); `etch_open_post` / `etch_open_template` switch documents - refused while buffered changes are unsaved. - **History.** `etch_undo` / `etch_redo` walk the document; undo is the always-available recovery from a bad apply, repeatable step by step. - **Color scheme.** `etch_get_color_scheme` / `etch_set_color_scheme` keep generated style values matching your builder theme. ## End-of-session routine Before wrapping up a substantive session: 1. Save (or explicitly discard) any buffered document changes. 2. Store the session's durable facts with `etch_remember_project_memory` - confirmed decisions, observations, references. 3. Refresh the digest with `etch_write_project_digest` if recall flagged it stale or the session changed direction. The next session on that site starts where this one ended. --- ## Tool Reference Every tool is typed: inputs are validated against the official Etch public API schemas and results come back as structured content your harness can rely on. The **Effect** column is the key to the editing model: - **read** - never changes anything. - **buffered** - lands in the open builder document; saved only by an explicit `etch_save_document`. - **persist** - written to the database immediately. - **session** - changes agent-side session state (which target is selected), nothing in WordPress. 81 tools as of 2.1.0. ## Targets, status, and navigation | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_targets` | read | List connected Etch targets and the current working target. | | `etch_select_target` | session | Select the working target for future tools. | | `etch_get_status` | read | Etch availability and runtime status, including unsaved changes. | | `etch_get_navigation_context` | read | Active document identity and builder navigation context. | | `etch_list_posts` | read | List posts visible from the target, optionally by post type. | | `etch_list_templates` | read | List templates visible from the target. | | `etch_open_post` | buffered | Switch the target to a post; refused while changes are unsaved. | | `etch_open_template` | buffered | Switch the target to a template; refused while changes are unsaved. | | `etch_go_to` | session | Navigate the builder to a supported UI area. | | `etch_get_color_scheme` | read | Read the builder color scheme. | | `etch_set_color_scheme` | persist | Set the builder color scheme. | ## Reading the document | Tool | Effect | What it does | | --- | --- | --- | | `etch_get_document_tree` | read | The current document's full block tree. | | `etch_get_block_json` | read | One block's full JSON payload. | | `etch_get_selected_block` | read | The block currently selected in the builder. | | `etch_find_blocks` | read | Find block ids by a typed predicate. | ## Editing blocks | Tool | Effect | What it does | | --- | --- | --- | | `etch_insert_blocks` | buffered | Insert validated blocks. | | `etch_replace_block` | buffered | Replace one block. | | `etch_update_block` | buffered | Patch one block (attributes, text, classes). | | `etch_mutate_block_attributes` | buffered | Granular attribute and class changes on one block. | | `etch_duplicate_block` | buffered | Deep-copy one block. | | `etch_move_block` | buffered | Move one block within the document. | | `etch_delete_block` | buffered | Delete one block. | | `etch_copy_block` | read | Copy one block into an opaque portable payload. | | `etch_paste_block` | buffered | Paste a copied payload anywhere in the document. | ## Saving and history | Tool | Effect | What it does | | --- | --- | --- | | `etch_save_document` | persist | Explicitly save the active document. Always user-approved. | | `etch_undo` | buffered | Undo the last document operation; repeatable. | | `etch_redo` | buffered | Redo the last undone operation. | ## Buffered styles | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_styles` | read | Buffered style rules and CSS variables. | | `etch_apply_style_patch` | buffered | Apply validated rules and CSS variables without saving. | | `etch_delete_style` | buffered | Delete one buffered style rule. | | `etch_get_style_variable` | read | Read one global CSS variable. | | `etch_remove_style_variable` | buffered | Remove one buffered CSS variable. | ## Global stylesheets | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_stylesheets` | read | List global stylesheets, optionally including CSS. | | `etch_get_stylesheet` | read | Read one global stylesheet. | | `etch_create_stylesheet` | persist | Create a global stylesheet. | | `etch_update_stylesheet` | persist | Update a global stylesheet. | | `etch_append_stylesheet` | persist | Append CSS to a global stylesheet. | | `etch_delete_stylesheet` | persist | Delete a global stylesheet. | | `etch_list_custom_media` | read | List global `@custom-media` definitions. | | `etch_add_custom_media` | persist | Add an `@custom-media` definition. | ## Components | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_components` | read | Component summaries, optionally filtered. | | `etch_get_component_json` | read | One component including its block tree. | | `etch_upsert_agent_component` | persist | Create or update a component by key. | | `etch_delete_agent_component` | persist | Delete components by key. | | `etch_enter_component_edit_mode` | session | Focus a component for direct editing of its tree. | | `etch_save_component_edit_mode` | persist | Persist the focused component. | | `etch_exit_component_edit_mode` | session | Leave focus mode, optionally reverting. | | `etch_is_in_component_edit_mode` | read | Whether focus mode is active. | ## Loops | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_loops` | read | List buffered loop definitions. | | `etch_upsert_loop` | buffered | Create or replace a loop by key. | | `etch_delete_loop` | buffered | Delete a loop by id. | | `etch_bind_loop_to_block` | buffered | Bind a loop definition to a loop block. | ## Custom fields | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_field_groups` | read | List all custom field groups. | | `etch_get_field_group` | read | Read one field group by id. | | `etch_create_field_group` | persist | Create a field group. | | `etch_update_field_group` | persist | Replace a field group. | | `etch_delete_field_group` | persist | Delete a field group. | | `etch_add_field` | persist | Add a field to a group. | | `etch_update_field` | persist | Replace a field in a group. | | `etch_remove_field` | persist | Remove a field from a group. | | `etch_get_field_values` | read | All resolved field values for a post. | | `etch_get_field_value` | read | One resolved field value for a post. | | `etch_set_field_value` | persist | Set one field value. | | `etch_set_field_values` | persist | Set several field values at once. | | `etch_delete_field_value` | persist | Clear one field value. | ## ACSS | Tool | Effect | What it does | | --- | --- | --- | | `etch_detect_acss` | read | Detect Automatic.css and sample its live variables in the builder tab. | ## Skills | Tool | Effect | What it does | | --- | --- | --- | | `etch_list_skills` | read | List core, user, and runtime skills. | | `etch_get_skill` | read | Read one skill by name and provider. | | `etch_get_skill_reference` | read | Read a declared reference file for a skill. | | `etch_list_local_skills` | read | List local core and user skills. | | `etch_create_local_skill` | persist | Create a user skill. | | `etch_update_local_skill` | persist | Update a user skill. | | `etch_validate_local_skills` | read | Validate locally authored user skills. | | `etch_create_skill_reference` | persist | Create or overwrite a reference file for a local skill. | ## Project Memory | Tool | Effect | What it does | | --- | --- | --- | | `etch_recall_project_memory` | read | Recall the Project Digest and record brief. Always first. | | `etch_inspect_project_memory` | read | Audit stored memory per project. | | `etch_remember_project_memory` | persist | Store one confirmed Decision, Observation, or Reference. | | `etch_correct_project_memory` | persist | Correct one record's payload under an expected revision. | | `etch_forget_project_memory` | persist | Delete one record or a confirmed aggregate. | | `etch_write_project_digest` | persist | Write the narrative Project Digest. | | `etch_recover_project_memory` | persist | Explicit URL rebind, or quarantine a corrupt store. | --- ## Troubleshooting(Mcp) ## `etch_list_targets` is empty The server is running but no builder tab is connected to the local connector. 1. Confirm the Etch builder tab is open in an authenticated WordPress admin session. 2. Enable AI Connector in Etch if the builder asks for it, then click **AI Connector** again - the tab dials out to `127.0.0.1:7331` only when connected. 3. Call `etch_list_targets` again (or `etch_recall_project_memory`, which falls back to listing when no working target exists). 4. If your harness runs in client mode (`reusing an existing connector`), confirm at least one other harness is actually running and hosting the connector. A client with no host has nothing to connect through. Never share your WordPress credentials with the agent - the authenticated browser tab is the only credential involved. ## `Could not bind the connector WebSocket port 7331` Another process owns port 7331 and is not acting as the shared connector - often a foreign process, or an older 1.1.x etch-agent that predates connector sharing. Either free port 7331, or give this instance its own port: ```json "args": ["SERVER_PATH", "--client-name", "claude", "--connector-ws-port", "17331"] ``` A custom port runs standalone: it does not host the shared control server and does not reuse another connector. ## `bun install` fails on the packaged runtime - **Bun too old.** `bun --version` must report 1.3.14 or newer; older releases are not verified against the packaged lockfile. - **Frozen lockfile mismatch.** Run the exact form `bun install --cwd mcp --frozen-lockfile --no-save` from the package root. The lockfile pins exact versions with integrity hashes; any drift is a hard error by design. - **Upgrading the package.** Unzip the new release over the existing `etch-agent/` folder (the folder name is version-agnostic) and re-run the install command. ## ACSS detection returns a safe-mode error `etch_detect_acss` reads the builder tab's stylesheets, and the Connector's safe-mode sandbox withholds page access entirely: ```text "globalThis" is not available in safe mode — only "etch" and standard JS built-ins are exposed. Connect the tooling in unsafe mode to run arbitrary scripts. ``` To use detection, connect AI tooling in unsafe mode in the Etch builder. Detection is optional for everything else: all editing tools work in safe mode, and the agent can follow the bundled `acss` skill once ACSS is confirmed manually. ## Switching posts or templates is refused `etch_open_post` and `etch_open_template` refuse while the document has buffered (unsaved) changes. Save with `etch_save_document`, or discard with `etch_undo` repeated until clean - `etch_get_status` reports the unsaved-changes state. ## Edits appear in the builder but WordPress is unchanged That is the buffered editing model working as designed. Block, style, and loop edits land in the open document only; nothing reaches the database until an explicit, user-approved `etch_save_document`. Note the exceptions that persist immediately: global stylesheets, components, custom fields, and Project Memory. ## A staging site moved to production (or the domain changed) Project Memory is keyed by the normalized site URL; it never merges data across URLs automatically. The agent runs `etch_recover_project_memory` in preview mode, confirms the target URL has no memory and both URLs are the same project, then applies the rebind. If the local store is corrupt, the same tool quarantines it to a sidecar file so a fresh store can be created. ## Two agents on the same target Only one agent should mutate the same Etch target at a time - two agents editing one builder tab will collide. Keep one mutating agent per target; reading, and any work on other targets, is fine in parallel. Multiple harnesses (Claude Code, Codex, opencode, …) can all run simultaneously and share one connector. ## The agent improvised a block structure that broke The agent should read the bundled `etchapi` skill (`mcp/skills/core/etchapi/SKILL.md`) before editing on a site - it defines the safe block shapes and the read-then-write flow. Recovery from a bad apply is always `etch_undo`, repeated as needed, before any save.