Capabilities

What it does

A capability is one named action with a contract and a server-side handler. The contract declares the name, input, output, failure, and metadata. The handler implements the action on the server.

Effect is a library for describing work with typed failures36 and required services. A service is a named interface for one job. Schema describes accepted values, their TypeScript types, and the rules for checking and converting them at runtime.

defineContract declares input, output, and failure with Effect Schema. It sets metadata describing the action, such as whether it is read-only, and any approval requirements. implement connects the contract to one handler.

A projection builds a callable interface from a capability. The projections in packages/capability provide:

ratstack.sh serves seven: search, read, backlinks, neighbors, mentions, path, and execute. The registry lives in apps/site/src/capabilities/index.ts. The local command line projects the core registry in apps/cli/src/surfaces.ts.

The standard

Code-mode discovery and execution

Code mode derives tool declarations from capability schemas. The default discovery budget is 2,000 estimated tokens. The estimate uses four characters per token.

Discovery selects the shortest declarations and gives each namespace a turn. Namespace summaries mark the selected tools as COMPLETE or PARTIAL.

catalogBudget sets the budget. declarations: "inline" includes all declarations; "search" includes none. An explicit catalogBudget takes precedence over either setting. The declarations resource always contains the full catalog.

Programs can call tools.$codemode.search to find declarations. An exact tool path returns only that tool. Other queries rank path segments, path substrings, descriptions, then input fields.

limit and offset bound each page. next holds the next offset; remaining counts matching tools after this page. total keeps its meaning as the full catalog size.

Execution returns result, logs, diagnostic, toolCalls, and truncated. Check diagnostic before using result. A declared tool failure retains its tag and a safe message. Parse errors, invalid data, timeouts, and program failures also return diagnostics.

Host cancellation still interrupts execution.

The HTTP execute response uses status 200 for execution diagnostics. Failure diagnostics have a null result. Consumers that parsed SandboxError bodies must read diagnostic instead. A health check must reject a non-null result when it expects failure.

toolCalls lists admitted calls in dispatch order, including failed calls. maxToolCalls rejects extra calls before their handlers run. Both sandbox adapters run at most eight tool calls at once. maxOutputBytes bounds returned JSON and log content by UTF-8 bytes.

Output cuts set truncated and keep the diagnostic and call history. The budget excludes diagnostic, call-history, and transport-envelope bytes. Both limits are optional; zero is a valid limit.

Handlers keep the services captured when the program starts. Devtools records each handler’s duration and outcome through the existing CallWatch. A downstream storage adapter owns its statement and row limits.

How to check

Removing an interface

The README’s Keep or cut table lists the files for “No HTTP”, “No MCP”, and “No code mode.” Cutting MCP cuts code mode, because code mode is built on the MCP toolkit.

Sources

  1. rat-stack/packages/capability/src/contract.ts at main · joelhooks/rat-stack · GitHub. GitHub joelhooks/rat-stack. Contract definition; used for schemas, annotations, and approval settings. Accessed 2026-10-01.
  2. rat-stack/packages/capability/src/implement.ts at main · joelhooks/rat-stack · GitHub. GitHub joelhooks/rat-stack. Handler binding; used for schema validation and declared failures. Accessed 2026-10-01.
  3. rat-stack/apps/site/src/capabilities/index.ts at main · joelhooks/rat-stack · GitHub. GitHub joelhooks/rat-stack. Hosted registry; used to identify the capabilities served by ratstack.sh. Accessed 2026-10-01.
  4. rat-stack/apps/cli/src/surfaces.ts at main · joelhooks/rat-stack · GitHub. GitHub joelhooks/rat-stack. CLI composition; used to show the local projections. Accessed 2026-10-01.
  5. rat-stack/packages/capability/test at main · joelhooks/rat-stack · GitHub. GitHub joelhooks/rat-stack. Projection tests; used to check validation, approvals, and sandbox calls. Accessed 2026-10-01.

Last changed 2026-10-10 in 978dccc. Source on GitHub. Change log.

Linked from

  1. A clean playground. rat-stack does real work with packages that stay easy to add and remove.

    The website’s search and read capabilities, named actions with shared contracts and handlers, serve the public repo.

  2. add-a-capability. Learn how one contract and its handler become a command, HTTP route, MCP tool, browser RPC, and sandbox call.

    Add the implementation to the capabilities tuple consumed by its composition root.

  3. Agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.

    Capabilities — Named application actions exposed through generated interfaces share one definition and one server-side implementation.

  4. Agent rules for rat-stack (AGENTS.md). What you may change, which commands to run, and which changes need approval.

    Define schemas and metadata with defineContract; bind a server-side handler with implement and add the capability to capabilities.

  5. An MCP your users want. Rhys Sullivan's practical guide gives rat-stack a checklist for useful MCP tools.
  6. Build and run rat-stack (README.md). What is in the repo, how the example works, and how to run it.

    Add another to capabilities, then verify every projection you keep; CLI command registration lives in apps/cli/src/command.ts.

  7. Change log. What changed in the files served here, newest first.

    Capabilities — edited: docs: point live docs, skills and Brain pages at apps/site

  8. Effect + Alchemy peer patterns. Source-grounded patterns from repos on nearby Effect and Alchemy pins.
    Link context

    Capability fence: test or lint that every surface, including toRpc, originates from the capability registry; make the test prove its guarded paths exist and contain files.

  9. Feature flags. Typed feature flags with owners, removal dates, and stable subject rollouts.

    Each capability shares its contract across surfaces.

  10. Full agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
  11. learn. Present Effect, Alchemy, XState, and application-design concepts during real work when the operator enables learn mode. Use for adaptive explanations and local learning progress.

    Confirm storage only after the capability returns a feedback id.¶

  12. learn-rat-stack. Trace a capability through Effect, XState, five projections, the CLI, and Alchemy. Try hosted search and read.

    Start with inspectFile, a capability: one named action with a contract and a server-side handler.

  13. One capability, every surface. A schema-typed contract and one handler feed every interface rat-stack keeps.

    Register it in capabilities, then check each interface you keep.

  14. One schema, three surfaces. A capability contract feeds CLI, HTTP, and MCP; OpenAPI is generated output, not their input.

    A capability contract owns Effect schemas.¶

  15. Property-based testing. State a rule that must hold for every input, then let a generator hunt for the smallest input that breaks it.

    The same schema defines the capability’s contract and generates its test inputs.

  16. Rat Stack lore | rat-stack. Short, source-grounded notes on the ideas and decisions behind rat-stack.

    One schema, three surfaces — A capability contract feeds CLI, HTTP, and MCP; OpenAPI is generated output, not their input.

  17. Rat Stack systems | rat-stack. The systems rat-stack ships, the standard each keeps, and how to check it.

    Capabilities — Named application actions exposed through generated interfaces share one definition and one server-side implementation.

  18. rat-stack. An Effect stack so pure (aspirational) Kit Langton will blush.
  19. Run Effect at the integration boundary. Build the runtime where a calling framework enters, reuse its services, and dispose it when that integration ends.

    A new runner does not authorize a handler that skips the capability contract.¶

  20. Schemas define the boundary. Define accepted data with Schema, decode unknown input before dispatch, and encode results through the declared contract.

    In rat-stack, one capability contract supplies schemas to every interface projection.¶

  21. Source change history (log.md). The generated change log as Markdown.

    Capabilities — edited: docs: point live docs, skills and Brain pages at apps/site

Unlinked mentions (45)