Skip to main content

🖥️ TF Code - AI Coding Agent CLI

TF Code is ToothFairyAI's official AI coding agent - a powerful command-line interface that brings AI-powered coding assistance directly to your terminal. It provides full access to ToothFairyAI models, tools, and MCP (Model Context Protocol) servers, enabling you to code with AI assistance in any development environment.

Quick Start

1. Install

npm install -g @toothfairyai/tfcode

2. Configure Credentials

export TF_WORKSPACE_ID="your-workspace-id"
export TF_API_KEY="your-api-key"
export TF_REGION="dev" # Options: dev, au, eu, us

3. Validate

tfcode providers validate

4. Start Coding

tfcode

Or run a single task:

tfcode run "Explain this codebase"

Configuration

Credentials Setup

TF Code requires your ToothFairyAI credentials to access models and tools. There are three ways to configure them:

export TF_WORKSPACE_ID="your-workspace-id"
export TF_API_KEY="your-api-key"
export TF_REGION="dev" # Options: dev, au, eu, us

Add these to your shell profile (~/.zshrc, ~/.bashrc, etc.) for persistence.

Option B: Interactive Setup

Run the guided setup command:

tfcode setup

This will prompt for:

  • Workspace ID
  • API Key
  • Region

Credentials are stored in ~/.local/share/opencode/.tfcode/credentials.json.

Option C: Project-Level Configuration

Create .tfcode/opencode.json in your project root:

{
"provider": {
"toothfairyai": {
"type": "api",
"key": "your-api-key",
"workspaceId": "your-workspace-id",
"region": "dev"
}
}
}

Validate Credentials

After configuration, verify your credentials:

tfcode providers validate

Expected output:

✓ toothfairyai credentials validated
Workspace: your-workspace-id
Region: dev
Models available: 20

Configuration Files

credentials.json

Location: ~/.local/share/opencode/.tfcode/credentials.json

{
"workspace_id": "your-workspace-id",
"api_key": "your-api-key",
"region": "dev"
}

Project Configuration

Location: .tfcode/opencode.json (in project root)

{
"provider": {
"toothfairyai": {
"type": "api",
"key": "your-api-key",
"workspaceId": "your-workspace-id",
"region": "dev"
}
},
"model": "mystica",
"agent": "build"
}

Regions

ToothFairyAI has multiple regional endpoints:

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

Choose the region closest to you for best performance.

Overview

Key Features

  1. Multi-Model Support: Use any ToothFairyAI model directly from your terminal
  2. Tool Integration: Automatic access to ToothFairyAI MCP tools for enhanced capabilities
  3. File Operations: Read, write, edit, and search files with AI assistance
  4. Code Execution: Execute bash commands and code snippets
  5. Git Integration: Automatic git tracking and commit assistance
  6. Session Management: Persistent sessions with conversation history
  7. Skill System: Load specialised skills for domain-specific assistance

What's Included

  • ToothFairyAI Models: Access to all ToothFairyAI serverless models (Mystica, GLM-5, Claude, GPT, etc.)
  • ToothFairyAI Tools: Built-in integration with 100+ ToothFairyAI MCP tools
  • Teal Branding: Custom ToothFairyAI visual identity
  • Centralised Logging: All logs in one place for debugging
  • Tool Calling: Full support for MCP tool execution

Installation

Requirements

  • Node.js: Version 18 or higher
  • Python (optional): Version 3.10+ for ToothFairyAI integration features

Install via npm

npm install -g @toothfairyai/tfcode

Supported Platforms

TF Code is available for all major platforms:

PlatformArchitectureVariant
macOSApple Silicon (M1/M2)darwin-arm64
macOSInteldarwin-x64
macOSIntel (no AVX2)darwin-x64-baseline
LinuxARM64linux-arm64
LinuxARM64 (Alpine)linux-arm64-musl
Linuxx64linux-x64
Linuxx64 (no AVX2)linux-x64-baseline
Linuxx64 (Alpine)linux-x64-musl
Linuxx64 (Alpine, no AVX2)linux-x64-baseline-musl
WindowsARM64windows-arm64
Windowsx64windows-x64
Windowsx64 (no AVX2)windows-x64-baseline

The correct binary is automatically selected during installation.

Usage

Start Interactive Session

tfcode

This opens an interactive chat interface where you can:

  • Ask coding questions
  • Request file modifications
  • Execute commands
  • Use MCP tools

Run Single Commands

Execute a single task and exit:

tfcode run "Explain this codebase"
tfcode run "Add error handling to src/api.ts"

Specify Model

Choose a specific model:

tfcode run "Write a function to parse CSV" --model toothfairyai/mystica
tfcode run "Debug this issue" --model toothfairyai/z/glm-5

Available Models

All ToothFairyAI open-source models are available:

Model IDDescription
mysticaGeneral purpose coding model
mystica_15Faster variant of Mystica
z/glm-5GLM-5 for SOTA coding and agentic capabilities
kimi-k2.5Kimi 2.5 for advanced reasoning
minimax-2.5Minimax 2.5 for complex tasks
sorcererSorcerer model for specialised applications

MCP Tool Integration

TF Code automatically connects to ToothFairyAI's MCP server, providing access to 100+ tools for:

Agent Management

  • Create, update, delete agents
  • List and search agents
  • Configure agent settings

Function Management

  • Create agent functions (tools)
  • Configure external API integrations
  • Manage authentication

Knowledge Base

  • Create and search documents
  • Manage folders and entities
  • Build custom knowledge

Workspace Operations

  • Manage members and channels
  • View request logs
  • Track usage and costs

Example: Using MCP Tools

tfcode run "List all agents in my workspace"

The AI will automatically call toothfairy_list_toothfairy_agents and present the results.

tfcode run "Create a new agent called 'DataProcessor' with retriever mode"

The AI will call toothfairy_create_toothfairy_agent with the appropriate parameters.

Commands Reference

CommandDescription
tfcodeStart interactive session
tfcode run <prompt>Execute single task
tfcode setupConfigure credentials interactively
tfcode providers listList available providers
tfcode providers validateValidate credentials
tfcode mcp listList MCP tools
tfcode --helpShow all commands
tfcode --versionShow version

Logging

All logs are centralised in one location:

# View logs
tail -f ~/.local/share/opencode/log/dev.log

# Filter for specific service
tail -f ~/.local/share/opencode/log/dev.log | grep "provider.toothfairyai"

Log Levels

  • DEBUG: Detailed information for debugging
  • INFO: General operational information
  • WARN: Warning messages
  • ERROR: Error messages

Run with debug logging:

tfcode --log-level DEBUG

Troubleshooting

Credentials Not Working

# Verify credentials
tfcode providers validate

# Re-run setup
tfcode setup

MCP Tools Not Loading

  1. Check credentials are valid
  2. Verify network connectivity to MCP server
  3. Check logs for connection errors:
    grep "mcp.*error" ~/.local/share/opencode/log/dev.log

Binary Not Found

If installation fails, try:

# Clean install
npm uninstall -g @toothfairyai/tfcode
npm cache clean --force
npm install -g @toothfairyai/tfcode

Permission Errors

On Linux/macOS:

sudo chown -R $(whoami) ~/.npm-local

Updating

Update to the latest version:

npm update -g @toothfairyai/tfcode

Uninstalling

npm uninstall -g @toothfairyai/tfcode

# Optionally remove configuration
rm -rf ~/.local/share/opencode/.tfcode

Best Practices

  1. Use Project Configuration: Add .tfcode/opencode.json to each project for consistent settings
  2. Validate Credentials: Run tfcode providers validate after setup
  3. Check Logs: Use --log-level DEBUG when troubleshooting
  4. Choose Right Model: Use mystica for general tasks, z/glm-5 for complex agentic work
  5. Leverage MCP Tools: Let the AI use ToothFairyAI tools for workspace operations

Background

TF Code is built on OpenCode, an open-source AI coding agent, customised for ToothFairyAI with enhanced integration, ToothFairyAI agentic AI, and seamless access to the ToothFairyAI ecosystem of models and tools.

Resources

Support

For issues and feature requests: