tencent cloud

Directory Structure of .codebuddy

Download
Focus Mode
Font Size
Last updated: 2026-09-30 18:15:48
AI-Translated
Gain a deep understanding of the files and subdirectories in the CodeBuddy Code configuration directory ~/.codebuddy and the project-level .codebuddy directory.
CodeBuddy Code uses two types of configuration directories:
Global directory ~/.codebuddy/: stores user-level configurations, historical data, runtime data, and more, affecting all projects.
Project directory .codebuddy/ (located in the project root): stores project-level configurations, rules, skills, commands, and more, and is shared with the team through project 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 subagents (available in all projects)
├── rules/ # User-level rule files (available in all projects)
├── skills/ # User-level skills (available in all projects)
│
├── projects/ # Runtime data for sessions and subagents of each project
├── sessions/ # Session data
├── plans/ # Plan files generated in plan mode
│
├── logs/ # Runtime logs
├── traces/ # Execution trace data (OpenTelemetry)
├── file-history/ # File change history
├── history.jsonl # Conversation history
├── blobs/ # Binary resources (images, screenshots, etc.)
├── tasks/ # Task tracking data
├── teams/ # Runtime data for Agent teams
├── shell-snapshots/ # Bash sandbox snapshots
│
├── plugins/ # Installed plugins
├── local_storage/ # CLI key-value persistent storage
├── channels/ # Channel configurations (WeChat, etc.)
│
├── computer-use/ # Computer Use feature records
├── debug/ # Debug information
└── usage-data/ # Usage statistics

Core configuration file

settings.json

User-level global configuration applies to all projects. It can be managed through the /config command or by direct editing.
{
"language": "Simplified Chinese",
"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 complete configuration fields, see Settings Configuration.

settings.local.json

Local personal configurations are not automatically synced or shared by CodeBuddy Code. They are suitable for storing overrides that are only effective on the local machine, such as API keys and debug switches.

CODEBUDDY.md

The user-level memory file takes effect in all projects and is suitable for storing personal coding preferences, common workflow instructions, and so on.
## Tool Preferences
- Use pnpm instead of npm
- Prefer a functional programming style

## Code Style
- Use 2-space indentation
For details, see Memory Management.

mcp.json

Global MCP server configuration, with the same format as the project-level .mcp.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
}
}
}
For details, see MCP Documentation.

User-Level Extension Directory

agents/

Stores user-level custom subagents that take effect in all projects. Each agent is a .md file:
~/.codebuddy/agents/
├── code-reviewer.md # Code review agent
└── translator.md # Translation agent
File format (YAML frontmatter + system prompt):
---
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, focusing on code quality, security, and practical tutorials...
For details, see Subagent Documentation.

rules/

Stores user-level rule files that take effect in all projects. All .md files are loaded automatically, and subdirectories are supported:
~/.codebuddy/rules/
├── preferences.md # Personal coding preferences
└── workflows.md # Common workflow standards
Rule files support frontmatter to control loading behavior:
---
alwaysApply: false
paths: src/**/*.ts
---

# TypeScript Standards

- Prefer `interface` over `type`.
- Do not use `any`.

skills/

Stores user-level skills that take effect in all projects. Each skill is a standalone directory that contains a SKILL.md file:
~/.codebuddy/skills/
└── pdf/
└── SKILL.md
For details, see Skills documentation.

Runtime Data Directory

These directories are automatically maintained by CodeBuddy Code and typically require no manual intervention:
Directory
Description
projects/
Runtime data for each project, including session records (.jsonl) and subagent 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/
File snapshots operated in each session, used for /rewind rollback
history.jsonl
Global conversation history (used for /resume restoration)
blobs/
Binary resources such as images and screenshots, stored by content hash
tasks/
Task management system data (TaskCreate/TaskUpdate)
teams/
Runtime data of Agent teams (TeamCreate)
shell-snapshots/
Bash sandbox startup snapshots for accelerating 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/

Place it in the project root directory so that it can be committed to version control for team sharing:
.codebuddy/
├── settings.json # Shared project configuration
├── settings.local.json # Local personal configuration (automatically ignored by .gitignore)
├── CODEBUDDY.md # Project-level memory file
│
├── agents/ # Project-level custom subagents
├── rules/ # Project-level rule files
├── skills/ # Project-level skills
├── commands/ # Custom slash commands

Configuration File

settings.json

Shared project configuration is synchronized with the team through version control. It is suitable for configuring project-wide models, permission rules, plugins, and more:
{
"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 configurations are automatically added to .gitignore by CodeBuddy Code. They are suitable for storing personal overrides, such as local debug ports and personal keys, without affecting other team members.

CODEBUDDY.md

A project-level memory file that is shared through version control. It stores team knowledge such as project architecture, conventions, and common commands:
# Project Description

This project is a TypeScript monorepo (Yarn workspaces).

## Common Commands

- `yarn build` — Build all packages
- `yarn test` — Run all tests

## Architecture Conventions

- Use the CellJS dependency injection framework
- Place protocol definitions in `*-protocol.ts` files
Note:
You can also place the memory file in CODEBUDDY.md at the root directory (not inside .codebuddy/). Both locations are equivalent.

Project-Level Extension Directory

agents/

Stores project-specific subagents and takes precedence over user-level agents. When agents have the same name, the project-level agent overrides the user-level agent.
.codebuddy/agents/
├── blog-translator.md # Blog translation agent
└── docs-reviewer.md # Documentation review agent

rules/

Stores project-level rules and is shared through version control. It is suitable for team-wide code standards, workflow conventions, and similar purposes. Subdirectory organization is supported:
.codebuddy/rules/
├── code-style.md # Code style conventions
├── testing.md # Testing standards
├── security.md # Security requirements
└── frontend/
├── react.md # React component conventions
└── styles.md # Style conventions
All .md files are automatically loaded recursively.

skills/

Stores project-level skills. Each skill is a directory that contains a SKILL.md file and optional supporting files:
.codebuddy/skills/
├── case-executor/
│ ├── SKILL.md # Skill definition
│ ├── scripts/ # Helper scripts
│ └── references/ # Reference materials
└── cnb-api/
└── SKILL.md
SKILL.md format:
---
name: case-executor
description: Execute JSON test cases and generate a report
allowed-tools: Read, Write, Bash
---

You are a test execution expert responsible for running UI test cases in JSON format...
For details, see Skills documentation.

commands/

Stores custom slash commands, triggered via /command-name. Supports directory nesting (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 command
Command file format:
---
description: Create a new Issue
argument-hint: "<description> ; <type> ; <product>"
allowed-tools: Bash
---

Create an Issue based on the following description: $ARGUMENTS
For details, see Slash command documentation.

Configuration Precedence

Multiple layers of configuration are applied in the following priority order (higher priority overrides lower priority):
Command line parameters (highest priority)
↓
.codebuddy/settings.local.json (project-local, not committed to version control)
↓
.codebuddy/settings.json (project-shared, team-wide)
↓
~/.codebuddy/settings.json (user-global, personal preferences)
↓
Built-in product default configuration (lowest priority)
Priority of agents/skills/rules: project level > user level > plugin level. If they have the same name, the project-level one takes precedence.

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 the cwd)
4. Project-level rules: .codebuddy/rules/*.md (cwd only, not upward)
5. Project-local memory: CODEBUDDY.local.md
6. Subdirectory memory: The tool dynamically loads the CODEBUDDY.md file in a subdirectory when operating on files in that subdirectory.

Version Control Recommendations

File/Directory
Submit to Version Control or Not
Description
.codebuddy/settings.json
✔ Recommended to commit
Team-shared configuration
.codebuddy/settings.local.json
✖ Do not commit
Automatically added to .gitignore
CODEBUDDY.md / .codebuddy/CODEBUDDY.md
✔ Recommended to commit
Team-shared knowledge
CODEBUDDY.local.md
✖ Do not commit
Automatically added to .gitignore
.codebuddy/agents/
✔ Recommended to commit
Team-shared subagents
.codebuddy/rules/
✔ Recommended to commit
Team-shared rules
.codebuddy/skills/
✔ Recommended to commit
Team-shared skills
.codebuddy/commands/
✔ Recommended to commit
Team-shared commands


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback