Skip to main content
This lesson explains how Claude Code manages environment and configuration: where settings live, how scoping works (user vs project vs enterprise), how to create a project “memory” file with CLAUDE.md, and the CLI commands to inspect or change configuration. Follow these guidelines to keep Claude Code predictable, secure, and team-friendly.
A presentation slide titled "Environment and Configuration Management" with the word "Demo" displayed prominently on a dark curved background. A small "© Copyright KodeKloud" appears in the bottom-left corner.
Overview
  • Claude Code uses a combination of configuration files and CLI settings to control permissions, environment variables, telemetry, UI preferences, and other behaviors.
  • Settings are applied at three scopes:
    • User-level: personal settings on a developer’s machine.
    • Project-level: repository-scoped settings stored under a .claude folder and shared with the team.
    • Enterprise-managed: centrally applied, organization-wide managed settings.
Table: Configuration scopes at a glance Welcome message (what you see when you start Claude Code in a repo)
User-level settings
  • Location (typical):
    • macOS / Linux: ~/.claude/settings.json
    • Windows: C:\ProgramData\claude-code\settings.json (or similar under ProgramData)
  • These files control your personal defaults (theme, model selection, telemetry opt-ins, etc.). If you use an editor alias (e.g., code for VS Code) and it’s not available, the CLI will fall back to another editor like vim.
Example: attempting to open the user settings in VS Code when the code alias is missing
Project-level settings
  • Use .claude/settings.json at the repository root for team-shared defaults and permissions. This file is version-controlled so the whole team receives the same base configuration.
  • For per-developer preferences that should not be checked in, use .claude/settings.local.json. Claude Code will add this file to .gitignore when present.
Example: project-level settings.json (valid JSON)
Example: per-developer settings.local.json (ignored by git)
Enterprise-managed settings
  • Organizations can enforce managed settings which are applied system-wide. These settings typically live in OS-specific paths:
Expanded enterprise settings example (permissions, defaultMode, additional directories)
Enterprise managed settings can override local or project settings in certain areas. If you rely on specific environment variables or permission behavior, confirm with your administrator before assuming local overrides will apply.
Reference documentation The CLAUDE.md “memory” file
  • CLAUDE.md is a per-project file that Claude Code loads into memory at startup. Use it to provide context, development commands, testing instructions, linting/formatting guidance, and anything that helps the assistant act like a project-aware collaborator.
  • You can create CLAUDE.md with the /init command or author it manually.
Example CLAUDE.md for a Python Flask application (this is the file content — you can create it with /init or ask Claude to generate it):
Keep CLAUDE.md concise and focused: include the commands you want Claude to run, important file locations, test instructions, and any known quirks. This improves the assistant’s relevance and reduces noisy suggestions.
Notes about CLAUDE.md
  • Claude loads CLAUDE.md for every session, so include things that help the assistant act immediately (build steps, test commands, primary entry points).
  • Avoid embedding secrets in CLAUDE.md. Use it for developer-friendly context and commands only.
Common configuration options and UI preferences
  • Common toggles and preferences you may find in user or project settings:
    • to-do list visibility
    • checkpointing (useful for reverting assistant-proposed edits)
    • verbose output / logging
    • model selection and safety settings
    • theme (dark/light) and Vim mode
    • diff tool preference and auto-install IDE extension
  • Checkpointing is particularly useful when Claude proposes multi-file edits—if a proposed change breaks the build, you can quickly revert to a previous state.
Protecting sensitive files
  • Use deny patterns to prevent Claude Code from reading secrets, build artifacts, or any directory you want protected. For example:
Explicitly deny access to any files containing secrets or credentials. Do not rely solely on .gitignore—deny patterns prevent the assistant from reading files even if they exist in the repo.
Using the claude CLI
  • The claude CLI lists, gets, and sets configuration at local or global levels. It’s useful for scripting or quick inspection of current settings.
Example: a runtime error when OpenTelemetry environment variables are misconfigured
If the CLI is functional, claude config list returns a JSON object with current config:
Set and get config values
  • Set a global config (affects all projects on the machine):
  • Read a specific key:
Tip: If you run claude config set without a value, the CLI will prompt you. To avoid prompts, always provide the key and value on the command line, for example:
Putting it together — typical project config and workflow
  • Recommended workflow:
    1. Create .claude/settings.json with team defaults and permission rules.
    2. Add .claude/settings.local.json per-developer for local preferences; do not check this in.
    3. Author CLAUDE.md with project context, dev commands, and test instructions.
    4. Use claude config to inspect or adjust local/global CLI behavior as needed.
Example final checklist for a Python project (commands you can add to CLAUDE.md or run locally):
This configuration pattern helps Claude Code operate safely and predictably across different machines and teams while preserving developer autonomy for local preferences. Links and references

Watch Video

Practice Lab