.codebuddy Directory Structure β
A deep dive into the files and subdirectories under CodeBuddy Code's configuration directory
~/.codebuddyand the project-level.codebuddydirectory.
CodeBuddy Code uses two configuration directories:
- Global directory
~/.codebuddy/: stores user-level configuration, history, runtime data, etc., affecting all projects - Project directory
.codebuddy/(located at the project root): stores project-level configuration, rules, skills, commands, etc., shared with the team via version control
Global Directory ~/.codebuddy/ β
~/.codebuddy/
βββ settings.json # User-level global configuration
βββ settings.local.json # Local personal preferences (not shared)
βββ CODEBUDDY.md # User-level memory file
βββ mcp.json # Global MCP server configuration
βββ statusline-command.sh # Custom status line script (optional)
β
βββ agents/ # User-level custom sub-agents (available to all projects)
βββ rules/ # User-level rule files (available to all projects)
βββ skills/ # User-level skills (available to all projects)
β
βββ projects/ # Per-project session and sub-agent runtime data
βββ sessions/ # Session data
βββ plans/ # Plans generated in plan mode
β
βββ logs/ # Runtime logs
βββ traces/ # Execution trace data (OpenTelemetry)
βββ file-history/ # File change history
βββ history.jsonl # Conversation history
βββ blobs/ # Binary assets (images, screenshots, etc.)
βββ tasks/ # Task tracking data
βββ teams/ # Agent team runtime data
βββ shell-snapshots/ # Bash sandbox snapshots
β
βββ plugins/ # Installed plugins
βββ local_storage/ # CLI key-value persistent storage
βββ channels/ # Channel configuration (WeChat, etc.)
β
βββ computer-use/ # Computer Use feature records
βββ debug/ # Debug information
βββ usage-data/ # Usage statisticsCore Configuration Files β
settings.json β
User-level global configuration that applies to all projects. Manage it via the /config command or by editing it directly.
json
{
"language": "English",
"model": "gpt-5",
"reasoningEffort": "high",
"permissions": {
"defaultMode": "default",
"allow": ["Bash(git:*)"],
"deny": ["Read(./.env)", "Read(./secrets/**)"]
},
"env": {
"NODE_ENV": "development"
},
"memory": {
"autoMemoryEnabled": true,
"typedMemory": true
},
"trustedDirectories": ["~/workspace/myproject"]
}For the full list of configuration fields, see Settings.
settings.local.json β
Local personal configuration. CodeBuddy Code does not auto-sync or share this file; it is suitable for storing overrides that only apply to the local machine (such as API keys, debug toggles, etc.).
CODEBUDDY.md β
User-level memory file that takes effect across all projects. Suitable for personal coding preferences, common workflow notes, etc.
markdown
## Tool Preferences
- Use pnpm instead of npm
- Prefer functional programming style
## Code Style
- Use 2-space indentationSee Memory Management for details.
mcp.json β
Global MCP server configuration. Same format as the project-level .mcp.json:
json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
}
}
}See MCP Documentation for details.
User-Level Extension Directories β
agents/ β
Stores user-level custom sub-agents that take effect across all projects. Each agent is a single .md file:
~/.codebuddy/agents/
βββ code-reviewer.md # Code review agent
βββ translator.md # Translation agentFile format (YAML frontmatter + system prompt):
markdown
---
name: code-reviewer
description: Code review expert; use proactively after writing code
tools: Read, Grep, Glob, Bash
model: inherit
---
You are a senior code reviewer focused on code quality, security, and best practices...See Sub-Agent Documentation for details.
rules/ β
Stores user-level rule files that take effect across all projects. All .md files are loaded automatically; subdirectories are supported:
~/.codebuddy/rules/
βββ preferences.md # Personal coding preferences
βββ workflows.md # Common workflow conventionsRule files support frontmatter to control loading behavior:
markdown
---
alwaysApply: false
paths: src/**/*.ts
---
# TypeScript Conventions
- Prefer `interface` over `type`
- Disallow `any`See Memory Management - Rule System for details.
skills/ β
Stores user-level skills that take effect across all projects. Each skill is a self-contained directory containing a SKILL.md:
~/.codebuddy/skills/
βββ pdf/
βββ SKILL.mdSee Skills Documentation for details.
Runtime Data Directories β
These directories are maintained automatically by CodeBuddy Code and typically do not require manual operation:
| Directory | Description |
|---|---|
projects/ | Per-project runtime data, including session records (.jsonl) and sub-agent tool output (tool-results/) |
sessions/ | Active session data |
plans/ | Plan files generated in plan mode |
logs/ | Runtime logs grouped by date and process |
traces/ | OpenTelemetry execution trace data |
file-history/ | Snapshots of files operated on within each session, used by /rewind |
history.jsonl | Global conversation history (used by /resume) |
blobs/ | Binary resources such as images and screenshots, stored by content hash |
tasks/ | Task management system data (TaskCreate/TaskUpdate) |
teams/ | Agent team (TeamCreate) runtime data |
shell-snapshots/ | Bash sandbox startup snapshots that speed up sandbox creation |
plugins/ | File contents of installed plugins |
local_storage/ | CLI internal key-value persistent storage (.info files named by content hash) |
Project Directory .codebuddy/ β
Located at the project root and intended to be committed to version control so the team can share it:
.codebuddy/
βββ settings.json # Project shared configuration
βββ settings.local.json # Local personal configuration (auto-ignored by .gitignore)
βββ CODEBUDDY.md # Project-level memory file
β
βββ agents/ # Project-level custom sub-agents
βββ rules/ # Project-level rule files
βββ skills/ # Project-level skills
βββ commands/ # Custom slash commandsConfiguration Files β
settings.json β
Project shared configuration synced with the team via version control. Suitable for setting team-wide model, permission rules, plugins, and so on:
json
{
"permissions": {
"allow": ["Read", "Edit", "Bash(git:*)", "Bash(npm:*)"],
"deny": ["Read(./.env)", "Read(./secrets/**)"]
},
"enabledPlugins": {
"pr-review-toolkit@company-tools": true
},
"extraKnownMarketplaces": {
"company-tools": {
"source": {
"source": "github",
"repo": "myorg/codebuddy-plugins"
}
}
}
}settings.local.json β
Local personal configuration. CodeBuddy Code automatically adds it to .gitignore. Suitable for personal overrides (such as local debug ports or personal keys) that should not affect other team members.
CODEBUDDY.md β
Project-level memory file shared via version control. Stores team knowledge such as project architecture, conventions, and common commands:
markdown
# Project Overview
This project is a TypeScript monorepo (Yarn workspaces).
## Common Commands
- `yarn build` β build all packages
- `yarn test` β run all tests
## Architectural Conventions
- Uses the CellJS dependency injection framework
- Protocol definitions live in `*-protocol.ts` filesTip: You can also place the memory file at the project root as
CODEBUDDY.md(outside the.codebuddy/directory). Both locations are equivalent.
Project-Level Extension Directories β
agents/ β
Stores project-specific sub-agents, which take precedence over user-level agents. When names collide, the project-level agent overrides the user-level one.
.codebuddy/agents/
βββ blog-translator.md # Blog translation agent
βββ docs-reviewer.md # Documentation review agentrules/ β
Stores project-level rules shared via version control. Suitable for team-wide code conventions, workflow agreements, etc. Subdirectories are supported:
.codebuddy/rules/
βββ code-style.md # Code style conventions
βββ testing.md # Testing conventions
βββ security.md # Security requirements
βββ frontend/
βββ react.md # React component conventions
βββ styles.md # Styling conventionsAll .md files are recursively loaded automatically.
skills/ β
Stores project-level skills. Each skill is its own directory containing a SKILL.md and optional supporting files:
.codebuddy/skills/
βββ case-executor/
β βββ SKILL.md # Skill definition
β βββ scripts/ # Helper scripts
β βββ references/ # Reference materials
βββ cnb-api/
βββ SKILL.mdSKILL.md format:
markdown
---
name: case-executor
description: Executes JSON test cases and generates reports
allowed-tools: Read, Write, Bash
---
You are a test execution expert responsible for running UI test cases in JSON format...See Skills Documentation for details.
commands/ β
Stores custom slash commands invoked via /command-name. Nested directories are supported (invoked using /group:command):
.codebuddy/commands/
βββ deploy.md # /deploy command
βββ team/
β βββ issue-start.md # /team:issue-start command
β βββ create-issue.md # /team:create-issue command
βββ openspec/
βββ propose.md # /openspec:propose commandCommand file format:
markdown
---
description: Create a new Issue
argument-hint: "<description> ; <type> ; <product>"
allowed-tools: Bash
---
Create an Issue based on the following description: $ARGUMENTSSee Slash Command Documentation for details.
Configuration Priority β
Multi-layer configuration is applied with the following priority (higher priority overrides lower priority):
Command-line arguments (highest priority)
β
.codebuddy/settings.local.json (project local, not committed)
β
.codebuddy/settings.json (project shared, team-wide)
β
~/.codebuddy/settings.json (user global, personal preferences)
β
Built-in product defaults (lowest priority)Priority for agents/skills/rules: project-level > user-level > plugin-level. When names collide, the project level wins.
Memory Loading Order β
1. User-level memory: ~/.codebuddy/CODEBUDDY.md
2. User-level rules: ~/.codebuddy/rules/*.md (recursive)
3. Project-level memory: CODEBUDDY.md (searched recursively upward from cwd)
4. Project-level rules: .codebuddy/rules/*.md (cwd only, no upward search)
5. Project local memory: CODEBUDDY.local.md
6. Subdirectory memory: dynamically loaded `CODEBUDDY.md` from a subdirectory when tools operate on files thereVersion Control Recommendations β
| File / Directory | Commit to VCS | Notes |
|---|---|---|
.codebuddy/settings.json | β Recommended | Team shared configuration |
.codebuddy/settings.local.json | β Do not commit | Auto-added to .gitignore |
CODEBUDDY.md / .codebuddy/CODEBUDDY.md | β Recommended | Team shared knowledge |
CODEBUDDY.local.md | β Do not commit | Auto-added to .gitignore |
.codebuddy/agents/ | β Recommended | Team shared sub-agents |
.codebuddy/rules/ | β Recommended | Team shared rules |
.codebuddy/skills/ | β Recommended | Team shared skills |
.codebuddy/commands/ | β Recommended | Team shared commands |
Related Resources β
- Settings β Complete configuration field reference
- Memory Management β Detailed guide to CODEBUDDY.md and the rule system
- Sub-Agents β Create and use custom sub-agents
- Skills Documentation β In-depth guide to the skill system
- Slash Commands β Custom command reference
- MCP Documentation β MCP server configuration
Use the .codebuddy directory wisely to help CodeBuddy Code better understand your project and team conventions.