CLI and agents
Project setup
Set up TolkBot in your project with the init command: interactively at a terminal, and without prompts in CI and agent sandboxes.
Initialize your project
Run the init command in the directory your app lives in: the repository root for a single app, the app's own directory in a monorepo:
tolkbot init
The wizard will:
- Detect your project type (Next.js, React, Vue, Expo, etc.)
- Detect your i18n framework (next-intl, react-i18next, vue-i18n, etc.)
- Locate existing locale files and infer the directory structure
- Determine your base language (defaults to
enif found) - Link the TolkBot project for this directory, or create one, which reads the repository on GitHub to find the file pattern for your locale files
- Create a
tolkbot.jsonconfiguration file in the project's directory - Offer to add instructions for coding agents to your
AGENTS.mdorCLAUDE.md
Finding the file pattern takes a few seconds, and up to a minute or two in a large repository. init waits for it. If TolkBot finds no locale files, init exits 1 and prints a link to the project's settings, where you set the pattern by hand; then run tolkbot init again.
Overwrite existing config
If you already have a tolkbot.json and want to re-initialize:
tolkbot init --force
Run beside an existing tolkbot.json, --force links the project that file names again and rewrites it in place, which is how you refresh its file pattern after changing it in the dashboard.
In a monorepo
A repository can hold one TolkBot project per app, each with its own directory (its subpath) and file pattern. init picks the project from the directory you run it in:
- Inside an app's directory, or anywhere below it, it links the project whose directory holds yours.
- With no project there, it creates one for the directory you are in.
- Where several projects sit below you, such as at the root of a repository with
apps/webandapps/docs, it asks which one at a terminal. Without a terminal, or with--yes, it exits2with the codeambiguous_projectand lists them.
--project <slug> picks one by its slug instead, wherever you run it:
tolkbot init --yes --project web
$ cd my-monorepo && tolkbot init --yes < /dev/null
{
"error": {
"code": "ambiguous_project",
"message": "This directory holds 2 TolkBot projects: docs (apps/docs), web (apps/web).",
"hint": "Run 'tolkbot init' in the app's directory, or pass --project <slug>."
}
}
A repository path belongs to one organization at a time. When another organization manages the directory, init exits 1 with repository_path_claimed; when an archived project of yours still holds it, with repository_path_in_use and a link to that project.
Without prompts
In CI, a container or an agent sandbox there is no terminal to ask questions in, so init accepts everything detection found and prints the result as JSON. At a terminal, --yes does the same without the wizard:
tolkbot init --yes
Override any individual guess:
tolkbot init --yes \
--base en \
--targets nb,es,pt-BR \
--framework next-intl
Every option is under init on the Commands page.
The interactive wizard offers to install an i18n library when it doesn't find one. Non-interactively that would mutate your lockfile and scaffold source files as a side effect of what reads like a config command, so it only happens if you ask for it.
init needs a TolkBot account. Without a login it exits 3 before it does anything, and says how to log in:
$ tolkbot init < /dev/null
{
"error": {
"code": "not_authenticated",
"message": "tolkbot init needs a TolkBot account, and this machine is not logged in.",
"hint": "Run 'tolkbot auth login', which opens tolkbot.ai in a browser to sign in with GitHub, or set $TOLKBOT_TOKEN in CI. ..."
}
}
Machine-readable output
tolkbot init --json
{
"projectId": "k57a...",
"project": "web",
"repositoryId": "j93b...",
"repository": "acme/app",
"framework": "next-intl",
"subpath": "apps/web",
"sourcePattern": "messages/{locale}.json",
"config": "/home/me/acme/app/apps/web/tolkbot.json",
"baseLocale": "en",
"targets": ["nb", "es"],
"createdProject": true,
"installed": false,
"agentsFile": null
}
project is the project's slug, the value --project takes, and config is the tolkbot.json init wrote. createdProject is false when init linked to a project that already existed for the repository. agentsFile says where the agent instructions went, with --agents-file. sourcePattern, baseLocale and targets are the project's settings after detection, which may fill in what you left out. A failure prints the error shape on stderr and exits with its code.
Prerequisites
Non-interactive or not, init needs two things it can't do for you:
- A GitHub remote on the repository (
git remote get-url origin) - The TolkBot GitHub App installed with access to that repository
Both failures name the missing step.
Languages
init takes the target languages it finds in the repository. A repository with only a base file has none, so add them from the terminal:
tolkbot languages add nb de
Each language is added to the project and set up the same way as with Add language in the dashboard (see Adding a language). --existing says what happens to translations the repository already has for it:
| Option | Description |
|---|---|
--existing trust | Keep them as written by a person, so TolkBot does not translate them again unless asked. The default |
--existing review | Keep them in the files and flag each one for you to confirm on the Translations page |
--json | Output the result as JSON (the default without a terminal) |
languages add changes the project only. It prints the next step: tolkbot translate --dst nb fills the files now, and with automated pull requests on, the next push that changes the base file opens a pull request.
Codes are the ones on Supported languages, in any spelling (pt-BR, pt_BR). A language already on the project changes nothing and exits 0. An unsupported code exits 2 with the code unsupported_locale and names the closest supported codes. If setting up a language fails, the command prints what it did and exits 1; running it again retries.
{
"project": { "name": "Web", "slug": "web" },
"existing": "trust",
"changed": true,
"languages": [
{ "locale": "nb", "outcome": "added" },
{ "locale": "de", "outcome": "unchanged", "setup": "set-up" }
],
"targetLanguages": ["de", "nb"],
"next": {
"translate": ["tolkbot translate --dst nb"],
"pullRequestOnPush": true
}
}
outcome is added, set_up (it was on the project but not set up), unchanged or failed (with error). Removing a language is done in the dashboard's project settings.
List them
tolkbot languages list
Prints the base language and each target language, whether it is set up, and the files the project's pattern maps it to in this working tree, marked when the file does not exist yet.
Configuration file
init writes tolkbot.json in the project's directory: the repository root, or the app's directory in a monorepo. Every command looks for it in the directory it runs in and then in each parent, so commands run anywhere inside the app find it.
{
"projectId": "your-project-id",
"framework": "next-intl",
"subpath": "apps/web",
"sourcePattern": "messages/{locale}.json"
}
Fields
| Field | Description |
|---|---|
projectId | Your project ID from the TolkBot dashboard (required) |
framework | The i18n framework your project uses (required) |
subpath | The project's directory in the repository, "" at the root |
sourcePattern | The project's file pattern, relative to subpath, as it was when init last ran |
subpath and sourcePattern pin the files the project reads, so tolkbot validate checks exactly those files, with no login and no network, and ignores fixtures, examples and other apps' files. The project's settings stay the source of truth: translate and the other commands that talk to TolkBot read the pattern from the project, and print one warning line when it differs from the file, naming tolkbot init --force to refresh it. A tolkbot.json from before these fields still works; validate then scans the directory for locale files, and says to run tolkbot init --force to pin the pattern.
Supported framework values
| Value | Framework |
|---|---|
next-intl | Next.js with next-intl |
react-i18next | React with react-i18next |
i18next | i18next (vanilla) |
expo | Expo / React Native |
vue-i18n | Vue.js with vue-i18n |
custom | Custom setup |
Auto-detection
TolkBot automatically detects your project setup by examining:
- Package manager — npm, yarn, or pnpm
- Framework dependencies in
package.json - Existing i18n configuration files
- Locale file locations in common directories (
locales/,messages/,public/locales/,i18n/)
Detected locale patterns
| Framework | Default pattern |
|---|---|
| next-intl | messages/{locale}.json |
| react-i18next | public/locales/{locale}/common.json |
| i18next | locales/{locale}.json |
| expo | locales/{locale}.json |
| vue-i18n | locales/{locale}.json |
| custom | locales/{locale}.json |
What's next
- Add a language with
tolkbot languages add - Start translating with
tolkbot translate - Validate your setup with
tolkbot validate