> For the complete documentation index, see [llms.txt](https://docs.raidrobotics.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.raidrobotics.org/commands-v3-state-machine/reference/maintaining-these-docs.md).

# Maintaining these docs

These docs live in the `docs/` folder of the [robot template repository](https://github.com/Team4469/Robot_FSM_Template-Commandv3), next to the code they describe. They're published to the team's GitBook site, RAID Docs, the same way the RAIDParts docs are.

## How publishing works

```mermaid
flowchart LR
    A[docs/ in this repo] -- push to main --> B[GitHub Action<br/>mirror-docs.yml]
    B -- rsync --> C[Team4469/RAID_Docs<br/>commands-v3-state-machine/]
    C -- Git Sync --> D[RAID Docs on GitBook]
```

1. A push to `main` that changes anything under `docs/` runs the **Mirror docs to RAID Docs** workflow (`.github/workflows/mirror-docs.yml`). You can also run it by hand from the repository's **Actions** tab.
2. The workflow copies `docs/` into the `commands-v3-state-machine/` folder of the `Team4469/RAID_Docs` repository and pushes.
3. GitBook's Git Sync picks up the change and publishes it.

{% hint style="warning" %}
The mirror is **one way**. This repository is the source of truth: anything in `commands-v3-state-machine/` that isn't in `docs/` is deleted on the next sync, **including edits made in the GitBook editor**. Always edit the files here.
{% endhint %}

## Editing a page

* Each page is a Markdown file. GitBook blocks (hints, steppers, tabs, expandable sections) use `{% ... %}` tags; copy an existing page to see how.
* Diagrams are Mermaid code blocks: a fenced code block whose language is `mermaid`. GitBook draws them.
* Link to other pages with relative paths (`../guide/vision.md`). Link to source files with full GitHub URLs, because the docs are published away from the code.

## Adding a page

1. Create the `.md` file in the right section folder.
2. Add it to `SUMMARY.md`. A page that isn't in `SUMMARY.md` doesn't show up in the sidebar.

## Keeping the docs in step with the code

The code's header comments are the first place to document something. These docs follow them. When you change the code in a way that changes how someone would use it (a new state, a new button, a renamed file, a new log entry), update the matching page in the same pull request:

| If you change...          | Update                                                                                                                                                                                                    |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The state machine         | [The superstructure state machine](https://docs.raidrobotics.org/commands-v3-state-machine/guide/superstructure.md)                                                                                       |
| A button                  | [Driver controls](https://docs.raidrobotics.org/commands-v3-state-machine/guide/teleop.md), [Controls](https://docs.raidrobotics.org/commands-v3-state-machine/reference/controls.md)                     |
| A logged value            | [Log entries](https://docs.raidrobotics.org/commands-v3-state-machine/reference/log-entries.md)                                                                                                           |
| A file's name or location | [File map](https://docs.raidrobotics.org/commands-v3-state-machine/reference/file-map.md), [Tour of the project](https://docs.raidrobotics.org/commands-v3-state-machine/getting-started/project-tour.md) |

## One-time setup

The sync needs three things. If you're setting up a new copy of this template, or the sync isn't running:

1. **A `RAID_DOCS_TOKEN` secret** in this repository (**Settings › Secrets and variables › Actions**): a token with write access to `Team4469/RAID_Docs`. It can be the same token the RAIDParts repository uses.
2. **A section in RAID Docs' `gitbook-docs.yaml`** whose space reads from the `commands-v3-state-machine` folder. It's the **Commands V3 State Machine** section (`section-12`), inside the **Controls Docs** group:

   ```yaml
   - type: section
     key: section-12
     title: Commands V3 State Machine
     path: commands-v3-state-machine
     children:
       - type: space
         key: space-12
         title: Commands V3 State Machine
         path: commands-v3-state-machine
         default: true
         content:
           directory: ./commands-v3-state-machine
   ```

   The folder name must match `TARGET_DIR` in `.github/workflows/mirror-docs.yml`.
3. **`.gitbook.yaml`** at the root of this repository, which tells GitBook the docs start in `docs/`. It's already there.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.raidrobotics.org/commands-v3-state-machine/reference/maintaining-these-docs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
