# Set up a project

Once, in the repo root; the store is a subdirectory that the `.aitodo.yaml` pin points to.

```console
$ tkt init myproject --workspace-dir .tickets --pin
$ tkt group new "Payments" --kind project --prefix PAY --description "Card payments"
$ tkt ticket new "Partial refunds" -g payments --type feature --description "Refund part of a payment" --details "Finance refunds a partial amount." --ac "Part of a payment is refunded"
```

## Details

Never use the repo root as the store (it creates `tickets/`, `groups/`, `docs/`, `gotchas/` at its root). Then fill in the group descriptor (`## Overview`, conventions, verification): every ticket inherits it ([Docs and gotchas](/en/docs/concepts/docs-gotchas.md#context-docs)). Read: `tkt ticket get PAY-001`.

- `tkt init [name] [--workspace-dir PATH] [--pin [--force]]` is idempotent: when the store exists it says so and exits 0 (`--pin` still runs). Without `--workspace-dir` it initializes the resolved root. It creates `.aitodo/` (`config.yaml`, `counters.json`, `.gitignore`, `templates/`) and `tickets/`, `groups/`, `docs/`, `gotchas/`. `--pin` writes `./.aitodo.yaml` (a relative path under the cwd; `workspace:` only with a name); a different existing file is refused without `--force` (`ERR_ID_DUPLICATE`).
- `tkt group new <name> --kind project|component --prefix PREFIX [--id ID] [--repo R --branch B --base-ref B]`: the prefix is at most 10 upper-case letters or digits, starting with a letter; the default id is the name lower-cased with spaces as hyphens (punctuation stays: pass `--id`, else `ERR_ID_INVALID`). A group's first anchor needs `--repo`.
- The setup script beside the skill: `scripts/init-project-store.sh PREFIX "Project name" [repo-url] [store-dir]`, run from the project root. It runs `tkt init` and `tkt group new` (with a repo URL also the `repoAnchor`, branch `main`), seeds the four body sections with TODOs and prints the `export AITODO_WORKSPACE_DIR=…` line. Idempotent; without a repo URL it prints the `tkt group edit <id> --repo <url> --branch main --base-ref main` to run.

- `tkt where [--json]`: the root, the name, which source won and whether it is initialized: `{root, workspace, source, projectFile, initialized}`, `source` is `flag`, `env`, `file <path>` or `default`; it also names the credentials file (`credentials`, `credentialsSource`).
- A local store pinned to a coordinator (`.aitodo/server.yaml`) gets a `coordinator: <url> (project <id>) serves ids, leases` line: ids and leases come from the server, everything else is local; under `tkt --offline` or `AITODO_OFFLINE=1` it adds `offline: this call uses the local counters`. `--json`: `coordinator` `{url, project, serves, offline, pinFile}`, `null` without a pin. It reads the pin only, never the server. This is not the `store: server` mode (there the whole store is on the server and `tkt where` says `store: server`).

## Commands on this page

- [`tkt init`](/en/docs/reference/commands/setup.md#tkt-init): Initialize a new workspace on disk (optionally pinned to the current directory)
- [`tkt where`](/en/docs/reference/commands/setup.md#tkt-where): Show which workspace root the commands use here, and which source won
- [`tkt group new`](/en/docs/reference/commands/setup.md#tkt-group-new): Create a new group (optionally with a repoAnchor)

## Related

- Concept: [Docs and gotchas](/en/docs/concepts/docs-gotchas.md): The store's docs and gotchas (doc://\<id\>, gotcha://\<id\>) are edited in place, never with sed: every byte outside the edited part stays.
