# Server pin and credentials

Where `tkt` finds the server and the project, and where your token is.

`tkt token …`, `tkt project llm …`, `tkt project delete`, `tkt login`, `tkt logout` and `tkt feedback …` take `--server` / `--project`, else a `.aitodo.yaml` that says `store: server`, else the store's pin `.aitodo/server.yaml`. They are REST calls from this machine, never forwarded to `/cli`. The token lives in `credentials.yaml` (mode 0600) in the config dir; `tkt where` says which one and why.

## Details

- The config dir (`credentials.yaml`, `last-error.json`), first match wins: `AITODO_CONFIG_DIR=<dir>` (the files directly in it) > `configDir: <path>` in the nearest `.aitodo.yaml` (relative to it; with any pin or alone) > `$XDG_CONFIG_HOME/aitodo/` (`%APPDATA%\aitodo\` on Windows) > `~/.config/aitodo/`. Unlike `XDG_CONFIG_HOME` it leaves other tools (`gh`, `git`) alone. An older `tkt` rejects `configDir`. A triage folder: `configDir: .config`, `.config/` in `.gitignore`.
- `tkt where`: `credentials: <path> (from …)`; `--json`: `credentials`, `credentialsSource`: `env` | `file` | `xdg` | `appdata` | `default`. A dir inside a git work tree that git does not ignore: `Warning: …` at every write and `tkt doctor` `CONFIG_DIR_NOT_IGNORED`; add it to `.gitignore`.
- `--workspace-dir` / `--workspace` pick whose pin is read. Pins go only to a named store (`--workspace-dir`, `AITODO_WORKSPACE_DIR`, `--workspace` / `AITODO_WORKSPACE`, `.aitodo.yaml`). Outside a store, or with `store: server`, register writes no pin (never the implicit `~/.aitodo/default`): `No server pin written: …`, next step `tkt store init --server <url> --project <id>`; `--json`: `pin: null`, `pinSkipped: no-store | server-store` (`pinSkipped: null` when it pinned).

## Related

- Env var: [`AITODO_CONFIG_DIR`](/en/docs/reference/env.md#AITODO_CONFIG_DIR): Where credentials.yaml lives; beats configDir in .aitodo.yaml, XDG\_CONFIG\_HOME and APPDATA
- Doctor · warning: [`CONFIG_DIR_NOT_IGNORED`](/en/docs/reference/doctor.md#doctor-CONFIG_DIR_NOT_IGNORED): A credentials directory inside a repo that git does not ignore
