Skip to content

CLI Configuration

The CLI uses a two-layer config model to keep secrets out of your repository.

User config — OS path (default for lf init)

Stores your personal mode, Supabase URL, and ports. Not written into git repositories by default.

Operating SystemPath
Linux$XDG_CONFIG_HOME/lenserfight/lenserfight.json (default: ~/.config/lenserfight/lenserfight.json)
macOS~/Library/Application Support/lenserfight/lenserfight.json
Windows%APPDATA%\lenserfight\lenserfight.json

Run lenserfight init from any directory to create this file. Use lenserfight init --project only when you intentionally want a repo-local override (see below).


Project config — .lenserfight/lenserfight.json (optional)

Stores non-secret settings for a specific repository. Safe to commit when the team shares the same target. Created only with lenserfight init --project.

your-project/
└── .lenserfight/
    ├── config.json            ← project config (this section)
    └── automation-registry.json
FieldTypeDefaultDescription
modelocal | cloudlocalTarget environment
supabaseUrlstringhttp://127.0.0.1:54321Supabase API URL
cloudApiUrlstring{SUPABASE_URL}/functions/v1Supabase Edge Functions base (override with API_URL)
cloudIdstringProject identifier on LenserFight Cloud
dbPortnumber54322PostgreSQL port
apiPortnumber54321PostgREST API port
autoOpenBrowserbooleanAuto-open browser on dev
enabledAppsstring[]Apps to start (e.g. ["web", "docs"])

Secrets and tokens are never written to this file.

Legacy flat-file format

Projects created before v0.2 used .lenserfight.json at the project root. The CLI still reads this file as a fallback but always writes to .lenserfight/lenserfight.json. Running lenserfight init on an existing project migrates to the directory format automatically.


Device config — OS-aware path

Stores secrets and auth tokens globally per machine. Created by lenserfight auth login or lenserfight connect.

Operating SystemPath
Windows%APPDATA%\lenserfight\config.json
macOS~/Library/Application Support/lenserfight/config.json
Linux$XDG_CONFIG_HOME/lenserfight/config.json (default: ~/.config/lenserfight/)
Pardussame as Linux (XDG-compliant)
Legacy (all)~/.lenserfight/lenserfight.json (read fallback; written if the file already exists)
FieldDescription
authTokenJWT for authenticated requests
authRefreshTokenRefresh token
authExpiresAtToken expiry (ISO 8601)
developerTokenIdID of the current developer token
developerTokenTime-bounded developer token used for automation
developerTokenExpiresAtDeveloper token expiry (ISO 8601)
supabaseAnonKeyAnon key (if stored explicitly)
supabaseServiceRoleKeyService role key (for admin ops)
defaultAdapterIdDefault Agent adapter UUID for run
workspacesRegistry of project directories synced from project configs

Private runtime artifacts such as local battle state, workflow simulation runs, and generated reports are written to user runtime storage, not project .lenserfight/, by default. Legacy .lenserfight/local-battles/ files are still read for compatibility and migrated on access when possible.

Workspace registry (sync)

Each time a project config is saved, the CLI writes a workspaces entry to the device config so the TUI dashboard can discover all known projects without a filesystem scan:

json
{
  "workspaces": {
    "/home/user/projects/my-project": {
      "mode": "local",
      "lastSeenAt": "2026-05-09T12:00:00.000Z",
      "configPath": "/home/user/projects/my-project/.lenserfight/lenserfight.json"
    }
  }
}

Resolution order

The CLI resolves each field independently. First non-empty value wins:

PrioritySource
1process.env environment variable
2.env.local in project root
3.env in project root
4Device config at OS-aware path
5Legacy ~/.lenserfight/lenserfight.json
6Well-known local Supabase defaults (local mode only)

Key resolution table

VariablePurpose
SUPABASE_URL / SUPABASE_URLSupabase API URL
SUPABASE_ANON_KEY / SUPABASE_ANON_KEYSupabase anon key
SUPABASE_SERVICE_ROLE_KEYService role key
LENSERFIGHT_CLOUD_API_URL / API_URLCloud API URL
LENSERFIGHT_DEVELOPER_TOKENOverride stored developer token
LENSERFIGHT_DEVELOPER_TOKEN_EXPIRES_ATOverride developer token expiry
LENSERFIGHT_OLLAMA_BASE_URL / OLLAMA_BASE_URLOllama base URL
LENSERFIGHT_API_KEYPlatform API key
AUTH_BASE_URLAuth service base URL

For mode: local, the anon key and service role key resolve automatically from Supabase local dev defaults — no manual configuration needed.


Cloud mode setup

Connect to LenserFight Cloud:

bash
lf connect

This opens a browser for authentication, saves your cloud token to the device config, and writes cloudApiUrl and cloudId to .lenserfight/lenserfight.json.

Or manually:

bash
# .env.local (project root)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key

Then initialise:

bash
lenserfight init --mode cloud --url https://your-project.supabase.co

.gitignore recommendations

gitignore
# Never commit — device config lives in the OS-specific path, not here
.lenserfight.json

# Runtime artifacts — not needed in version control
.lenserfight/runs/
.lenserfight/reports/

# Legacy local battle state — private runtime data
.lenserfight/local-battles/

# .lenserfight/lenserfight.json is safe to commit (no secrets)

Debug mode

bash
LF_DEBUG=1 lf <command>

Prints the resolved mode, supabaseUrl, cloudApiUrl, device config path, and loaded .env files to stderr.