CLI Reference
Usage
koto [command] [options]If no command is provided, koto translate runs by default.
Commands
koto init
Interactive setup wizard. Auto-detects your framework, locale file format, and source directory, then generates a koto.config.ts.
npx koto init| Flag | Description |
|---|---|
--yes, -y | Accept all defaults without prompting |
koto translate
Translate all pending strings. Default command when none is specified.
npx koto translatenpx koto translate --locale es,frnpx koto translate --context legalnpx koto translate --dry-runnpx koto translate --force| Flag | Description |
|---|---|
--locale, -l | Translate only specific locales (comma-separated) |
--context, -c | Translate only files matching a specific context profile |
--dry-run | Preview what would be translated without writing files |
--force | Re-translate all keys, ignoring cache and lockfile |
--fail-on-error | Exit with code 1 on translation errors or quality failures |
--json | Output results in machine-readable JSON |
koto diff
Show what needs translation. Lists new, changed, and deleted keys across all target locales.
npx koto diffnpx koto diff --json| Flag | Description |
|---|---|
--json | Output diff in machine-readable JSON |
--locale, -l | Check only specific locales |
koto types
Generate TypeScript type definitions from your source locale files.
npx koto typesnpx koto types --watch| Flag | Description |
|---|---|
--watch | Watch source files and regenerate types on change |
koto validate
Check your configuration and test the provider connection.
npx koto validatekoto badge
Generate an i18n coverage badge from your lockfile, plus coverage artifacts for CI and dashboards.
npx koto badgekoto contribute
Fork an OSS repo, run koto translation for one locale, and open a pull request via GitHub CLI.
npx koto contribute owner/repo --locale frnpx koto contribute owner/repo --locale ja --dry-run| Flag | Description |
|---|---|
--locale, -l | Target locale code for the contribution (required) |
--dry-run | Show steps without creating a fork/PR |
koto cache stats
Display cache analytics: cached translations, hit rate, and disk usage.
npx koto cache statskoto cache clear
Clear the translation cache. Subsequent runs will re-translate all keys.
npx koto cache clearGlobal options
| Flag | Description |
|---|---|
--version, -v | Show koto version |
--help, -h | Show help text |
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Translation failure, quality gate failure, or invalid config |
2 | Unknown command or missing required arguments |
Environment variables
| Variable | Description | Required by |
|---|---|---|
OPENAI_API_KEY | OpenAI API key | provider.name: 'openai' |
ANTHROPIC_API_KEY | Anthropic API key | provider.name: 'anthropic' |
GOOGLE_API_KEY | Google Gemini API key | provider.name: 'google' |
KOTO_CONFIG | Custom path to config file | All (optional) |
koto loads .env files from your project root automatically.
Examples
# Initialize a new projectnpx koto init
# Translate everythingnpx koto translate
# Translate only Spanish and Frenchnpx koto translate -l es,fr
# Translate only legal contextnpx koto translate -c legal
# Preview without writingnpx koto translate --dry-run
# Re-translate everything from scratchnpx koto translate --force
# CI mode: fail on errorsnpx koto translate --fail-on-error
# Check what needs translatingnpx koto diff
# Generate TypeScript typesnpx koto types
# Watch mode for typesnpx koto types --watch
# Verify setupnpx koto validate
# Generate coverage badgenpx koto badge
# Contribute translations to an OSS reponpx koto contribute owner/repo --locale fr