Tired of configuring Claude Code by hand? We got you covered While Claude code is a terminal CLI, it surprisingly took me some time to automate the configuration. Sharing my experiences here as it can be useful for people scripting it on CI/CD systems or other scripts. Note: I’ll be using the linux commands and syntax here The recommended Installation is easy: npm install -g @anthropic-ai/claude-code npm install -g @anthropic-ai/claude-code This installs the claude command globally. Now the fun can begin! claude Claude Max or API Key setup As part of the manual setup you need to choose between a Claude Max subscription or the Claude API. For both it starts an OAuth flow which is not easy to automate regardless of if you have the ANTHROPIC_API_KEY configured in your shell. ANTHROPIC_API_KEY Through this Reddit post I came across the use of an ApiKeyHelper which allows Claude Code to get the keys from a script. We simply have it output the env var of our existing API Key. We’ll configure this script further in the settings. this Reddit post ################################## # Setup API helper ################################## echo 'echo ${ANTHROPIC_API_KEY}' > /home/node/.claude/anthropic_key_helper.sh chmod +x /home/node/.claude/anthropic_key_helper.sh ################################## # Setup API helper ################################## echo 'echo ${ANTHROPIC_API_KEY}' > /home/node/.claude/anthropic_key_helper.sh chmod +x /home/node/.claude/anthropic_key_helper.sh Claude config vs settings.json The CLI has a simple claude config command, which manages things into ~/.claude/claude.json. I found it to be a bit buggy at times and it seems the team is deprecating this command anyway. claude config ~/.claude/claude.json it seems the team is deprecating this command anyway Therefore we write a skeleton to ~/.claude.json ourselves: ~/.claude.json shiftEnterKeyBindingInstalled configures the ask for terminal installhasCompletedOnboarding indicates configuration is doneset the theme to dark here shiftEnterKeyBindingInstalled configures the ask for terminal install shiftEnterKeyBindingInstalled hasCompletedOnboarding indicates configuration is done hasCompletedOnboarding set the theme to dark here We also configure the trust of our API key, the syntax seems to be the last 20 characters of your API_KEY ANTHROPIC_API_KEY_LAST_20_CHARS=${ANTHROPIC_API_KEY: -20} # We write the global config to ~/.claude.json # Warning this overwrites your existing cat < ~/.claude.json { "customApiKeyResponses": { "approved": [ "$ANTHROPIC_API_KEY_LAST_20_CHARS"], "rejected": [ ] }, "shiftEnterKeyBindingInstalled": true, "theme": "dark" , "hasCompletedOnboarding": true } EOM ANTHROPIC_API_KEY_LAST_20_CHARS=${ANTHROPIC_API_KEY: -20} # We write the global config to ~/.claude.json # Warning this overwrites your existing cat < ~/.claude.json { "customApiKeyResponses": { "approved": [ "$ANTHROPIC_API_KEY_LAST_20_CHARS"], "rejected": [ ] }, "shiftEnterKeyBindingInstalled": true, "theme": "dark" , "hasCompletedOnboarding": true } EOM Now we can configure the API Key Helper we set up earlier. We do this after the skeleton otherwise it would be overwritten. claude config set --global apiKeyHelper ~/.claude/anthropic_key_helper.sh claude config set --global apiKeyHelper ~/.claude/anthropic_key_helper.sh Trust & Onboarding The next step is to get rid of the ask if we want to trust Claude Code on the current directory and also avoid having the onboarding wizard popup: claude config set hasTrustDialogAccepted true claude config set hasTrustDialogAccepted true claude config set hasCompletedProjectOnboarding true claude config set hasCompletedProjectOnboarding true Setting up MCP servers Claude Code has good support for MCP, now even for remote MCP servers. good support for MCP remote MCP servers. The example mostly show the use of claude mcp add claude mcp add I tend to use the add-json option as it makes things a lot more configurable. Also I tend to run the npx install or docker pull before adding the mcp server because there is no progress output when Claude runs it for you. add-json npx install docker pull Also note that the file ~/.claude/claude.json now may contain sensitive secrets. Make sure to set the right permissions if you are on a shared system. ~/.claude/claude.json Here’s an example of installing the mcp puppeteer container: docker pull mcp/puppeteer docker pull mcp/puppeteer # example that generates the config into the MCP_JSON var read -r -d '' MCP_JSON <<'EOF' { "command": "docker", "args": ["run", "-i", "--rm", "--init", "-e", "DOCKER_CONTAINER=true", "mcp/puppeteer"] } EOF # then add it claude mcp add-json puppeteer "$MCP_JSON" # listing the server claude mcp list # example that generates the config into the MCP_JSON var read -r -d '' MCP_JSON <<'EOF' { "command": "docker", "args": ["run", "-i", "--rm", "--init", "-e", "DOCKER_CONTAINER=true", "mcp/puppeteer"] } EOF # then add it claude mcp add-json puppeteer "$MCP_JSON" # listing the server claude mcp list Setting permissions When the Claude Code agent is running, it by default asks you if you approve various commands and if you want to save the decision. This is how you can set up the permissions for different tools. Note that mcp servers use the mcp__ prefix for it. set up the permissions claude config add allowedTools "Edit,Bash" claude config add allowedTools "Edit,Bash" claude config add allowedTools "mcp__puppeteer" claude config add allowedTools "mcp__puppeteer" Claude VScode Extension Claude Code has a VSCode extension that you can install in your favorite IDE. It is not available through the regular VSCode extension marketplace but is part of the npm install of the package. We can manually install it after we’ve downloaded it. Note that this will not work in devcontainer postCreate, it needs to be executed inside a terminal. I set it up in a .bashrc that gets executed on first shell execution. ################################# # set the IDE code for `vscode` , `cursor` for cursor IDE_CMD=cursor # Do this in a tempdir tempdir=$(mktemp -d) cd $tempdir # downloads the package npm pack @anthropic-ai/claude-code tar -xzvf anthropic-ai-claude-code-*.tgz # Install the extension # requires a reload of the editor $IDE_CMD --install-extension package/vendor/claude-code.vsix ################################# # set the IDE code for `vscode` , `cursor` for cursor IDE_CMD=cursor # Do this in a tempdir tempdir=$(mktemp -d) cd $tempdir # downloads the package npm pack @anthropic-ai/claude-code tar -xzvf anthropic-ai-claude-code-*.tgz # Install the extension # requires a reload of the editor $IDE_CMD --install-extension package/vendor/claude-code.vsix Interesting (undocumented settings) I’m sure there are many but as Claude Code is not opensource it’s hard to guess. The most interesting I found was parallelTasksCount that seems to control the number of subtasks Claude Code works on, helpful if you want to unleash even more power. Have you discovered others? Let us know! found claude config set --global parallelTasksCount 3 claude config set --global parallelTasksCount 3 Handy env vars And finally Claude Code has a lot of environment variables you can configure. Here’s the most interesting for setting up a build environment, like setting timeouts and disabling telemetry. Claude Code has a lot of environment variables # enable debug logging # export ANTHROPIC_LOG=debug # disable non-essential traffic and disable telemetry! # - Equivalent of setting DISABLE_AUTOUPDATER, DISABLE_BUG_COMMAND, DISABLE_ERROR_REPORTING, and DISABLE_TELEMETRY # export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=true # define frequency of api helper refresh # CLAUDE_CODE_API_KEY_HELPER_TTL_MS # set/increase the bash timeout for longer commands # BASH_DEFAULT_TIMEOUT_MS # set the mcp timeout # MCP_TIMEOUT # enable debug logging # export ANTHROPIC_LOG=debug # disable non-essential traffic and disable telemetry! # - Equivalent of setting DISABLE_AUTOUPDATER, DISABLE_BUG_COMMAND, DISABLE_ERROR_REPORTING, and DISABLE_TELEMETRY # export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=true # define frequency of api helper refresh # CLAUDE_CODE_API_KEY_HELPER_TTL_MS # set/increase the bash timeout for longer commands # BASH_DEFAULT_TIMEOUT_MS # set the mcp timeout # MCP_TIMEOUT Pfffew - DevOps Experience Setting up Claude Code feels a bit like being the first DevOps on Mars. While everyone’s raving about agentic UX, some of us are just trying to get it to work in CI. Hopefully this guide saves you a few hours. Feel free to fork my claude_code_init script gist and share your setup tips! claude_code_init script gist