# The store

The first match wins: `--workspace-dir` > `AITODO_WORKSPACE_DIR` > the nearest `.aitodo.yaml` (cwd, then parents) > `~/.aitodo/<name>`.

Unexpected store? Run `tkt where`: an exported `AITODO_WORKSPACE_DIR` beats `.aitodo.yaml`.

- `--workspace-dir` and `AITODO_WORKSPACE_DIR` are the store root itself: no name is appended.
- `store: server` in `.aitodo.yaml`: the store lives on the team server, and the repo holds only that file ([A store on the server](/en/docs/guides/team/server-store.md#team-server-store)).
- Commit `.aitodo.yaml` and the store. `.aitodo/.gitignore` keeps the local state out; `tkt doctor` warns `STATE_FILE_NOT_IGNORED` or `STATE_FILE_TRACKED` when git sees it anyway.

## Details

- A stale `.envrc` often exports `AITODO_WORKSPACE_DIR`. The name counts only under the `~/.aitodo` default: `--workspace`/`-w` > `AITODO_WORKSPACE` > `.aitodo.yaml` `workspace` > `default`. The REST API resolves the same way from the server's cwd.
- **`.aitodo.yaml` keys:** `workspaceDir` (relative to the **file's** directory; `~` expanded), `workspace` (alone it selects `~/.aitodo/<workspace>`), `configDir` (where the credentials file lives, [Server pin and credentials](/en/docs/guides/team/credentials.md#team-pin)), or `store: server` with `server` and `project`. No other key. The nearest file wins; files are never merged. A broken file (bad YAML, unknown key) is `ERR_FILE_PARSE` naming the file, never silently skipped.
- **Local state:** `.aitodo/.gitignore` keeps out `index.db`, `leases.json`, `*.lock` (the locks beside `counters.json` and `leases.json`, `claim.lock`), `decompositions/` and `cache/`. A store made by an older `tkt` gets the missing lines on its next write; its own lines stay. `STATE_FILE_NOT_IGNORED`: git does not ignore such a file; `STATE_FILE_TRACKED`: git already tracks one (hint: `git -C <repo> rm --cached <path>`, a directory: `git rm -r --cached`, plus the missing line). Never commit a `.lock` file. Outside git, and for a `store: server` store, this is not checked.
- **Layout:** `.aitodo/` (`config.yaml`, `counters.json`, `.gitignore`, the derived `index.db`, the `templates/` overlay), `tickets/`, `groups/<id>/_group.md`, `docs/`, `gotchas/`, `decisions/`, `milestones/`.

## Related

- Guide: [A store on the server](/en/docs/guides/team/server-store.md): A project's store can live on the server instead of the repo; the repo then holds only .aitodo.yaml (store: server, server, project).
- Guide: [Server pin and credentials](/en/docs/guides/team/credentials.md): Where tkt finds the server and the project, and where your token is.
- Env var: [`AITODO_WORKSPACE_DIR`](/en/docs/reference/env.md#AITODO_WORKSPACE_DIR): The store directory; beats .aitodo.yaml (--workspace-dir)
- Env var: [`AITODO_WORKSPACE`](/en/docs/reference/env.md#AITODO_WORKSPACE): A store by name under ~/.aitodo/\<name\> (--workspace)
- Doctor · warning: [`STATE_FILE_NOT_IGNORED`](/en/docs/reference/doctor.md#doctor-STATE_FILE_NOT_IGNORED): A local state file in .aitodo/ (index, leases, locks, decompositions, cache) that git does not ignore
- Doctor · warning: [`STATE_FILE_TRACKED`](/en/docs/reference/doctor.md#doctor-STATE_FILE_TRACKED): A local state file git already tracks: git rm --cached it
