A Practical Guide to AI Coding Tools: From Installation to Securely Connecting to an LLM
This guide explains how to set up an AI coding assistant, from checking your environment and installing the tool safely, to configuring credentials, connecting to a large language model service, and setting permission boundaries. It uses Claude Code as an example and includes commands for macOS, Linux, and Windows, plus verification steps and security best practices for API keys, proxies, and certificates.
1. What Can AI Coding Tools Do?
AI coding tools can read project files, understand code structure, and generate or modify code based on your instructions. Common use cases include the following.
- Generating boilerplate code: Create APIs, data structures, configuration files, and test cases from functional descriptions.
- Reading unfamiliar projects: Map out module boundaries, function call chains, and exception-handling logic.
- Assisting with debugging: Analyze error messages and log excerpts to suggest possible causes and a troubleshooting sequence.
- Refactoring and adding tests: Identify duplicated logic, propose how to split it, and add tests for edge cases.
- Performing development operations: With your authorization, create files, modify code, run tests, or organize commit content.
These tools work best on repetitive tasks with clear context. For code involving payments, permission checks, encryption, or production environment configuration, an experienced engineer should review every line, even when the model output looks reasonable.
2. Preparing Your Environment
2.1 Check Basic Tool Versions
The commands differ by operating system. Run the following commands in a terminal to confirm that Node.js, npm, and Git are installed.
macOS or Linux:
node --versionnpm --versiongit --versionuname -m
Windows PowerShell:
node --versionnpm --versiongit --version$env:PROCESSOR_ARCHITECTURE
The output of uname -m or $env:PROCESSOR_ARCHITECTURE identifies your processor architecture, such as x86_64, arm64, or AMD64. When downloading an installer, its architecture must match this output.
If a command returns “is not recognized as an internal or external command” or “command not found,” install the corresponding software first, then reopen the terminal.
2.2 Prepare the Project Directory
We recommend using AI coding tools inside a dedicated Git repository. Before making changes, commit your current code. That way, if the tool makes a mistake, you can diff and roll back with Git.
sample-project/├── src/├── tests/├── docs/├── config/├── README.md└── .gitignore
Sensitive files should be excluded at two layers. The first layer is .gitignore, which prevents accidental commits. The second layer is the tool’s own ignore rules, which prevent the tool from reading those files. With Claude Code, for example, you can configure denied paths in the project’s .claude/settings.json:
{"permissions": {"deny": ["Read(./.env)","Read(./.env.*)","Read(./config/secrets/**)","Read(./backups/**)"]}}
Your .gitignore should also exclude dependency directories, build artifacts, log files, and local configuration — for example, node_modules/, dist/, *.log, and .env*. The exact configuration fields vary by tool version, so refer to the official documentation.
2.3 Confirm Network and Account Permissions
First, confirm that your machine can reach the model provider’s domain. If you are on a corporate network, ask your network administrator about the proxy address, certificate chain, and egress policy.
Install and run the tool under a regular user account. Avoid running AI coding tools with administrator privileges over the long term — the higher the privilege, the greater the impact of any accidental operation.
3. Installing the Tool
This section uses installing Claude Code via npm as an example. Other tools may be installed differently; follow their official documentation.
Claude Code has a minimum Node.js version requirement. Before installing, run node --version and compare the result against the requirement in the official documentation. If your version is too old, upgrade Node.js first.
npm install -g @anthropic-ai/claude-codeclaude --version
After a successful installation, claude --version prints the version number.
Verifying the Installation Source
Malicious npm packages with names similar to legitimate ones are common, so verify the package’s source before installing. The following two commands show the repository URL and publisher information:
npm view @anthropic-ai/claude-code repository.urlnpm view @anthropic-ai/claude-code maintainers
The repository URL should point to the official organization’s repository, and the maintainers should match what the official documentation discloses. If either does not match, stop the installation and confirm with your team.
Troubleshooting “Command Not Found”
Step 1: Check the npm global installation directory:
npm prefix -g
Step 2: Confirm that the bin subdirectory under that path is in your PATH. On macOS and Linux:
echo $PATHwhich claude
On Windows PowerShell:
$env:Path -split ';'Get-Command claude
Step 3: If the directory is missing from PATH, add it to your shell configuration file (for example, ~/.zshrc or ~/.bashrc), then reopen the terminal. On Windows, you can add the directory in the Environment Variables settings.
Verifying Installer Integrity
If the tool is distributed as an installer or archive, verify it against the SHA-256 checksum published on the release page before installing:
# macOSshasum -a 256 tool-installer.pkg# Linuxsha256sum tool-installer.tar.gz
# Windowscertutil -hashfile tool-installer.exe SHA256
The computed result must exactly match the checksum provided on the official release page. If it does not, do not install the file.
4. Connecting to an LLM Service
AI coding tools do not include model capabilities themselves. They access model services over the network, so configuration requires four things: the API endpoint, access credentials, the model name, and the protocol type.
4.1 Confirm the Protocol Type and Variable Names
Before connecting, confirm which protocol your provider offers. Different protocols use different authentication methods and variable names.
- Anthropic native or compatible format: Claude Code reads the following variables directly.
ANTHROPIC_BASE_URL: The base API URL, usually without/v1— follow your provider’s documentation.ANTHROPIC_API_KEY: The API key, sent as thex-api-keyrequest header.ANTHROPIC_MODEL: The model name, which can also be specified at startup with the--modelflag.
- OpenAI-compatible format: Claude Code cannot use these endpoints directly. You need either an Anthropic-compatible endpoint provided by your provider, or a compatibility gateway that converts the protocol, and then configure the variables above.
If both a configuration file and environment variables exist for the tool, follow the precedence described in the tool’s documentation. After configuring, verify the connection using the method in Section 4.4.
4.2 Store Credentials Securely
API keys are highly sensitive data. They should never be written into code, configuration files, or Git repositories, and they should not appear in terminal history or logs.
When creating a key in the provider’s console, grant only the permissions the current project needs. Prefer the operating system’s built-in credential storage.
On macOS, store the key in Keychain and read it when needed:
security add-generic-password -a "$USER" -s claude-code-api -wexport ANTHROPIC_API_KEY="$(security find-generic-password -a "$USER" -s claude-code-api -w)"
On Linux desktop environments, you can use secret-tool:
secret-tool store --label="claude-code-api" service claude-code-apiexport ANTHROPIC_API_KEY="$(secret-tool lookup service claude-code-api)"
On Windows, you can store the key in Credential Manager and read it into the current session each time you open a terminal. If you only need temporary access, set a session-scoped variable in PowerShell:
$env:ANTHROPIC_API_KEY = "paste-your-key-here"
This only applies to the current session and becomes invalid once the terminal is closed.
We do not recommend storing keys long-term with setx. setx writes the value to user environment variables, where every process under the same user can read it, and the value remains in the registry indefinitely. If you must use setx, clean up immediately afterward:
[Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', $null, 'User')
Note: All addresses and model names in the examples above are format placeholders only. Replace them with the actual values from your provider’s documentation.
4.3 Verify the API Endpoint and Model Name
Endpoints and model names vary significantly between providers. Before connecting, confirm the following in your provider’s documentation:
- Whether the API URL includes a version path, such as
/v1; - The exact spelling and capitalization of the model name;
- Whether the model supports code generation, multi-turn conversation, long context, and tool calling;
- Input and output token limits;
- Rate limits.
If the model name is misspelled, the server typically returns “model not found” or “access denied.” These errors are unrelated to your API key — check the name first.
4.4 Verify the Connection with a Minimal Request
Before launching the tool, send a read-only request with curl to confirm that authentication works. The authentication header must match the protocol.
For Anthropic native or compatible format, use x-api-key and anthropic-version:
curl -sS -o /dev/null -w "%{http_code}\n" \-H "x-api-key: $ANTHROPIC_API_KEY" \-H "anthropic-version: 2023-06-01" \"$ANTHROPIC_BASE_URL/v1/models"
On Windows, use curl.exe, because curl in PowerShell is an alias for Invoke-WebRequest:
curl.exe -sS -o NUL -w "%{http_code}`n" `-H "x-api-key: $env:ANTHROPIC_API_KEY" `-H "anthropic-version: 2023-06-01" `"$env:ANTHROPIC_BASE_URL/v1/models"
For OpenAI-compatible format, use Authorization: Bearer:
curl -sS -o /dev/null -w "%{http_code}\n" \-H "Authorization: Bearer $API_KEY" \"$API_BASE/models"
What the response codes mean:
200: Connection and authentication are working;401: The key is incorrect, expired, or revoked;403: The key is valid but lacks permission for the target model;404: The endpoint path is wrong, or the provider does not offer a/modelsendpoint;429: Rate limit exceeded;5xx: Server-side error — retry later or check the provider’s status page.
Some providers do not offer a /models endpoint. In that case, use the health-check endpoint described in the provider’s documentation, or send a very short message request and confirm it returns 200.
4.5 Configure Proxies and Certificates
If your network requires a proxy to reach external services, set the proxy address:
export HTTPS_PROXY="http://proxy-address:port"
If your corporate network uses a custom root certificate, Node.js-based tools typically need the certificate file specified:
export NODE_EXTRA_CA_CERTS="/path/to/corporate-root-ca.pem"
The proxy address and certificate path should come from your network administrator. If you encounter certificate errors, do not work around them by disabling certificate verification. With verification disabled, both your keys and your code could be exposed through a man-in-the-middle attack.
4.6 Rotate Keys
Rotate keys periodically, or immediately if you suspect a leak. The recommended order is:
- Generate a new key in the console;
- Update your local credential store or environment variables;
- Verify the connection returns
200using the curl command above; - Revoke the old key in the console.
Do not reverse this order. If you revoke the old key first, the tool stops working before verification begins.
5. Set Permission Boundaries
Before first use, define what the tool is allowed to do. The table below shows recommended default policies.
| Operation | Recommended Default | Notes |
|---|---|---|
| Reading project source code | Allow | Limited to the current repository directory |
Reading .env, keys, backup files |
Deny | Exclude in both .gitignore and the tool’s deny rules |
| Modifying files | Confirm each time | Review the diff before approving writes |
| Executing shell commands | Confirm each time | Especially delete, move, and dependency-install commands |
| Installing dependencies or modifying lock files | Confirm each time | Check the source and license of new dependencies |
| Accessing external addresses | Allow only provider domains | Other addresses require separate approval |
| Accessing production environments | Deny | Production operations should be done manually through formal processes |
Three concrete measures help enforce these policies.
First, prefer an approval mode that asks for confirmation on each action. Every write and command request should require your explicit approval before it executes.
