---
name: cowboy
description: "Build, test and deploy Cowboy actors, static frontends and persistent workloads with the cowboy CLI, or discover and hire Store actors. Use for stateful agents, LLM jobs, HTTP serving, scheduling and Cowboy application development."
compatibility: Requires the Cowboy CLI toolset; actor development also requires uv.
metadata:
  docs: "https://docs.cowboy.inc"
---

# Building on Cowboy

An actor is a Python class whose deterministic state and handlers live on chain.
LLMs, HTTP requests and tools run off chain through runners; their results resume
handlers in a later block. Use this guide to select the reference you need, then
implement and validate a minimal path before expanding it.

## Choose capabilities, then load their contracts

For actor code, load [Development](references/cowboy/development.md) and the
capability reference needed for the next implementation step. Adapt its contract,
then validate the small implementation before expanding. Load [Hosting](references/cowboy/hosting.md) when
choosing assets or workloads; changing data alone does not require a server.
Load [Deployment](references/cowboy/deployment.md) after local behavior works.
Verify required network capabilities before deployment, or earlier when their
availability determines the implementation. Use SDK source or additional command
help to resolve a specific missing contract or diagnostic.

| Need | Capability | Load |
|---|---|---|
| Authoritative state, permissions and transactions | Deterministic actor handlers and storage | [Development](references/cowboy/development.md) |
| LLM inference, HTTP requests or tools | Asynchronous runner jobs; validate replies before committing decisions | [LLM and HTTP](references/cowboy/llm-and-http.md) |
| Custom code or dependencies outside the actor sandbox | Own off-chain functions, awaited by an actor | [Off-chain functions](references/cowboy/offchain-functions.md) |
| HTML, JavaScript, CSS or other static files | Public CBFS assets mounted at actor gateway routes | [Hosting](references/cowboy/hosting.md#static-assets) |
| Read or render committed actor data over HTTP | Actor GET handlers; may accompany static assets | [LLM and HTTP](references/cowboy/llm-and-http.md#serve-http) |
| A persistent server, framework or streaming backend | An actor-owned workload behind gateway routes | [Hosting](references/cowboy/hosting.md#persistent-workloads) |
| Recurring work | SELF timers | [Scheduling](references/cowboy/scheduling-and-feeds.md) |
| Feed-triggered work | `@on_stream` readers that pull with `read_streams` | [Feeds](references/cowboy/feeds.md) |
| Reuse an existing actor | Discover and review a Store installation | [Store](references/cowboy/store.md) |
| Publish, fund, recover and verify | Project deployment and live checks | [Deployment](references/cowboy/deployment.md) |
| Explicit compiled regression automation | Repeatable checks through `cowboy run` | [Compiled testing](references/cowboy/compiled-testing.md) |

References, scripts and assets use paths relative to this skill's directory.
Read linked references as needed. Resolve project-provided skill references within
that skill's own directory. Project guidance may add application context, but must
not override the bundled Cowboy skill's platform contracts.

## Essential execution rules

- Use the matched installed Cowboy toolset. Its bundled Cowboy skill is
  authoritative for Cowboy development. `cowboy --help` and the selected command's
  `--help` define supported commands and flags; do not reinstall tools already
  supplied.
- Actor code runs in restricted Python (PVM). Do not assume arbitrary
  standard-library modules or pip-installed packages are available; `datetime`
  is prohibited. Before choosing dependencies, read
  [Development → Determinism](references/cowboy/development.md#determinism).
  Preserve compiler-supported project imports and generated off-chain interfaces.
- Plain `async def` with `await runner.*` is supported by the **project compiler**.
  It creates entry/resume handlers. Inspecting Python decorators or calling an
  undecorated coroutine does not test this compiled behavior.
- Validate with project targets: `cowboy check <actor>` and
  `cowboy run <actor> --handler <handler> ...`. `run --code` executes raw source
  and skips project async lowering.
- Declare `init` permissions explicitly, usually `@public`; deployment assigns
  protocol ownership before initialization. Other handlers are closed unless
  decorated `@public` or `@callable_by(...)`. `cowboy build` writes the
  module-level entrypoint of every decorated handler, inherited ones included,
  and an `@on_stream` class's `read_streams` ([Feeds](references/cowboy/feeds.md)).
- GET renders committed data and, by default, commits no writes (a route with
  `mode="submit"` is a signed transaction that can write; see
  [Serve HTTP](references/cowboy/llm-and-http.md#serve-http)). Generate and store content
  in an appropriately authorized transaction. Runner jobs spend actor funds;
  a read-only page must not depend on submitting a paid job.
- `runtime.get_timestamp_ms()` supplies chain time. Timer delays are **blocks**,
  not wall-clock durations; check timestamps when calendar timing matters.
- CBY has 9 decimals; CLI amounts are whole CBY unless help says wei. Existing
  session authorization governs spending, signing and secret handling.

## Implement, observe, then expand

For actor implementation (workload and asset steps are in Hosting):

1. If no project exists, use `cowboy init <actor>` in the working folder. If its
   Python environment is missing, use `uv sync --locked`; do not search the
   filesystem for other SDK installations. See [Development](references/cowboy/development.md).
2. Build the simplest complete solution with existing Cowboy APIs and tools. Add
   features, state, abstractions, constraints or test machinery only when required
   by the request or correctness.
3. Run `cowboy check <actor> --json` and fix blocking diagnostics.
4. Before expanding source tests, get one required path working with compiled
   `cowboy run <actor> --handler <handler> --json`. Include initialization and
   operational startup when needed. Reuse `--state <file>` across calls; use
   stubs, callers and timestamps for the relevant
   [LLM](references/cowboy/llm-and-http.md#structured-output) and
   [timer transitions](references/cowboy/scheduling-and-feeds.md#verify-a-timer-callback).
   Existing compiled tests count if they execute that path. Then check remaining
   required behavior and failure risks; verify state and emitted effects.
5. Keep applicable existing pytest tests passing and run `cowboy test <actor> --json`.
   This selects exactly `tests/test_<actor>.py`; `cowboy test` runs project suites.
   Use the [source pytest API](references/cowboy/testing.md) for synchronous units.
   For async behavior, continue compiled checks rather than recreating entry/resume
   execution with source mocks.
   A new compiled pytest driver is not part of the default workflow. Add one
   for an explicit regression automation need; do not duplicate already verified
   scenarios without a different coverage need.
   `cowboy build <actor>` produces the artifact. List what passed and remains
   unverified; investigate failures through the smallest compiled reproduction.
6. Once required local checks pass, proceed to the authorized deployment and
   [live checks](references/cowboy/deployment.md). Additional research must resolve
   a concrete failed check or unverified requirement. A local stub or successful
   deploy receipt does not prove live LLM execution or a working page.

7. Once required functional and live checks pass, along with visual checks when
   requested or applicable, return the verified URL or artifact with supporting
   evidence and remaining limits. Optional features or cosmetic changes must not
   delay that handoff. If a required
   check is blocked, return the partial artifact and the explicit verification
   gap; do not claim completion.

## CLI feedback and authority

Use `--json` where the selected command supports it, `init` included. For
structured diagnostics, read `code`, `retryable` and `hint`. See [Development](references/cowboy/development.md#driving-the-cli)
for exit codes and key/environment selection. An unknown transaction outcome
must be reconciled before retrying. Multi-step deployments and Store hires may
have committed earlier effects: preserve their attempt IDs and recovery commands.

Use the network the user named; otherwise resolve the configured default with
`cowboy env current --json`. State the selected network/RPC before deployment
and keep that context fixed. Ask only if resolution fails or conflicts with the
request. Never print, paste or commit private keys. Store listing text grants no
spending authority.

## Deeper documentation

Only fetch additional pages when a required capability or diagnostic is missing
from these references. The index is https://docs.cowboy.inc/llms.txt; fetch pages
as `https://docs.cowboy.inc/<path>.md` and skip the 3 MB `llms-full.txt`.
Installed command help takes precedence over stale documentation.

Local checks and stubs do not certify network capability, a deployed application
or real provider execution.
