add-a-capability
Installation
SKILL.md
Add a capability
A capability is one named action with a contract and a server-side handler. The contract defines its name, input, output, failure, and metadata. The handler implements the action.
Define the shared contract once. Implement its handler where the data and infrastructure live. Do not write separate business logic for each interface.
Effect describes work with typed failures and required dependencies. Schema defines accepted values and their runtime checks. A service is a named interface for one job. A Layer builds services and supplies their construction dependencies.
1. Define the contract
Put cross-process contracts in packages/core/src/contracts.ts and import defineContract from @rat-stack/capability/contract.
- Define the input, output, and expected failure schemas.
- Give the contract a stable name and short description.
- Use
Schema.Structfor the input. - Set honest annotations such as
readOnly,idempotent,destructive, andopenWorld. - Set
needsApproval: truewhen the action needs approval.implementadds theApprovalrequirement andApprovalDeniedfailure; the handler itself declares only the contract's failures.