> ## 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.

# Examples

> Practical workflows for agents, DQL, import/export, and deployment.

## LLM wiki pattern

```bash theme={null}
kiwifs init --template knowledge --root ./knowledge
```

```text Directory structure theme={null}
knowledge/
├── SCHEMA.md
├── index.md
├── log.md
├── pages/
├── episodes/
└── .kiwi/playbook.md
```

Call **`kiwi_context`** on connect, then follow playbook operations.

See [Agent playbook](/concepts/agent-playbook).

## Agent writes

<AccordionGroup>
  <Accordion title="REST — single file">
    ```bash theme={null}
    curl -X PUT 'http://localhost:3333/api/kiwi/file?path=pages/auth.md' \
      -H 'X-Actor: my-agent' \
      -H 'X-Provenance: run:run-249' \
      -d '# Authentication

    OAuth2 + JWT.'
    ```
  </Accordion>

  <Accordion title="REST — bulk write (one commit)">
    ```bash theme={null}
    curl -X POST 'http://localhost:3333/api/kiwi/bulk' \
      -H 'Content-Type: application/json' \
      -d '{
        "files": [
          {"path": "pages/auth.md", "content": "# Auth\n\nUpdated."},
          {"path": "log.md", "content": "- 2026-05-21: updated auth"}
        ],
        "actor": "agent:exec_abc",
        "message": "run 249"
      }'
    ```
  </Accordion>

  <Accordion title="Filesystem mount">
    ```bash theme={null}
    echo "# Finding" > /mnt/kiwi/pages/finding-042.md
    ```
  </Accordion>

  <Accordion title="Query provenance">
    ```bash theme={null}
    curl 'http://localhost:3333/api/kiwi/meta?where=$.derived-from[*].id=run-249'
    ```
  </Accordion>
</AccordionGroup>

## MCP tool sequences

<AccordionGroup>
  <Accordion title="First connection">
    ```
    kiwi_context
    ```
  </Accordion>

  <Accordion title="Ingest a source">
    ```
    kiwi_search("authentication")
    kiwi_write("pages/auth.md", content)
    kiwi_read("index.md")
    kiwi_write("index.md", updated)
    kiwi_append("log.md", "- added auth")
    ```
  </Accordion>

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

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

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

    See [Episodic memory](/concepts/episodic-memory).
  </Accordion>

  <Accordion title="Health check">
    ```
    kiwi_analytics
    kiwi_health_check("pages/auth.md")
    kiwi_lint
    ```
  </Accordion>
</AccordionGroup>

## DQL

<CodeGroup>
  ```bash Table query theme={null}
  kiwifs query 'TABLE title, status FROM "pages" WHERE status = "draft" SORT priority DESC'
  ```

  ```bash Count by group theme={null}
  kiwifs query 'COUNT FROM "pages" GROUP BY status'
  ```

  ```bash REST theme={null}
  curl 'http://localhost:3333/api/kiwi/query?q=TABLE%20title%20FROM%20%22pages%22'
  ```
</CodeGroup>

## Aggregation

```bash theme={null}
kiwifs aggregate --group status --calc count,avg:priority
```

## Import

<CodeGroup>
  ```bash From PostgreSQL theme={null}
  kiwifs import --from postgres --dsn "postgres://..." --table users --root ./knowledge
  ```

  ```bash From Obsidian theme={null}
  kiwifs import --from obsidian --path ~/vault --root ./knowledge
  ```

  ```bash Dry run theme={null}
  kiwifs import --from csv --path data.csv --root ./knowledge --dry-run
  ```
</CodeGroup>

## Export

<CodeGroup>
  ```bash JSONL with content theme={null}
  kiwifs export --format jsonl --include-content -o knowledge.jsonl
  ```

  ```bash With embeddings theme={null}
  kiwifs export --format jsonl --include-embeddings -o vectors.jsonl
  ```

  ```bash Document render (PDF) theme={null}
  curl -X POST 'http://localhost:3333/api/kiwi/export/document' \
    -H 'Content-Type: application/json' \
    -d '{"format":"pdf","path":"pages/report.md"}' -o report.pdf
  ```
</CodeGroup>

See [Document export](/export/documents).

## Production config

```toml .kiwi/config.toml theme={null}
[server]
public_url = "https://wiki.example.com"

[search]
engine = "sqlite"

[search.vector]
enabled = true

[search.vector.embedder]
provider = "ollama"
model = "nomic-embed-text"

[versioning]
strategy = "git"

[backup]
remote = "git@github.com:org/knowledge.git"
interval = "5m"
```

## Docker

```bash theme={null}
docker run -d --restart always \
  -v /data/knowledge:/data \
  -p 3333:3333 \
  ameliaanhlam/kiwifs serve --root /data
```

## Go embed

```go theme={null}
import "github.com/kiwifs/kiwifs/pkg/kiwi"

srv, err := kiwi.New("/data/knowledge", kiwi.WithSearch("sqlite"))
mux.Handle("/wiki/", http.StripPrefix("/wiki", srv.Handler()))
```

See [Go embed](/deploy/go-embed) and [Alternate protocols](/guides/alternate-protocols).
