> ## Documentation Index
> Fetch the complete documentation index at: https://app.keystroke.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Docs for agents

> How your agent reads the Keystroke docs while it builds.

The Keystroke documentation is the source of truth for APIs, patterns, and examples — and your agent can search and read it as it works, with no setup. Prefer what the docs return over prior knowledge.

Docs access comes in two forms that mirror the two ways to build: the **CLI** for local work, and the **MCP server** for chat-first agents. Both are read-only and reach the same documentation.

## From the CLI

The CLI ships two documentation commands. They need **no authentication and no project** — they work the moment the CLI is installed.

```bash theme={null}
keystroke docs search "webhook trigger"        # find pages by topic
keystroke docs query "cat /quickstart.mdx"     # read a page by path
```

| Command                            | Use for                                                                                                                                       |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `keystroke docs search "<query>"`  | Broad or conceptual lookups when you don't know the path. Returns matching pages with titles and paths.                                       |
| `keystroke docs query "<command>"` | Exact keyword/regex search, structure exploration, and reading a page by path with a shell-style command (`cat`, `rg`, `ls`, `tree`, `head`). |

Pass a path returned by `search` (with its `.mdx` extension) to `query` to read it: `keystroke docs query "cat /learn/agents/build-agents.mdx"`.

## From the MCP server

[MCP clients](/build-with-ai/mcp-for-agents) get the same two capabilities as tools, always available once connected:

| Tool          | Use for                                                                           |
| ------------- | --------------------------------------------------------------------------------- |
| `search_docs` | Broad or conceptual lookups; returns matching pages and their paths.              |
| `query_docs`  | Exact keyword/regex search and reading pages by path against the docs filesystem. |

## By URL

When an agent works over plain HTTP fetch instead of the CLI or MCP, the docs are still reachable as clean markdown:

* **A single page** — append `.md` to any docs URL to get a markdown version, e.g. `https://keystroke.ai/docs/quickstart.md`.
* **The whole index** — `https://keystroke.ai/docs/llms.txt` is a machine-readable map of every page, handy for pointing an agent at the full docs at once.

## How query works

`query` (and `query_docs`) run against a virtualized, read-only documentation filesystem rooted at `/` — not a shell on any machine. A few things to know:

* **Stateless** — each call resets the working directory to `/`. Use absolute paths, or chain with `&&`.
* **Output is capped** (\~30KB per call). Prefer a targeted `rg -C 3 "term" /path.mdx` or `head -n 120 /path.mdx` over `cat` on large pages, and batch several files into one read.
* Convert a filesystem path to a docs URL by dropping the `.mdx` extension (`/quickstart.mdx` → `/quickstart`).

```bash theme={null}
keystroke docs query "tree / -L 2"                   # see the top-level layout
keystroke docs query "rg -il 'defineWorkflow' /"     # find pages mentioning a symbol
keystroke docs query "head -n 200 /cli.mdx"          # read the top of a page
```

## Baseline context: AGENTS.md

`keystroke init` scaffolds an `AGENTS.md` guide (symlinked to `CLAUDE.md`) with concise baseline context — the CLI, project layout, discovery, and working habits — that most coding agents read automatically. The CLI keeps `AGENTS.md` in sync with your installed version whenever you run a command in the project. `AGENTS.md` orients your agent; the docs commands above are how it goes deeper.

## Next steps

<CardGroup cols={2}>
  <Card title="CLI for agents" href="/build-with-ai/cli-for-agents">
    Headless behavior, JSON output, and the deploy-first loop.
  </Card>

  <Card title="MCP for agents" href="/build-with-ai/mcp-for-agents">
    Build from any MCP client in a hosted workspace.
  </Card>

  <Card title="Build agents" href="/learn/agents/build-agents">
    Author agents, configure models, and add tools.
  </Card>

  <Card title="CLI reference" href="/cli">
    Every command, flag, and the local-vs-cloud target model.
  </Card>
</CardGroup>
