Skip to main content
The LeadMagic CLI stores configuration in a JSON file and supports environment variable overrides.

Config File Location

LocationPathWhen Used
Project-local.leadmagic/config.jsonWhen a .leadmagic/ directory exists in the current or parent directory
Global~/.leadmagic/config.jsonFallback when no project-local directory is found
The CLI checks for a project-local .leadmagic/ directory first, walking up the directory tree. If none is found, it uses the global directory at ~/.leadmagic/. Initialize a project-local directory:
lm init --local
Initialize the global directory:
lm init --global

Configuration Keys

Manage config values with lm config:
lm config show          # Show all settings
lm config get apiKey    # Get a specific value
lm config set apiKey    # Set a value (prompts securely for sensitive keys)

User Config Keys

These keys can be set via lm config set <key> <value>:
KeyTypeDescriptionDefault
apiKeystringLeadMagic API key (lm_ prefix)
baseUrlstring (URL)API base URLhttps://api.leadmagic.io
dbPathstringPath to database file~/.leadmagic/data.db
dbMemoryLimitstringDatabase memory limit (e.g., 2GB, 512MB)
dbThreadsnumberNumber of database threads (1–256)
aiProvider"gateway"AI providergateway
aiModelstringAI model identifieranthropic/claude-sonnet-4.6

Internal Config Keys

These are managed automatically by the CLI:
KeyTypeDescription
authTokenstringOAuth access token (from lm login)
refreshTokenstringOAuth refresh token
authTokenExpiresAtnumberToken expiry timestamp (ms)
userInfoobjectCached user info (email, name)
workerBaseUrlstringAI Gateway URL
outputDirstringExport output directory
scrollSpeednumberScroll speed (1–10)
themestringColor theme name
plainTextMessagesbooleanRender messages as plain text
acceptedTermsAtstringISO timestamp of terms acceptance
dbQueryTimeoutnumberSQL query timeout (ms)
dbMaxRowsnumberMax rows returned from queries

Environment Variables

VariableOverridesDescription
LEADMAGIC_API_KEYapiKeyAPI key (takes precedence over config file)
LM_WORKER_URLworkerBaseUrlAI Gateway URL
LM_DEBUGSet to 1 to enable debug logging

Database Configuration

The CLI uses a local embedded database for storing loaded data, query results, and metadata.
lm config set dbPath /path/to/custom.db
lm config set dbMemoryLimit 4GB
lm config set dbThreads 8
Database management commands:
CommandDescription
lm db initInitialize database and run migrations
lm db statsShow database statistics and memory usage
lm db vacuumCompact database, reclaim space
lm db analyzeUpdate query optimizer statistics
lm db repairFix corruption and re-run migrations
lm db resetDrop all tables and data
lm db unlockRelease database lock from stale processes
lm db reset is destructive and cannot be undone. Exported files in .leadmagic/export/ are preserved.

AI Model Selection

Select a model interactively:
lm config model
Or set it directly:
lm config set aiModel claude-sonnet
List available models:
lm config list-models
lm config list-models -p anthropic
In chat, switch models on the fly:
/model

Themes

The CLI supports four color themes:
ThemeDescription
draculaDark purple theme (default)
tokyo-nightDark blue theme
nordArctic blue theme
catppuccinWarm pastel theme
Set a theme:
lm config set theme tokyo-night
Or switch in chat:
/theme

Export Directory

All enrichment, validation, and export results are saved to timestamped subdirectories:
.leadmagic/export/
├── 20260306-143022-email-finder/
│   └── contacts_enriched.csv
├── 20260306-151045-validation/
│   └── campaign_validated.csv
└── 20260306-160812-enrich/
    └── leads_enriched.csv
Each operation creates a new timestamped directory to prevent overwriting previous results. Set a custom output directory:
lm config set outputDir /path/to/exports

Interactive Configuration

Open the full interactive configuration UI:
lm config interactive
This provides a terminal-based interface for browsing and editing all settings. Aliases: lm config ui, lm config tui.

Next Steps