> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sanbuphy/claude-code-source-code/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick start

> Get Claude Code running in minutes using the pre-built CLI.

The fastest way to use Claude Code is to run the pre-built `cli.js` that ships inside the npm package. No build step required.

<Steps>
  <Step title="Check your Node.js version">
    Claude Code requires Node.js 18 or later.

    ```bash theme={null}
    node --version
    # Should print v18.x.x or higher
    ```
  </Step>

  <Step title="Navigate to the repository root">
    The pre-built `cli.js` lives at the root of the package, alongside `package.json`.

    ```bash theme={null}
    cd /path/to/claude-code-source-code
    ```
  </Step>

  <Step title="Verify the CLI works">
    ```bash theme={null}
    node cli.js --version
    # → 2.1.88 (Claude Code)
    ```
  </Step>

  <Step title="Authenticate">
    Claude Code needs access to the Anthropic API. Use either method:

    **Option 1 — Environment variable (recommended for scripts):**

    ```bash theme={null}
    export ANTHROPIC_API_KEY=sk-ant-...
    ```

    **Option 2 — Interactive login:**

    ```bash theme={null}
    node cli.js login
    ```

    The login command walks you through the OAuth flow and stores credentials locally.
  </Step>

  <Step title="Run a non-interactive query">
    Use `-p` (or `--print`) to send a single prompt and exit immediately. No interactive session is opened.

    ```bash theme={null}
    node cli.js -p "Hello Claude"
    ```

    The response is printed to stdout and the process exits.
  </Step>

  <Step title="Start an interactive session">
    Run without any flags to open the interactive REPL:

    ```bash theme={null}
    node cli.js
    ```

    You'll see the Claude Code welcome screen. Type your prompt and press Enter. Use `/help` to list available slash commands.
  </Step>
</Steps>

## Key flags

| Flag                              | Description                                                                                               |
| --------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `--version`, `-v`                 | Print the version string and exit. Zero module loading — the fastest path.                                |
| `-p`, `--print`                   | Non-interactive mode. Send one prompt, print the response, and exit.                                      |
| `-c`, `--continue`                | Resume the most recent session in the current working directory.                                          |
| `-r`, `--resume <session-id>`     | Resume a specific session by ID. Optionally pass a search term to filter the interactive picker.          |
| `--model <model-id>`              | Override the model used for the main agent loop. Accepts aliases (`sonnet`, `opus`, `haiku`) or full IDs. |
| `--output-format <format>`        | Output format for `--print` mode: `text` (default), `json`, or `stream-json`.                             |
| `--max-turns <n>`                 | Maximum number of agentic turns in non-interactive mode.                                                  |
| `--dangerously-skip-permissions`  | Bypass all permission checks. For sandboxed CI/CD pipelines only.                                         |
| `--add-dir <path>`                | Grant tool access to an additional directory beyond the current working directory.                        |
| `--allowed-tools <tools...>`      | Comma/space-separated allowlist of tool names (e.g. `"Bash(git:*) Edit"`).                                |
| `--disallowed-tools <tools...>`   | Comma/space-separated denylist of tool names.                                                             |
| `--system-prompt <prompt>`        | Replace the default system prompt with a custom one.                                                      |
| `--append-system-prompt <prompt>` | Append text to the default system prompt.                                                                 |
| `--mcp-config <file>`             | Load MCP server configurations from a JSON file.                                                          |
| `--settings <file-or-json>`       | Load additional settings from a JSON file or inline JSON string.                                          |
| `--bare`                          | Minimal mode: skip hooks, LSP, plugins, attribution, and auto-memory. Auth via `ANTHROPIC_API_KEY` only.  |
| `--no-session-persistence`        | Disable writing session transcripts to disk (only works with `--print`).                                  |

## Example: non-interactive query

```bash theme={null}
ANTHROPIC_API_KEY=sk-ant-... node cli.js -p "List all TypeScript files in ./src that export a default function"
```

The agent runs, executes whatever tools are needed (glob, read, etc.), prints the final answer, and exits.

## Example: resume a previous session

```bash theme={null}
# Continue from where you left off in the current directory
node cli.js --continue

# Resume a specific session by ID
node cli.js --resume sess_abc123
```

## Install globally (optional)

If you want to call `claude` instead of `node cli.js`:

```bash theme={null}
npm install -g .
claude --version
# → 2.1.88 (Claude Code)
```

<Note>
  The `-p` flag puts Claude Code into non-interactive (headless) mode. This is equivalent to the SDK's `QueryEngine` path and is well-suited for scripting and automation.
</Note>
