Concept | Description |
Worker | A running CLI process registered in ~/.codebuddy/sessions/ through a PID file. |
Daemon | A background HTTP service process ( --serve mode), managed through daemon start |
Background session (bg) | A non-interactive task started with --bg, automatically outputting logs to a file. |
# Start the daemon (run in the background with automatic port allocation)codebuddy daemon start# Specify a portcodebuddy daemon start --port 8080# Specify a bind address (allow remote access)codebuddy daemon start --host 0.0.0.0# Specify a permission mode (defaults to delegate mode)codebuddy daemon start --permission-mode default# Pass other standard parameters (model, mcp-config, and others are inherited automatically)codebuddy daemon start --model claude-sonnet-4-20250514 --mcp-config ./.mcp.json
--permission-mode.daemon start (--model, --permission-mode, --mcp-config, --tools, --agent, --settings, and others) are automatically inherited by daemon child processes.daemon start multiple times does not create multiple daemons. If a daemon is already running, the information of the existing daemon is returned directly.codebuddy daemon status# {"status":"running","pid":12345,"endpoint":"http://127.0.0.1:51862","startedAt":1775498920401}
codebuddy daemon stopcodebuddy daemon restart
# Run tasks in the backgroundcodebuddy --bg "Implement the login page"# Specify a name (for easier lookup)codebuddy --bg --name feature-login "Implement the login page"
--print -y mode (no TUI + permission confirmation skipped), and stdout/stderr is redirected to ~/.codebuddy/logs/{name}.log.# List all active workerscodebuddy ps# View background session logscodebuddy logs feature-login# Continuously follow logs (similar to tail -f)codebuddy logs feature-login -f# Attach to a background sessioncodebuddy attach feature-login# Terminate a background sessioncodebuddy kill feature-login
# List all workerscurl http://127.0.0.1:8080/api/v1/workers# Start the Daemoncurl -X POST http://127.0.0.1:8080/api/v1/daemon/start \\-H "Content-Type: application/json" \\-d '{"port": 9090}'# View Worker logs (telemetry logs)curl "http://127.0.0.1:8080/api/v1/workers/12345/logs?type=telemetry&tail=100"# Terminate a Workercurl -X DELETE http://127.0.0.1:8080/api/v1/workers/12345
--serve mode is started, the Web UI provides three management pages:Type | Path | Content | Trigger Condition |
telemetry | ~/.codebuddy/logs/{date}/{workspace}.log | Info/Warn/Error of all modules | Always (default priority) |
process | ~/.codebuddy/logs/{name}.log | Process stdout/stderr | Only bg/daemon |
debug | ~/.codebuddy/debug/{sessionId}.txt | Detailed debug information | Requires --debug |
transcript | ~/.codebuddy/projects/{id}/{sessionId}.jsonl | Conversation history | Always |
~/.codebuddy/sessions/ when it starts:~/.codebuddy/sessions/├── 12345.json # Local process (PID as the filename)├── 67890.json # Another local process└── manual-abc123.json # Manually added remote Worker
{"pid": 12345,"sessionId": "interactive-12345","cwd": "/home/user/project","startedAt": 1775498920401,"kind": "interactive","url": "http://127.0.0.1:8080","mode": "local","version": "2.78.1","hostname": "my-machine"}
kill -0, and manually added remote Workers are detected through heartbeat timeout (2 minutes).Variable | Description |
CODEBUDDY_SESSION_KIND | Worker type (interactive / bg / daemon) |
CODEBUDDY_SESSION_NAME | Display name of the background session |
CODEBUDDY_SESSION_LOG | Background session log path |
CODEBUDDY_GATEWAY_AUTH | Authentication mode (none / password) |
# Register as a system service and start the daemon immediatelycodebuddy daemon install# Specify the port and permission modecodebuddy daemon install --port 8080 --permission-mode bypassPermissions# Remove the system service registrationcodebuddy daemon uninstall
codebuddy daemon status displays the system service status:{"status": "running","pid": 42567,"endpoint": "http://127.0.0.1:9527","systemService": {"installed": true,"backend": "launchd","configPath": "/Users/xxx/Library/LaunchAgents/com.codebuddy.daemon.plist"}}
Platform | Backend | Service Type | Configuration path |
macOS | launchd | Launch Agent (user level) | ~/Library/LaunchAgents/com.codebuddy.daemon.plist |
Linux | systemd | User Unit | ~/.config/systemd/user/codebuddy-daemon.service |
Windows | Task Scheduler | Scheduled task (user level) | schtasks /tn "CodeBuddy Daemon" |
KeepAlive / Restart=on-failure).# Native management on macOSlaunchctl list | grep codebuddylaunchctl stop com.codebuddy.daemonlaunchctl start com.codebuddy.daemon# Native management on Linuxsystemctl --user status codebuddy-daemonsystemctl --user stop codebuddy-daemonsystemctl --user start codebuddy-daemon# Native management on Windowsschtasks /query /tn "CodeBuddy Daemon"
codebuddy daemon start --port 8080# Open http://127.0.0.1:8080 in a browser to start using it# The service keeps running after the terminal is closed
# Starting in CIcodebuddy daemon start --port 9090# Calling from other CI steps (the body must be in Gateway Protocol format and include id/type)curl -X POST http://127.0.0.1:9090/api/v1/runs \\-H "Content-Type: application/json" \\-H "X-CodeBuddy-Request: 1" \\-d '{"id": "run-1", "type": "message", "payload": {"text": "Review the code changes in this PR"}}'# Response: {"data": {"runId": "uuid-xxx", "status": "accepted"}}
/api/v1/runs must include the X-CodeBuddy-Request header. The body must use the Gateway Protocol format, where id and type are required and the prompt text is placed in payload.text. For field details, see the HTTP API documentation.codebuddy daemon start --host 0.0.0.0 --port 8080# Colleagues can access http://192.168.1.100:8080
--bg to start multiple background sessions concurrently for handling different tasks, and manage them with ps/logs/kill.codebuddy --bg --name "refactor-auth" "Refactor the authentication module"codebuddy --bg --name "add-tests" "Add unit tests for the utils directory"codebuddy --bg --name "fix-types" "Fix all TypeScript type errors"# Check progresscodebuddy pscodebuddy logs refactor-auth
codebuddy daemon start# Connect WeChat/WeCom channels with the remote control feature
Feature | --serve | daemon start |
Lifecycle | Follows the terminal and exits when the terminal is closed. | Runs persistently in the background, independent of the terminal. |
Startup Method | Run in the foreground | fork a detached child process. |
Management Method | Stop with Ctrl+C | daemon stop/status/restart |
Multiple Starts | Create a new process each time | Idempotent, maintaining only one daemon. |
Typical Use | Temporary development and debugging | Long-running service. |
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