Skip to main content

Config

TF Code uses JSON config files merged in precedence order. Profile credentials and environment variables override file-based settings.

Interactive Setup

The recommended way to get started:

tfcode setup

This prompts for profile name, workspace ID, API key, and region, then saves them as a named profile.

Profiles

Profiles store multiple sets of ToothFairyAI credentials so you can switch between workspaces instantly.

Create

tfcode setup
# Prompts for: profile name, workspace ID, API key, region

Non-interactive:

tfcode setup --profile dev --workspace-id dev-ws-456 --api-key dev-key-xxx --region dev --name dev

Switch

tfcode profile prod
tfcode profile
# Current profile: prod
#
# Available profiles:
# * prod
# dev

Use in commands

tfcode -p prod run "Deploy to production"
TF_PROFILE=prod tfcode run "Force prod workspace"

Storage

Profiles are stored in ~/.local/share/tfcode/.tfcode/profiles.json:

{
"default": "prod",
"profiles": {
"prod": {
"api_key": "prod-key-xxx",
"workspace_id": "prod-ws-123",
"region": "au"
},
"dev": {
"api_key": "dev-key-yyy",
"workspace_id": "dev-ws-456",
"region": "dev"
}
}
}

Profiles replace the legacy credentials.json. TF Code automatically migrates it on first profile command.

Regions

RegionBase URLStreaming URL
devai.toothfairylab.linkais.toothfairylab.link
auai.toothfairyai.comais.toothfairyai.com
euai.eu.toothfairyai.comais.eu.toothfairyai.com
usai.us.toothfairyai.comais.us.toothfairyai.com

Config File Locations

Config sources are loaded in order of increasing priority (later overrides earlier):

  1. Global config~/.config/tfcode/tfcode.json
  2. Custom configOPENCODE_CONFIG env var path
  3. Project configtfcode.json in project root
  4. .tfcode/tfcode.json in project root
  5. Inline configOPENCODE_CONFIG_CONTENT env var
  6. Active profile — set via tfcode profile <name> or --profile / TF_PROFILE
  7. Environment variablesTF_WORKSPACE_ID, TF_API_KEY, TF_REGION

Files are merged together, not replaced. Non-conflicting settings from all sources are preserved.

Project config example

.tfcode/tfcode.json:

{
"toothfairy": {
"workspace_id": "your-workspace-id",
"api_key": "your-api-key",
"region": "au"
},
"model": "toothfairyai/mystica",
"default_agent": "build"
}

Environment Variables

VariableDescription
TF_WORKSPACE_IDToothFairyAI workspace ID
TF_API_KEYToothFairyAI API key
TF_REGIONToothFairyAI region: dev, au, eu, us
TF_PROFILEProfile name to use (overrides default profile)
TFCODE_SERVER_PASSWORDHTTP basic auth password for server mode
TFCODE_SERVER_USERNAMEHTTP basic auth username (default: tfcode)
OPENCODE_CONFIGPath to custom config file
OPENCODE_CONFIG_CONTENTInline config content (highest priority)

Validate

tfcode validate
tfcode validate --profile prod

Server Config

The server block controls the HTTP server:

{
"server": {
"port": 4096,
"hostname": "127.0.0.1",
"mdns": false,
"mdnsDomain": "tfcode.local",
"cors": ["https://app.example.com"]
}
}

Logging

tail -f ~/.local/share/tfcode/log/dev.log
tfcode --log-level DEBUG

Levels: DEBUG, INFO, WARN, ERROR.

CLI Commands Reference

Top-level

CommandDescription
tfcodeStart interactive session
tfcode run <prompt>Execute a single task and exit
tfcode serveStart headless HTTP server
tfcode webStart server and open web interface
tfcode attach <url>Attach TUI to a running server

Setup & credentials

CommandDescription
tfcode setupInteractive credential setup (creates a profile)
tfcode validateValidate credentials (--profile <name> for specific)
tfcode profileShow current profile and list all
tfcode profile <name>Switch to a different profile
tfcode syncSync workspace tools metadata
tfcode providers listList available providers
tfcode models [provider]List available models (optional provider filter)
tfcode models --verboseList models with metadata
tfcode models --refreshRefresh the models cache

MCP

CommandDescription
tfcode mcp listList MCP servers and tools
tfcode mcp addAdd a local MCP server
tfcode mcp authAuthenticate with OAuth MCP server
tfcode mcp logoutLogout from MCP server

Other

CommandDescription
tfcode -p/--profileSwitch profile per command
tfcode --log-levelSet log level
tfcode --versionShow version
tfcode --helpShow all commands

Chat commands (interactive)

CommandDescription
/compact [instructions]Compact context with preservation hints
/helpShow available commands