CodebuffClient class is the main entry point for using the Codebuff SDK.
Constructor
Options
Your Codebuff API key. Get one at codebuff.com/api-keys.If not provided, will read from
CODEBUFF_API_KEY environment variable.Working directory for file operations. Defaults to
process.cwd().All file paths in tool calls are relative to this directory.Path to directory containing skills. Skills found here will be available to the
skill tool.Each skill should be in its own subdirectory with a SKILL.md file.All files in your project as key-value pairs.
- Keys: file paths relative to
cwd - Values: file contents as strings
Knowledge files to inject into every run.Same format as
projectFiles. These files are added directly to agent context.If not provided, auto-discovers knowledge.md, AGENTS.md, or CLAUDE.md files.Array of custom agent definitions to make available for all runs.See Custom Agents for details.
Array of custom tool definitions to extend agent capabilities.See Custom Tools for details.
Maximum number of steps an agent can take before stopping.Use as a safety measure. A reasonable value is around 20.
Environment variables for terminal commands executed by agents.Merged with
process.env, with these values taking precedence.Default event handler for all runs.Can be overridden in individual
run() calls. See Event Handling.Optional filter to control which files agents can read.
'blocked': Returns[BLOCKED]instead of file content'allow-example': Prefixes content with[TEMPLATE]'allow': Normal read access
Methods
run()
Run a Codebuff agent with the specified options.Promise<RunState> - Contains session state and agent output
checkConnection()
Check connection to the Codebuff backend.Promise<boolean> - true if connected, false otherwise

