Lesson 2: Claude Code Configuration Hierarchy
·System Governance

Lesson 2: Claude Code Configuration Hierarchy

Master the governance of your AI agent. Learn how to manage global settings, repository-specific rules, and scoped behaviors to ensure Claude Code adheres to your company's unique engineering standards.


Module 6: Claude Code Configuration and Workflows

Lesson 2: Configuration Hierarchy

As an Architect, you don't want every developer on your team to have an agent that behaves differently. You want Standardization. Claude Code uses a Hierarchical Configuration system that allows you to define rules from the "Whole Machine" down to a "Specific Folder."

In this lesson, we master the three levels of configuration and learn the "Conflict Resolution" logic of the CLI.


1. Level 1: Global Configuration

Stored in the user's home directory (e.g., ~/.claude/config.json), these settings apply to every task on the machine.

  • Typical Settings: Use of specific models (defaulting to Sonnet), theme settings, and global "Ignore" patterns.
  • Architect's Strategy: Use this for "Personal Productivity" settings, but avoid placing project-specific rules here.

2. Level 2: Repository-Level Configuration

This is where the magic happens. By using a .claudecode.json or .clauderc file in the root of your project, you define how Claude should behave for that specific codebase.

  • Typical Settings: "Always use Tab for indentation," "Never delete files in the /production folder," or "Always run npm test after a change."
  • Architect's Strategy: Commit this file to Git. This ensures that everyone who clones the repo has an agent that follows the same house rules.

3. Level 3: Scoped Rules (Folder/File level)

You can define rules that only apply when Claude is working in a specific part of the repo.

  • Example: "When in /server, use Node.js patterns. When in /client, use React and Tailwind patterns."

4. Conflict Resolution (The "Last-One-Wins" Logic)

When a rule is defined at multiple levels, the Most Specific rule wins.

  • Global: "Use 2 spaces."
  • Repo: "Use 4 spaces."
  • Result: Claude will use 4 spaces inside that repo.

5. Visualizing the Hierarchy

graph TD
    A[Global Config] --> B[Repo-Level Config]
    B --> C[Scoped Rules]
    C --> D[Active Agent Behavior]
    Note right of D: Most specific rule wins

6. Summary

  • Global is for the user.
  • Repo is for the project (Commit to Git!).
  • Scoped is for specialized sub-sections of code.

In the next lesson, we will look at the most powerful tool for repo-level governance: CLAUDE.md.


Interactive Quiz

  1. Where should you store "Indentation Rules" that your whole team should follow?
  2. What happens if a Global rule and a Repo rule conflict?
  3. Why is it important to commit .claudecode.json to your repository?
  4. Setup a hypothetical scenario: You have a Python backend and a Go frontend. How would you configure Claude Code to use the correct PEP-8 linting for Python and gofmt for Go using the hierarchy?

Reference Video:

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn