I Want To | Use |
Load only the conventions for the code you touch, rather than a root file overriding every subsystem. | Per-directory CODEBUDDY.md files |
Prevent CodeBuddy from opening build outputs, generated code, and vendor dependencies. | Read deny rule in permissions.deny |
Find symbol definitions or callers through the language server instead of scanning files. | Code intelligence plugin |
When CodeBuddy creates a worktree, check out only the directories required by the task. | worktree.sparsePaths |
Read and edit sibling packages or another repository from the same session. | --add-dir or additionalDirectories |
Provide CodeBuddy with area-specific programs that are loaded only when relevant. | Per-directory Skills |
Replace many per-directory CODEBUDDY.md files with a single set of conventions that everyone installs. | plugin in the internal marketplace |
packages/api/ with your own subsystem directory, such as src/backend/ or lib/core/.monorepo/CODEBUDDY.md # Root instructionspackages/api/CODEBUDDY.md # API-specific instructions.codebuddy/skills/src/web/CODEBUDDY.md # Frontend-specific instructions.codebuddy/skills/src/shared/CODEBUDDY.md # Shared library instructionssrc/
codebuddy determines which files CodeBuddy can read and edit without additional permission grants, which CODEBUDDY.md files are loaded at startup, and which project settings apply.Launch From | File Access | CODEBUDDY.md Loaded at Startup | Scenario |
Repository root directory | Every file | Only the root directory; when CodeBuddy reads there, subdirectory files are loaded on demand. | Tasks span multiple packages or subsystems. |
Subdirectory | Only this subtree until you grant more permissions. | The CODEBUDDY.md in this directory plus that in each ancestor directory | Work scope limited to a single package or subsystem. |
.codebuddy/settings.json are loaded only from your launch directory, not inherited from parent directories like CODEBUDDY.md files: the .codebuddy/settings.json at the repository root applies only when you launch from the root.CODEBUDDY.md: Instructions that apply everywhere, such as coding standards, commit conventions, and repository layoutCODEBUDDY.md: Conventions specific to that area of the stack. In a monorepo, this is one per package. In a large single tree, it is one per subsystem, such as src/db/ or src/api/CODEBUDDY.md directs CodeBuddy to the repository structure:# CODEBUDDY.mdThis is a monorepo with three packages under packages/:- packages/api: A Node.js REST API using Express, TypeScript, and PostgreSQL- packages/web: A React frontend using Vite, TypeScript, and TailwindCSS- packages/shared: Shared TypeScript utilities used by both api and webRun commands from the package directory, not from the monorepo root.Each package has its own tsconfig.json, package.json, and test suite.
CODEBUDDY.md, here packages/api/CODEBUDDY.md, adds context specific to that area of the stack:# packages/api/CODEBUDDY.mdThis package is a REST API server.- Run tests: `npm test` (using Vitest)- Run the development server: `npm run dev` (port 3001)- Database migration: `npm run migrate`- Environment variables: Copy `.env.example` to `.env`API routes are in src/routes/. Each route file exports an Express router.Database queries use Knex in src/db/. Never write raw SQL strings in route handlers.
packages/api/, it loads packages/api/CODEBUDDY.md and the root CODEBUDDY.md. CodeBuddy sees the local instructions alongside the repository-wide rules, with no instructions from packages/web/ in the context. The same applies to any subdirectory in a non-monorepo tree.Stop hook receives the path to the session transcript when CodeBuddy finishes a response, so a script can review the session and propose CODEBUDDY.md updates while the exposed gaps are still fresh.CODEBUDDY.md files and path-scoped rules under .codebuddy/rules/ allow you to target instructions to a part of the tree. They differ in file location and load timing.Methodology | File Location | Load Time | Scenario |
By directory CODEBUDDY.md | Inside the directory, alongside its code | At startup when it is launched from that directory, or on demand when CodeBuddy reads files there. | Directory owners maintain their own conventions; instructions are versioned alongside the code. |
Path-scoped rules in .codebuddy/rules/ | Central .codebuddy/ at the repository root | When CodeBuddy processes files that match the rule's paths: glob | You want all conventions in one place, or the same rules apply to many scattered paths. |
.gitignore by default, so paths already listed there, such as node_modules/, dist/, and build/, stay out of search results without additional configuration.Read deny rule in permissions.deny to prevent CodeBuddy from opening these files even if search lists them..codebuddy/settings.json. To keep them personal, use .codebuddy/settings.local.json instead. Like other project settings on this page, these files are loaded only from your launch directory. Place them at the repository root if you launch CodeBuddy from there, or in each package's .codebuddy/ if you launch from a subdirectory.// .codebuddy/settings.json{"permissions": {"deny": ["Read(./**/dist/**)","Read(./**/build/**)","Read(./**/*.generated.*)","Read(./vendor/**)"]}}
cat, head, grep, and find, when a denied path is passed as an argument. They do not filter denied paths from recursive search output, nor do they cover arbitrary subprocesses that open files on their own. For the complete pattern syntax, see Read and Edit permission rules./plugin install typescript-lsp@claude-plugins-official
enabledPlugins project setting.Read deny rule above. The deny rule keeps irrelevant content out of the context, and code intelligence keeps CodeBuddy from reading the rest to locate definitions.--worktree flag starts a session in a new git worktree so that changes are isolated from the main checkout. By default, it checks out the entire repository. In large repositories, the worktree.sparsePaths setting uses git sparse-checkout to write only the listed directories plus root-level files to disk, so that worktrees start faster and use less space..codebuddy/settings.json. To add paths for yourself, use .codebuddy/settings.local.json: the lists are merged by scope, so the local file can add paths to the committed list but cannot remove them. The following example shows the committed file:// .codebuddy/settings.json{"worktree": {"sparsePaths": [".codebuddy","packages/api","packages/shared"]}}
.codebuddy/, packages/api/, and packages/shared/ instead of the full tree. Paths in sparsePaths are relative to the repository root, regardless of which subdirectory you start CodeBuddy from. Any directory path works here, not just package roots.sparsePaths, so if one subagent needs packages/api/ and another needs packages/web/, list both.sparsePaths, not individual files. Root-level files such as package.json, tsconfig.base.json, and lock files are always checked out along with the directories you list. Root-level directories are not, so if you want .codebuddy/settings.json, .codebuddy/rules/, or .codebuddy/skills/ from the repository root to be available inside the worktree, include .codebuddy in the list.node_modules in worktrees, pair sparsePaths with symlinkDirectories in the same .codebuddy/settings.json:// .codebuddy/settings.json{"worktree": {"sparsePaths": [".codebuddy","packages/api","packages/shared"],"symlinkDirectories": ["node_modules"]}}
node_modules/ back to the main repository copy instead of duplicating it on disk.sparsePaths and symlinkDirectories settings are read from your launch directory before the worktree is created. After creation, the session's working directory is the worktree root, not the subdirectory you launched from. Therefore, project settings within the worktree are loaded from .codebuddy/settings.json at the worktree root, which is a checked-out copy of the repository root file. Place any other settings you need inside worktrees, such as permission rules or hooks, in .codebuddy/settings.json at the repository root.packages/api/, it can read and write files within that directory. If a task requires cross-package changes, such as updating shared types that both api and web import, you need to grant access to sibling directories. The same mechanism grants access to separately checked-out repositories.additionalDirectories setting in .codebuddy/settings.json gives CodeBuddy access to directories outside the working directory. The following example grants access to two sibling packages:// .codebuddy/settings.json{"permissions": {"additionalDirectories": ["../shared","../web"]}}
packages/shared/ and packages/web/ when working from packages/api/.--add-dir when starting CodeBuddy:codebuddy --add-dir ../shared
.codebuddy/rules/ files, and skills are also loaded depends on how you add it:Adding Method | Loading CODEBUDDY.md and Rules | Loading skills |
additionalDirectories setting | Never | Never |
--add-dir flag or /add-dir command | Use Only the Environment Variables Below. | Yes |
--add-dir or /add-dir, set the CODEBUDDY_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD environment variable:CODEBUDDY_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 codebuddy --add-dir ../shared
additionalDirectories setting. For details, see Memory.additionalDirectories to .codebuddy/settings.json. For personal preferences or one-off access, use .codebuddy/settings.local.json or pass --add-dir at startup..codebuddy/skills/ within a directory. Commit them alongside the code for that area so that anyone who clones the repository gets them. In a monorepo, this can be one set of skills per package. In a large single-tree repository, it is one set per subsystem, such as src/db/.codebuddy/skills/.mkdir -p packages/api/.codebuddy/skills/api-testing
SKILL.md in that directory, which is packages/api/.codebuddy/skills/api-testing/SKILL.md. This example teaches CodeBuddy the testing patterns for the API package:---name: api-testingdescription: Testing patterns for the API package. Use when writing or modifying tests in packages/api/.---## Test StructureTests live in `src/__tests__/`, mirroring the `src/` directory structure.Each route file has a corresponding `.test.ts` file.## Run Tests- All tests: `npm test`- Single file: `npm test -- src/__tests__/routes/users.test.ts`- Watch mode: `npm test -- --watch`## Test Utilities- `src/__tests__/helpers/db.ts`: Provides `setupTestDb()` and `teardownTestDb()` for database testing.- `src/__tests__/helpers/auth.ts`: Provides `createTestUser()` and `getAuthToken()` for authentication endpoints.## Modes- Use `supertest` for HTTP assertions instead of raw fetch.- Always wrap database tests in a transaction that rolls back.- Mock external services in `src/__tests__/mocks/`.
packages/web/.codebuddy/skills/component-patterns/ describes frontend component conventions rather than testing. When CodeBuddy processes files in packages/api/, it loads the api-testing skill. When it works in packages/web/, it loads component-patterns instead. During another task, the skills from both directories are not loaded.paths frontmatter field accepts glob patterns, and CodeBuddy automatically loads the skill only when processing matching files. Use this feature for skills that reside in .codebuddy/skills/ at the repository root but apply only to certain files, regardless of where they appear, such as a database migration skill scoped to /migrations/.packages/api/: skills from that directory, every parent directory up to the repository root, and the user leveladditionalDirectories setting only grants file access and does not load skills.packages/api/"..codebuddy/skills/ at the repository root so that they can be loaded from any launch directory. When shared skills need their own version history or must work across repositories, package them as plugins instead. Plugin skills use the plugin-name:skill-name namespace, so they never conflict with directory-based skills. Platform teams can version and update them in one place..codebuddy/settings.json in each subdirectory must be self-contained rather than layered on top of the root file.worktree, additionalDirectories, and Read deny rules in .codebuddy/settings.json so that every developer in packages/api/ gets the same sibling access, sparse paths, and exclusions. The following file is the committed per-area settings for packages/api/:// packages/api/.codebuddy/settings.json{"worktree": {"sparsePaths": [".codebuddy","packages/api","packages/shared"],"symlinkDirectories": ["node_modules"]},"permissions": {"additionalDirectories": ["../shared"],"deny": ["Read(./**/dist/**)","Read(./**/build/**)"]}}
packages/api/, the CODEBUDDY.md files of sibling packages are already out of scope. If you also launch sessions from the repository root, add the exclusion rules to .codebuddy/settings.local.json at the repository root.additionalDirectories entries apply when you launch CodeBuddy directly from packages/api/. Inside a worktree created from this session, the working directory is the worktree root, so this settings file is not loaded. Sibling packages are already reachable within the worktree without it, but the deny rules need a second copy in .codebuddy/settings.json at the repository root so that worktree sessions can obtain them, as described in the worktree settings note:// .codebuddy/settings.json{"permissions": {"deny": ["Read(./**/dist/**)","Read(./**/build/**)"]}}
monorepo/CODEBUDDY.md.codebuddy/settings.json # Deny rules for worktree sessionspackages/api/CODEBUDDY.md.codebuddy/settings.json # worktree, additionalDirectories, and deny rules.codebuddy/skills/api-testing/SKILL.mdweb/CODEBUDDY.md.codebuddy/skills/component-patterns/SKILL.mdshared/CODEBUDDY.md
packages/api/:packages/api/CODEBUDDY.md, and skip packages/web/CODEBUDDY.md.packages/api/ and packages/shared/.dist/ and build/ in packages/api/..codebuddy/, packages/api/, packages/shared/, and root-level files, and apply the deny rules from the root settings file to the entire worktree.Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback