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

# Agent playbook

> SCHEMA.md, playbook.md, rules.md, and kiwi_context — how agents onboard to a knowledge base.

Every `kiwifs init` template ships agent-facing documents beside your markdown pages. Together they tell agents **where** to write, **what** frontmatter to use, and **which** MCP tools to call.

## Core files

| File                | Purpose                                                        |
| ------------------- | -------------------------------------------------------------- |
| `SCHEMA.md`         | Directory layout, frontmatter field tables, naming conventions |
| `.kiwi/playbook.md` | Step-by-step MCP sequences for each operation                  |
| `.kiwi/rules.md`    | Harness-specific behavior (Cursor, Claude, etc.)               |
| `index.md`          | Auto-maintained table of contents                              |
| `log.md`            | Optional append-only chronological record                      |

<Info>
  The **`knowledge`** template also includes `episodes/` for episodic memory. See [Episodic memory](/concepts/episodic-memory).
</Info>

## Load context in one call

<Tabs>
  <Tab title="MCP">
    ```
    kiwi_context
    ```

    Returns `schema`, `playbook`, and `index` in one response.
  </Tab>

  <Tab title="REST">
    ```bash theme={null}
    curl -s 'http://localhost:3333/api/kiwi/context'
    ```

    ```json theme={null}
    {
      "playbook": "# Playbook\n...",
      "schema": "# Schema\n...",
      "index": "# Index\n..."
    }
    ```
  </Tab>
</Tabs>

MCP also exposes read-only resource **`kiwi://schema`** for the schema document alone.

## Playbook operations

<AccordionGroup>
  <Accordion title="Ingest — process a new source">
    ```
    kiwi_context
    kiwi_search("authentication")
    kiwi_write("pages/auth.md", content)
    kiwi_read("index.md")
    kiwi_write("index.md", updated_index)
    kiwi_append("log.md", "- added auth page")
    ```
  </Accordion>

  <Accordion title="Query — answer a question">
    ```
    kiwi_search("payment timeout")
    kiwi_read("pages/payments.md")
    ```
  </Accordion>

  <Accordion title="Remember — save episodic observations">
    ```
    kiwi_append("episodes/2026-05-21.md", observation)
    ```
  </Accordion>

  <Accordion title="Consolidate — merge episodes into durable pages">
    ```
    kiwi_memory_report
    kiwi_read("episodes/2026-05-21.md")
    kiwi_write("pages/topic.md", merged_content)
    ```
  </Accordion>

  <Accordion title="Lint — audit health">
    ```
    kiwi_analytics
    kiwi_health_check("pages/auth.md")
    kiwi_lint
    ```
  </Accordion>
</AccordionGroup>

## Rules for your harness

Export `.kiwi/rules.md` in a format your agent tool understands:

<CodeGroup>
  ```bash Print rules theme={null}
  kiwifs rules
  ```

  ```bash Export for Cursor theme={null}
  kiwifs rules export --format cursor
  ```

  ```bash Sync to project config theme={null}
  kiwifs rules sync --format cursor --output .cursor/rules/kiwi.md
  ```
</CodeGroup>

REST: `GET /api/kiwi/rules`, `PUT /api/kiwi/rules` — see [Utilities API](/api/utilities#rules-file).

## Provenance on writes

```bash theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/file?path=episodes/run-249.md' \
  -H 'X-Actor: agent:researcher' \
  -H 'X-Provenance: run:run-249' \
  -d '# Session notes...'
```

<Note>
  KiwiFS injects `derived-from` into frontmatter automatically from these headers.
</Note>

## Related documentation

<CardGroup cols={2}>
  <Card title="MCP" icon="plug" href="/concepts/mcp">
    Full tool reference.
  </Card>

  <Card title="Episodic memory" icon="brain" href="/concepts/episodic-memory">
    Episodes, consolidation, and merge reports.
  </Card>

  <Card title="Schemas" icon="shield-check" href="/concepts/schemas">
    JSON Schema validation on writes.
  </Card>

  <Card title="Examples" icon="lightbulb" href="/guides/examples">
    Practical workflow recipes.
  </Card>
</CardGroup>
