TaskWeaver follows the XDG Base Directory Specification for configuration, making it a well-behaved Linux citizen.
TaskWeaver loads configuration in this order (later overrides earlier):
- Built-in defaults - Hardcoded fallback values
- XDG user config (
~/.config/taskweaver/config.toml) - System-wide user preferences - Project-local config (
./config.toml) - Takes precedence! (for development)
This means you can have both a system-wide config for general use AND project-specific overrides when working in a cloned repository.
# Project-local (for development)
./config.toml # Project-specific preferences (gitignored)
./.env # Project API keys (gitignored)
./tasks.db # Optional local database (gitignored)
# XDG user directories (system-wide)
~/.config/taskweaver/
├── config.toml # User preferences (model selection, display settings)
└── .env # API keys (secrets - gitignored)
~/.local/share/taskweaver/
└── tasks.db # SQLite database (application data)
~/.cache/taskweaver/
└── (future: LLM cache)
~/.local/state/taskweaver/
└── taskweaver.log # Application logs
Copy config.toml.example from the repository to get started:
cp config.toml.example ~/.config/taskweaver/config.tomlExample configuration:
# Simple, flat configuration - no nested sections!
# LLM model name
llm_model = "gpt-4o-mini"
# API endpoint URL (OpenAI, Anthropic, local, or custom)
api_endpoint = "https://api.openai.com/v1"
# Automatically decompose complex tasks into subtasks
auto_decompose = trueCopy .env.example from the repository:
cp .env.example ~/.config/taskweaver/.envAdd your API key:
# Your API key (works with any provider)
API_KEY=sk-...
# Examples:
# OpenAI: API_KEY=sk-proj-...
# Anthropic: API_KEY=sk-ant-...
# Local LLM: API_KEY=not-needed (or leave empty)How it works:
- Single
API_KEYenvironment variable - Works with whichever
api_endpointyou configured - Change providers by updating
config.toml, keep same.env - Perfect for local models that don't need authentication
.env files to version control!
For Developers: When working on TaskWeaver itself or contributing, you can create local config files in the project root:
cd /path/to/taskweaver
# Create local config (overrides your XDG config)
cp config.toml.example config.toml
# Create local .env (overrides your XDG .env)
cp .env.example .env
# Add your dev API keys
echo "OPENAI_API_KEY=sk-dev-..." >> .envHow it works:
- TaskWeaver detects project roots by looking for
pyproject.tomlor.git/ - If
./config.tomlexists, it overrides settings from~/.config/taskweaver/config.toml - If
./tasks.dbexists, it will be used instead of~/.local/share/taskweaver/tasks.db - Perfect for testing without affecting your system-wide tasks!
Example use case:
# ~/.config/taskweaver/config.toml (system-wide)
llm_model = "gpt-4"
api_endpoint = "https://api.openai.com/v1"
# ./config.toml (project-local override)
llm_model = "gpt-4o-mini" # Cheaper model for developmentWhen running from the project directory, TaskWeaver will use gpt-4o-mini (local) instead of gpt-4 (system).
config.toml, .env, and tasks.db are gitignored to prevent accidentally committing dev secrets.
You can override XDG directories using environment variables:
# Override config directory (default: ~/.config)
export XDG_CONFIG_HOME=/custom/config
# Override data directory (default: ~/.local/share)
export XDG_DATA_HOME=/custom/data
# Override cache directory (default: ~/.cache)
export XDG_CACHE_HOME=/custom/cache
# Override state directory (default: ~/.local/state)
export XDG_STATE_HOME=/custom/stateAll commands support the --db flag to override the database path:
taskweaver create "Test task" --db /tmp/test.db
taskweaver ls --db /tmp/test.dbSettings are loaded in this order (later overrides earlier):
- Built-in defaults (hardcoded in
config.py) - XDG user config (
~/.config/taskweaver/config.toml) - Project-local config (
./config.toml) - overrides XDG settings - Environment variables (
XDG_*for paths only) - CLI flags (
--dbfor temporary overrides)
Example:
# ~/.config/taskweaver/config.toml
llm_model = "gpt-4"
api_endpoint = "https://api.openai.com/v1"
auto_decompose = true
# ./config.toml (in project directory)
llm_model = "claude-3-5-sonnet-20241022" # Overrides "gpt-4"
api_endpoint = "https://api.anthropic.com/v1" # Overrides OpenAI endpoint
# auto_decompose stays true from XDG configResult: Uses Claude model with Anthropic endpoint, auto-decompose enabled.
from taskweaver.config import get_config, get_paths
# Get configuration (cached)
config = get_config()
print(config.model) # "gpt-4o-mini"
print(config.api_endpoint) # "https://api.openai.com/v1"
print(config.auto_decompose) # True
print(config.api_key) # Your API key from .env (or None)
# Get XDG paths (cached)
paths = get_paths()
print(paths.database_file) # PosixPath('/home/user/.local/share/taskweaver/tasks.db')
print(paths.project_root) # PosixPath('/path/to/project') or NoneIf you used TaskWeaver before XDG compliance, migrate your data:
# Old location
OLD_DB="~/.taskweaver/tasks.db"
# New location
NEW_DB="~/.local/share/taskweaver/tasks.db"
# Copy database
mkdir -p ~/.local/share/taskweaver
cp $OLD_DB $NEW_DB
# Remove old directory (optional)
rm -rf ~/.taskweaverIf you see "Database does not exist" errors, check permissions:
# Verify data directory is writable
ls -la ~/.local/share/taskweaver/
# Create manually if needed
mkdir -p ~/.local/share/taskweaverVerify your .env file is in the correct location:
# Should be here:
cat ~/.config/taskweaver/.env
# Not here:
cat .env # ❌ (project root - wrong!)Check your config.toml syntax:
# Validate TOML syntax
python3 -c "import tomllib; tomllib.load(open('~/.config/taskweaver/config.toml', 'rb'))"- Version control your config.toml - It's safe to share (no secrets)
- Never commit .env files - Use
.gitignore - Use environment variables in CI/CD - Don't rely on files in automated environments
- Back up your database -
~/.local/share/taskweaver/tasks.dbcontains all your tasks