@backendkit-labs/agent-coding
v0.19.3
Published
Coding agent profiles and tools for @backendkit-labs/agent-core
Readme
@backendkit-labs/agent-coding
A production-ready coding agent engine built on @backendkit-labs/agent-core. Bundles 10 specialized agents, filesystem tools, multi-provider support (DeepSeek, OpenAI, Anthropic, Ollama, Kimi, Grok), automatic stack detection, persistent memory, QA review, reflection, and an orchestration pipeline — all in a single createCodingEngine() call.
Table of contents
- Installation
- Quick start
- createCodingEngine
- createCodingEngineFromConfig
- Providers
- Built-in agents
- Built-in tools
- Skill packs
- Orchestration pipeline
- Reflection engine
- MCP server integration
- Multi-agent examples
- Config file
Installation
npm install @backendkit-labs/agent-codingAll provider adapters are bundled — no separate packages needed.
Quick start
import { createCodingEngine } from '@backendkit-labs/agent-coding';
const engine = createCodingEngine({
providers: { deepseek: { apiKey: process.env.DEEPSEEK_API_KEY! } },
defaultProvider: 'deepseek',
});
await engine.run('List all TypeScript files in src/ and tell me which ones have no tests');That single call gives you: 10 specialized agents, filesystem tools (read/write/edit/search), persistent project memory, skill loading, and stack auto-detection.
createCodingEngine
The primary factory. Returns a fully configured AgentEngine.
Options reference
interface CodingEngineOptions {
// Required
providers: ProvidersConfig;
defaultProvider: string;
// Agents and engine
defaultAgent?: string; // default: 'general'
workingDir?: string; // default: process.cwd()
maxIterations?: number; // default: 100
maxParallelAgents?: number; // default: 6
// I/O
transport?: Transport; // default: StdoutTransport
// App identity
appName?: string; // default: 'bk-agent' — used for ~/.{appName}/
// Persistence
disablePersistence?: boolean; // skip ProjectStore (useful for testing)
// MCP servers
mcpServers?: MCPServerConfig[];
// Context sharing
subAgentContextMessages?: number; // messages visible to sub-agents (recommend 10-20)
// Iteration control
onToolApproval?: (toolName, agentId, argsPreview) => Promise<ToolApprovalDecision>;
onIterationLimit?: (stats: IterationStats) => Promise<boolean>;
onStep?: (stats: IterationStats) => Promise<boolean>;
// Orchestration
orchestration?: boolean | OrchestrationOptions;
}Minimal setup
const engine = createCodingEngine({
providers: { deepseek: { apiKey: 'sk-...' } },
defaultProvider: 'deepseek',
});Multiple providers
const engine = createCodingEngine({
providers: {
deepseek: { apiKey: process.env.DEEPSEEK_API_KEY! },
anthropic: { apiKey: process.env.ANTHROPIC_API_KEY!, model: 'claude-opus-4-8' },
ollama: { host: 'http://localhost:11434', model: 'llama3.2' },
},
defaultProvider: 'deepseek',
// Each agent profile can specify a provider override
});With full orchestration
const engine = createCodingEngine({
providers: { deepseek: { apiKey: '...' } },
defaultProvider: 'deepseek',
orchestration: true,
// Enables:
// intent detection → domain detection → risk scoring
// policy engine → agent routing → QA auto-review → reflection
});With MCP servers
const engine = createCodingEngine({
providers: { openai: { apiKey: '...' } },
defaultProvider: 'openai',
mcpServers: [
{ name: 'github', command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'], env: { GITHUB_TOKEN: '...' } },
{ name: 'postgres', command: 'npx', args: ['-y', '@modelcontextprotocol/server-postgres'], env: { DATABASE_URL: '...' } },
],
subAgentContextMessages: 15,
});With manual tool approval
const engine = createCodingEngine({
providers: { deepseek: { apiKey: '...' } },
defaultProvider: 'deepseek',
onToolApproval: async (toolName, agentId, argsPreview) => {
const write = ['write_file', 'edit_file', 'run_command'];
if (!write.includes(toolName)) return 'approve';
console.log(`\n⚠ [${agentId}] ${toolName}:\n${argsPreview}\n`);
const a = await prompt('Approve? (y/n/all): ');
if (a === 'y') return 'approve';
if (a === 'all') return 'approve_all';
return 'reject';
},
});createCodingEngineFromConfig
Reads credentials from ~/.{appName}/config.json. No code changes needed to switch providers:
import { createCodingEngineFromConfig } from '@backendkit-labs/agent-coding';
const engine = createCodingEngineFromConfig();
// With overrides
const engine = createCodingEngineFromConfig({
workingDir: '/my-project',
orchestration: true,
});Providers
DeepSeek
providers: {
deepseek: {
apiKey: process.env.DEEPSEEK_API_KEY!,
model?: 'deepseek-chat', // default
maxTokens?: 8192,
temperature?: 0.7,
}
}OpenAI
providers: {
openai: {
apiKey: process.env.OPENAI_API_KEY!,
model?: 'gpt-4o',
baseUrl?: 'https://api.openai.com/v1',
}
}Anthropic (Claude)
providers: {
anthropic: {
apiKey: process.env.ANTHROPIC_API_KEY!,
model?: 'claude-sonnet-4-6', // default
}
}Ollama (local — no API key)
# Prerequisites
ollama serve
ollama pull llama3.2providers: {
ollama: {
host?: 'http://localhost:11434',
model?: 'llama3.2',
}
}OpenAI-compatible (Kimi, Grok, any endpoint)
providers: {
kimi: { apiKey: process.env.KIMI_API_KEY!, model: 'moonshot-v1-8k' },
grok: { apiKey: process.env.GROK_API_KEY!, model: 'grok-3' },
// Any OpenAI-compatible endpoint
vllm: { apiKey: 'local', baseUrl: 'http://localhost:8080/v1', model: 'my-model' },
}Built-in agents
Ten specialist agents are bundled. Orchestration routes tasks automatically; you can also select explicitly.
| Agent ID | Specialty |
|----------|-----------|
| general | General-purpose — default starting point |
| architect | System design, ADRs, architecture decisions |
| backend-agent | APIs, server logic, databases |
| frontend-agent | React, CSS, accessibility, UX |
| devops-agent | CI/CD, Docker, Kubernetes, infra |
| database-agent | SQL, indexes, migrations, query tuning |
| security-reviewer | Security audits, OWASP, threat modeling |
| qa-engineer | Test strategy, edge cases, QA reviews |
| documentation-agent | Docs, READMEs, API docs, changelogs |
| refactoring-agent | Code cleanup, technical debt, design patterns |
Selecting an agent
await engine.run('Audit src/ for SQL injection risks', { agentId: 'security-reviewer' });Adding custom agents
Create ~/.bk-agent/agents/my-agent.json:
{
"id": "my-agent",
"name": "My Custom Agent",
"systemPrompt": "You are specialized in ...",
"tools": ["read_file", "run_command"],
"provider": "anthropic"
}Loaded automatically — no code changes needed.
Built-in tools
All agents have access to these tools via CODING_TOOLS:
| Tool | Description |
|------|-------------|
| read_file | Read a file by path |
| write_file | Create or overwrite a file |
| edit_file | Apply a targeted patch to a file |
| list_directory | List files in a directory |
| run_command | Execute a shell command |
| search_files | Recursive content search |
| save_context | Write to session.md (persisted notes) |
| save_learning | Append to lecciones-aprendidas.md |
| save_audit | Write a structured audit entry |
| get_latest_audit | Read the latest audit |
| list_audits | List audit entries |
| save_user_preference | Persist user preferences |
| update_session | Update the in-progress session note |
Skill packs
Built-in packs activate based on detected project stack:
| Pack | Activates for |
|------|---------------|
| GLOBAL_BUILTIN_SKILLS | All projects |
| NODE_PACK_SKILLS | Node.js / TypeScript (package.json) |
| GO_PACK_SKILLS | Go (go.mod) |
| JAVA_PACK_SKILLS | Java (pom.xml, build.gradle) |
| KOTLIN_PACK_SKILLS | Kotlin / Android |
| PYTHON_PACK_SKILLS | Python (requirements.txt, pyproject.toml) |
Orchestration pipeline
When orchestration: true, an intelligent routing layer runs before each LLM call:
Input
→ Intent Detection (feature? bug? refactor? question?)
→ Domain Detection (backend? frontend? security? ops?)
→ Risk Scoring (reads only? writes files? runs commands?)
→ Policy Engine (enforce domain-level rules)
→ Agent Selection (best agent for detected domain + risk)
→ LLM Call
→ QA Review (auto-review code-heavy responses)Custom orchestration
orchestration: {
capabilityMatrix: {
'my-specialist': {
owns: ['payments', 'billing'],
skills: ['typescript', 'stripe'],
baseWeight: 0.95,
},
},
customRules: [
{
if: { domain: 'security' },
then: { mustInclude: ['security-reviewer'] },
},
],
enableQA: true,
noQA: false,
onQAReview: (review) => logger.info('[QA]', review),
}Reflection engine
Observes failures across runs, promotes recurring patterns into policy rules:
orchestration: {
reflection: true,
// After each sprint:
// 1. Failures logged to FailureCatalog
// 2. Patterns with ≥3 occurrences promoted to PolicyRules
// 3. lecciones-aprendidas.md updated
}MCP server integration
mcpServers: [
{
name: 'code-intelligence',
command: 'bk-mcp', // @backendkit-labs/mcp-server
args: [],
env: { BK_APP_NAME: 'bk-agent', BK_CWD: process.cwd() },
},
{
name: 'github',
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-github'],
env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN! },
},
],
subAgentContextMessages: 20,Multi-agent examples
Feature implementation
await engine.run(`
Implement JWT authentication middleware for Express:
- Validate Bearer token in Authorization header
- Attach decoded user to req.user
- Return 401 with clear error messages
- Include unit tests with valid/expired/malformed token cases
`);
// architect plans → backend-agent implements → qa-engineer writes testsSecurity audit
await engine.run(`
Audit all routes in src/routes/ for:
1. Missing auth middleware
2. SQL injection vulnerabilities
3. Exposed sensitive data
Output a prioritized fix list.
`, { agentId: 'security-reviewer' });Database migration
await engine.run(`
Write a zero-downtime migration: add NOT NULL column
'last_login_at TIMESTAMP DEFAULT NOW()' to the users table (50M rows).
Include rollback script and backfill strategy.
`, { agentId: 'database-agent' });Full stack refactor
await engine.run(`
Refactor auth from session cookies to JWT.
Update both Express middleware and React login flow.
Keep backward compatibility for 2 more sprints.
`);
// backend-agent + frontend-agent + security-reviewerConfig file
~/.bk-agent/config.json:
{
"defaultProvider": "deepseek",
"providers": {
"deepseek": { "apiKey": "sk-xxxx", "model": "deepseek-chat" },
"anthropic": { "apiKey": "sk-ant-xxxx", "model": "claude-sonnet-4-6" },
"ollama": { "host": "http://localhost:11434", "model": "llama3.2" }
},
"mcpServers": [
{
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "ghp_xxxx" }
}
]
}