Keep or cut rat-stack
Delete interfaces your product will not use. Do not keep code because you might need it one day.ΒΆ
A capability is one named action with a contract and a server-side handler. The contract defines its name, input, output, failure, and metadata. A projection builds a callable interface from capabilities.ΒΆ
CLI means command-line interface. MCP (Model Context Protocol27) lets an agent discover and call tools. Effect describes work with typed failures36 and required dependencies.ΒΆ
Read AGENTS.md first. Keep unrelated product work. Check imports and tests before deleting files.ΒΆ
Smallest version: command line only
Keep these files:ΒΆ
packages/capability/src/contract.tsΒΆpackages/capability/src/implement.tsΒΆpackages/capability/src/to-command.tsΒΆpackages/capability/src/call-watch.tsandpackages/capability/src/actor-watch.tsΒΆ- every module imported by these files or retained core code, and their testsΒΆ
- all of
packages/coreΒΆ - the CLI composition needed by the projected commandΒΆ
defineContract, implement, and toCommand keep the shipped stats command working. contract.ts does not depend on the other interfaces.ΒΆ
For CLI only, delete:ΒΆ
- unused projections and their matching tests in
packages/capability/srcandpackages/capability/test, only after tracing imports from the keep listΒΆ
Keep apps/cli/src/surfaces.ts with only the toCommand composition and its imports. Remove these unused CLI interfaces:ΒΆ
catalog,openapi,serve, andmcpcommands fromapps/cli/src/command.tsΒΆapps/cli/test/serve.test.tsΒΆ- catalog, OpenAPI, MCP, and code-mode cases from
apps/cli/test/cli.e2e.test.tsΒΆ
Cut code mode
Delete:ΒΆ
packages/capability/src/catalog.tsΒΆpackages/capability/src/code-mode.tsΒΆpackages/capability/src/sandbox-error.tsΒΆpackages/capability/src/sandbox-service.tsΒΆpackages/capability/src/sandbox-subprocess.tsΒΆpackages/capability/src/to-code-mode.tsΒΆpackages/capability/test/catalog.test.tsΒΆpackages/capability/test/sandbox.test.tsΒΆpackages/capability/test/to-code-mode.test.tsΒΆcodeModeandmcpServer.codeModefromapps/cli/src/surfaces.tsΒΆ- the
catalogcommand and--code-modeflag fromapps/cli/src/command.tsΒΆ - catalog and code-mode cases from
apps/cli/test/cli.e2e.test.tsΒΆ - the
./sandboxand./code-modeexports frompackages/capability/package.jsonΒΆ
Cut HTTP
Delete:ΒΆ
packages/capability/src/to-http-api.ts,packages/capability/src/http-api.ts, and the HTTP adapter testΒΆ- the
./http-apiexport frompackages/capability/package.jsonΒΆ http,routes, andwebServerfromapps/cli/src/surfaces.tsΒΆ- the
openapiandservecommands fromapps/cli/src/command.tsΒΆ apps/cli/test/serve.test.tsΒΆ- the OpenAPI15 case from
apps/cli/test/cli.e2e.test.tsΒΆ
Cut MCP
Delete:ΒΆ
packages/capability/src/to-toolkit.ts,packages/capability/src/toolkit.ts, and the MCP adapter testΒΆpackages/capability/test/mcp-harness.tsΒΆtoolsandmcpServerfromapps/cli/src/surfaces.tsΒΆ- the
mcpcommand fromapps/cli/src/command.tsΒΆ - MCP cases from
apps/cli/test/cli.e2e.test.tsΒΆ - the
./toolkitexport frompackages/capability/package.jsonΒΆ
Code mode21 imports to-toolkit.ts. Cutting MCP therefore cuts code mode too; apply both lists.ΒΆ
Cut XState
This recipe applies only to a clone that has already removed interest and every other lifecycle except file inspection. packages/core/src/interest-machine.ts also depends on XState and @xstate/effect; replacing file inspection alone cannot remove those dependencies. Find every remaining import before removing either package. Keeping a lifecycle means keeping its runtime and actor-watch.ts.ΒΆ
Delete:ΒΆ
packages/core/src/inspect-machine.tsand its testΒΆxstateand@xstate/effectfrompackages/core/package.jsonΒΆ- their
minimumReleaseAgeExcludeentries frompnpm-workspace.yamlΒΆ scripts/oxlint-plugin-xstate-effect.tsΒΆ- its entry in
oxlint.config.tsΒΆ
Then call FileInspector.inspect directly from the capability handler in packages/core/src/inspect-file.ts.ΒΆ
Cut devtools
Delete:ΒΆ
packages/devtoolsΒΆ@rat-stack/devtoolsfromapps/cli/package.jsonΒΆdevtoolsRoutes,devtoolsWebServer,mcpServer.devtools, andmcpServer.devtoolsCodeModefromapps/cli/src/surfaces.tsΒΆ- the
--devtoolsflag fromapps/cli/src/command.tsΒΆ - the devtools cases from
apps/cli/test/serve.test.tsandapps/cli/test/cli.e2e.test.tsΒΆ
In apps/web, swap devtoolsRoutes for contentRoutes in src/dev/backend.ts, point the development condition of #devtools-overlay in apps/web/package.json at ./src/features/shared/no-devtools.tsx, and delete src/dev/devtools, src/dev/client, and src/dev/features. vite dev keeps serving search and read; test/dev-content-routes.test.ts covers that path.ΒΆ
CallWatch, aroundHandlers, invokerFor, and watchActor stay in packages/capability. Devtools supplies CallWatch when the application is assembled. It observes calls without wrapping capability lists; its default does nothing. aroundHandlers remains the explicit policy wrapper over one list. invokerFor calls capabilities for code mode. watchActor lets machines report to devtools without depending on it.ΒΆ
Clean up after each cut
- Remove stale exports from
packages/capability/src/index.tsand any affected package barrel.ΒΆ - Remove stale imports, Layers, commands, and tests found by the compiler. A Layer builds services and supplies their construction dependencies. A service is a named interface for one job.ΒΆ
- Update the package table in
AGENTS.mdso repo law matches the clone.ΒΆ - Refresh the lockfile and format intentional changes:ΒΆ
pnpm install
pnpm fix
pnpm turbo run check test build Let the compiler and checks find every stale reference. Do not silence errors or delete unrelated tests.ΒΆ
Last changed 2026-10-07 in f1a00f2. Source on GitHub. Change log.