Junie Help

Environment variables

Environment variables let you configure Junie CLI without passing command-line flags. This is especially useful in CI/CD pipelines and headless environments where you set variables in the runner configuration instead of the command line.

Configuration precedence

When the same setting is specified in multiple places, Junie uses the following precedence order (highest to lowest):

  1. Command-line flags (--auth, --model, etc.).

  2. Environment variables (JUNIE_API_KEY, JUNIE_MODEL, etc.).

  3. Configuration files (.junie/guidelines.md, .junie/mcp/mcp.json, etc.).

  4. Built-in defaults.

For example, if JUNIE_MODEL is set to sonnet but you run junie --model gpt, the CLI flag takes priority.

Authentication

Set one of the following variables to authenticate Junie CLI with your preferred LLM provider.

Junie token

Environment variable

CLI equivalent

Description

JUNIE_API_KEY
-a, --auth

Authentication token (Junie API key) for Junie CLI. Generate one at junie.jetbrains.com/cli.

Provider API keys

Use these variables to authenticate directly with a specific LLM provider (BYOK). Only the key for the provider of your selected model is required.

Environment variable

CLI equivalent

Description

JUNIE_ANTHROPIC_API_KEY
--anthropic-api-key

API key for Anthropic (Claude models).

JUNIE_OPENAI_API_KEY
--openai-api-key

API key for OpenAI (GPT models).

JUNIE_GOOGLE_API_KEY
--google-api-key

API key for Google AI (Gemini models).

JUNIE_GROK_API_KEY
--grok-api-key

API key for xAI (Grok models).

JUNIE_OPENROUTER_API_KEY
--openrouter-api-key

API key for OpenRouter.

Project and task

Environment variable

CLI equivalent

Description

JUNIE_TASK
--task

Task description in plain English. Alternative to passing the task as a positional argument.

JUNIE_PROJECT
-p, --project

Path to the project directory. Defaults to the current working directory.

For model configuration, see Model selection.

Guidelines and customization

Guidelines file

Environment variable

CLI equivalent

Description

JUNIE_GUIDELINES_FILENAME
--guidelines-filename

Name or path of a custom guidelines file to use instead of the default. The file should be placed in .junie/ at the project root.

When Junie starts a task, it looks for guidelines in the following order:

  1. Custom file. If JUNIE_GUIDELINES_FILENAME is set, Junie uses that file (e.g., .junie/my_guidelines_ci.md).

  2. .junie/AGENTS.md. Primary guidelines file in the Junie project directory.

  3. AGENTS.md. The guidelines file in the project root.

  4. .junie/rules/*.md. All Markdown files in the rules directory, concatenated automatically.

  5. .junie/guidelines.md. Legacy guidelines file (still supported).

For more information on guidelines, see Guidelines and memory.

MCP servers

Environment variable

CLI equivalent

Description

JUNIE_MCP_DEFAULT_LOCATIONS
--mcp-default-locations

Enable or disable default MCP server locations (per-user and per-project). Defaults to true.

JUNIE_MCP_LOCATIONS
--mcp-location

Additional paths to MCP configuration folders. Can be specified multiple times.

For more information on configuring MCP servers, see MCP configuration.

See also

14 March 2026