SwiftRelay

← 全部冲刺笔记

Your First Claude Code Session on a New Machine

Agent 快速起步EN

Your first Claude Code session should end with a small, verified change, not a mystery configuration you cannot reproduce. This walkthrough separates installation, credentials, and project work so you can check each layer before moving on.

1. Prepare a Safe Folder for Your First Session

Start with a disposable project or a repository you understand. Avoid launching from your home directory, where unrelated documents and credentials may be nearby. If you already have a project, install its required language runtime and follow its setup instructions before asking an agent to change anything.

For this walkthrough, use macOS with Homebrew already installed, or Windows with WinGet available. Keep one terminal open throughout configuration so the environment stays consistent.

2. Install Claude Code and Verify the Command

On macOS, run brew install --cask claude-code. On Windows, run winget install Anthropic.ClaudeCode. These are documented installation options. For Linux or a machine without either package manager, follow the operating-system-specific native installation instructions in the official Claude Code documentation. ([code.claude.com](https://code.claude.com/docs/en/overview))

After installation, open a new terminal and run claude --version. Continue only when it prints a version. If the command is not found, resolve the installation directory's PATH configuration before troubleshooting credentials. ([code.claude.com](https://code.claude.com/docs/en/quickstart))

3. Prepare Your SwiftRelay Credentials

SwiftRelay is a useful option when you want pay-as-you-go access with per-token billing. Sign up for SwiftRelay to receive the small gift credit available to new accounts, then obtain your API credential.

Treat that credential like a password. Keep it out of source files, screenshots, shared terminal transcripts, and prompts. Before sending work code through any relay, confirm that your organization permits that route and review the service's data-handling terms.

4. Configure the Relay in Your Current Terminal

Claude Code uses ANTHROPIC_BASE_URL for a custom endpoint. Set its value to SwiftRelay's bare HTTPS host: use the HTTPS scheme followed by api.fastapirelay.com, with no additional path. Do not append /v1 for Claude Code.

In Bash or Zsh, assign environment variables with export VARIABLE_NAME='value'. In PowerShell, use $env:VARIABLE_NAME = 'value'. Set the base URL first, then set ANTHROPIC_AUTH_TOKEN to your relay credential if SwiftRelay's setup instructions specify bearer authentication. If they specify API-key authentication instead, use ANTHROPIC_API_KEY. These variables send different authentication headers; do not set both speculatively. ([code.claude.com](https://code.claude.com/docs/en/llm-gateway-connect))

Use session-only configuration for this first test. Once it works, persist it through an appropriate user-level configuration or secret-management workflow, not a committed project file. ([code.claude.com](https://code.claude.com/docs/en/llm-gateway-connect))

5. Launch Claude Code and Confirm the Route

Change into your chosen project directory with cd, then run claude from the same terminal. Complete the startup prompts, reading any trust request before accepting it. Starting inside the project establishes the working context for your session. ([code.claude.com](https://code.claude.com/docs/en/quickstart))

Run /status and inspect the base URL and credential source. Confirm that the relay address appears, then send a short test message. A successful response verifies more than installation alone: your endpoint, authentication, and selected model must work together. ([code.claude.com](https://code.claude.com/docs/en/llm-gateway-connect))

6. Ask Claude Code to Inspect Before Editing

Use a bounded first prompt: Read the project instructions and explain how to run the tests. Do not edit files or install dependencies yet. Compare the answer with the repository's documentation before authorizing work.

Then request one small change, such as correcting a validation message and adding a matching test. Keep permission prompts enabled and inspect proposed commands. Claude Code's permission controls distinguish reading, command execution, and file modification; broad approval is unnecessary for this exercise. ([code.claude.com](https://code.claude.com/docs/en/permissions))

7. Review the Diff and Record Your Setup

Inspect every changed file, run the relevant tests, and check for unrelated edits before committing. Ask Claude to distinguish tests it actually ran from checks it merely recommends.

Finally, review the session's usage in SwiftRelay and record your installation method, configuration variable names, and working test command without recording the credential. Your first session is complete when you can explain the change, verify it, and reproduce the setup.

接着读

又来跑一圈?登录