Skip to content

LearnTutorials

Navigate a large codebase with Claude Code

Set up Claude Code for a big repo or monorepo in 25 minutes, with folder CLAUDE.md files, a code intelligence plugin and rules that skip generated code.

By Recaply EditorsIntermediate25 min6 stepsUpdated

A hand shines a flashlight into a large tangled ball of yarn

What you need

  1. Step 1: Start Claude in the folder you work in

    3 min

    Where you launch Claude decides which CLAUDE.md files load and which files it can edit.

    1. In a terminal, cd into the package or subsystem you work on, such as packages/api.
    2. Run claude, then type /init at its prompt.
    3. Read the CLAUDE.md it writes, and delete anything Claude could work out from the code.

    You should see a new CLAUDE.md in that folder, with its build and test commands.

    /init didn't make a new file?

    A CLAUDE.md is already there, so /init suggests improvements instead of overwriting it. Accept the ones that help.

    Started from a subfolder, Claude can edit only that part of the repo until you grant it more.

  2. Step 2: Keep the root file for rules that apply everywhere

    4 min

    The root CLAUDE.md loads in every session, so each extra line costs attention on every task.

    1. Open CLAUDE.md at the repository root.
    2. Keep rules that hold in every folder: commit style, generated files and things never to touch.
    3. Delete folder maps and architecture notes. Claude reads the repo itself, and Anthropic's docs now list that habit as old advice.
    Your root CLAUDE.md
    # Rules for every folder
    - Run scripts from the folder you changed, not the repo root.
    - Start commit subjects with the folder name, like `api: fix login timeout`.
    - Never edit files in [GENERATED FOLDER]. Run [CODEGEN COMMAND] instead.

    You should see a root file of a few lines, far under the 200 lines Anthropic suggests as a limit.

    Claude keeps ignoring a rule in the file?

    The file is probably too long, so the line gets lost. Cut it down. A rule that must never bend belongs in a hook or a deny rule.

  3. Step 3: Give each folder its own commands

    5 min

    A folder's CLAUDE.md loads only when Claude works there, so it runs that folder's tests instead of the whole suite.

    1. Add a CLAUDE.md to each busy folder, such as packages/web/CLAUDE.md.
    2. List how to test one file, run the folder's tests and lint, as in the example.
    3. Start a session in that folder, run /context all and check the list under Memory files.
    Your folder CLAUDE.md
    # packages/api
    - Test one file: npm test -- [PATH TO TEST FILE]
    - All API tests: npm test
    - Lint: npm run lint
    - Copy .env.example to .env before you run tests.

    You should see the root CLAUDE.md and your folder's file under Memory files, and none from other folders.

    Other teams' CLAUDE.md files keep loading?

    Add their paths to claudeMdExcludes in .claude/settings.local.json, such as "/packages/web/". Or start Claude from your own folder.

  4. Step 4: Install a code intelligence plugin

    6 min

    A language server lets Claude find a function's definition and callers by symbol, instead of reading file after file.

    1. Install your language's server first. For TypeScript, run the first line below in your terminal.
    2. Start claude and run the /plugin install line at its prompt.
    3. Other languages have their own plugin, such as pyright-lsp for Python or gopls-lsp for Go.
    Run these, the second one inside Claude Code
    npm install -g typescript-language-server typescript
    /plugin install typescript-lsp@claude-plugins-official

    You should see a message that the plugin is active, or that you need to run /reload-plugins first.

    It says the marketplace wasn't found?

    Add it with /plugin marketplace add anthropics/claude-plugins-official, then run the install again.

    Code intelligence works in terminal sessions. Cloud sessions don't start plugin language servers.

  5. Step 5: Block generated and vendored code

    3 min

    Deny rules stop Claude from opening big files that were never meant to be read.

    1. Open .claude/settings.json in the folder you start Claude from, or create it.
    2. Add the rules below, and change the paths to match your build folders.
    3. Commit the file so your whole team gets the same rules.
    Your config
    {
      "permissions": {
        "deny": [
          "Read(./**/dist/**/*)",
          "Read(./**/build/**/*)",
          "Read(./**/*.generated.*)",
          "Read(./**/vendor/**/*)"
        ]
      }
    }

    You should see your 4 new rules listed in /permissions, with the settings file each one came from.

    Claude still reads files in a denied folder?

    Rules that start with ./ count from the folder you launched in. If you launch from different folders, write full paths that start with //.

    Paths in .gitignore, like node_modules/, already stay out of Claude's searches.

  6. Step 6: Test it on a real call path

    4 min

    One trace across folders shows whether the setup works before you rely on it.

    1. Paste the prompt below, with a real function name from your code.
    2. Watch which files Claude opens. Each one should sit on the path you asked about.
    Your prompt
    Trace how [FUNCTION NAME] gets called, from the entry point down to where it does its work. Use the language server to find references. List each file and line in order. Don't edit anything.

    You should see a short, ordered list of files and lines, with no detours through build output.

    Claude still searches file by file?

    Run /plugin and open the Errors tab. A row reading Executable not found in $PATH names the language server to install.

You get

A large codebase where Claude loads only the rules it needs, finds code by symbol and skips generated files

Did this guide work for you?

Sources