Skip to content

Commit 26140c8

Browse files
docs: synchronize Codebuff vs Claude Code docs and related agent docs; improve navigation and copy-link UX across docs
Why: align with recent edits and improve hash navigation and copy-link consistency. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent dfc91bd commit 26140c8

File tree

7 files changed

+120
-248
lines changed

7 files changed

+120
-248
lines changed

web/src/app/docs/layout.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { Menu } from 'lucide-react'
44
import { usePathname } from 'next/navigation'
5-
import { useState } from 'react'
5+
import { useState, useEffect } from 'react'
66

77
import { DocSidebar, sections } from '@/components/docs/doc-sidebar'
88
import { Button } from '@/components/ui/button'
@@ -15,6 +15,23 @@ export default function DocsLayout({
1515
}) {
1616
const pathname = usePathname()
1717
const [open, setOpen] = useState(false)
18+
19+
// New: Smoothly scroll to hash target on back/forward navigation
20+
useEffect(() => {
21+
const handleHashChange = () => {
22+
const id = window.location.hash.slice(1)
23+
if (id) {
24+
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' })
25+
}
26+
}
27+
28+
// If landing with a hash, ensure smooth scroll to target
29+
handleHashChange()
30+
31+
window.addEventListener('hashchange', handleHashChange)
32+
return () => window.removeEventListener('hashchange', handleHashChange)
33+
}, [])
34+
1835
return (
1936
<div className="pt-8">
2037
<div className="container flex md:space-x-8 overflow-x-hidden">

web/src/components/docs/copy-heading.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export function CopyHeading({
2929
{...props}
3030
id={id}
3131
className="inline-block hover:cursor-pointer hover:underline -mb-4 scroll-mt-24 font-serif"
32-
onClick={() =>
33-
id &&
32+
onClick={() => {
33+
if (!id) return
34+
history.pushState(null, '', `${window.location.pathname}#${id}`)
3435
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' })
35-
}
36+
}}
3637
>
3738
{title}
3839
<button

web/src/components/docs/mdx/mdx-components.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const createHeadingWithCopyLink = (
9797

9898
const handleClick = () => {
9999
if (id) {
100+
// Add a history entry with the new hash and smoothly scroll
101+
history.pushState(null, '', `${window.location.pathname}#${id}`)
100102
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' })
101103
}
102104

web/src/content/advanced/claude-code-comparison.mdx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,36 @@ Codebuff might be a better choice if you value:
2525
- Codebase Analysis: Codebuff pulls more context from scanning your entire codebase, rather than file-by-file. Codebuff also [blends different models](/docs/advanced#what-models-do-you-use?) based on their strengths to provide more accurate results.
2626
- Staying in Flow: Codebuff requires fewer confirmation prompts for file edits and command execution.
2727
- Focused changes: Codebuff does just what you asked for, while Claude Code will often get carried away editing more and more files.
28+
- SDK and Programmatic Access: Codebuff provides a full TypeScript SDK for programmatic integration, allowing you to create custom workflows and embed AI coding capabilities into your own tools.
29+
- Advanced Agent System: Create custom agents with TypeScript generator functions, spawn subagents, and orchestrate complex multi-step workflows that go far beyond simple chat interactions.
2830

2931
## When to Choose Claude Code
3032

3133
Claude Code might be a better choice if you:
3234

33-
- Can't use an intermediary provider, need to use the API directly from Anthropic
35+
- You require first-party Anthropic integration (no intermediary/proxy) for procurement, data handling, or legal reasons
36+
- You need enterprise security/compliance controls directly from Anthropic (e.g., SOC 2/ISO programs, data-retention controls, private/VPC networking options)
37+
- Your org needs centralized admin controls within Anthropic's ecosystem (SSO, RBAC, governance, auditability)
38+
- You prioritize early access to Anthropic model capabilities and first-party tooling
39+
3440

3541
## Feature Comparison
3642

3743
<MarkdownTable>
38-
| Feature | Codebuff | Claude Code | | --- | --- | --- | | CLI-based
39-
interaction | ✅ | ✅ | | Natural language commands | ✅ | ✅ | | Autonomous
40-
test execution | ✅ | ✅ | | Deep, targeted context awareness | ✅ | ❌ | |
41-
Large context window | ✅ (200k - 1M) | ✅ (200k) | | Fast diff edits (no full
42-
rewrites) | ✅ | ❌ | | Accuracy at scale | ✅ | ❌ | | Cost | $ | $$$ | |
43-
Polished UI | ❌ | ✅ | | Minimal interruptions | ✅ | ❌ |
44+
| Feature | Codebuff | Claude Code |
45+
| --- | --- | --- |
46+
| CLI-based interaction |||
47+
| Natural language commands |||
48+
| Autonomous test execution |||
49+
| Large context window | ✅ (200k-1M) | ✅ (200k-1M) |
50+
| Directory-specific context awareness || 🔄 |
51+
| Fast diff edits (no full rewrites) |||
52+
| Cost | $ | $$ |
53+
| Polished UI |||
54+
| Minimal interruptions |||
55+
| Full-featured SDK |||
56+
| Programmatic agent creation |||
57+
| Project templates |||
4458
</MarkdownTable>
4559

4660
## Summary

web/src/content/agents/creating-new-agents.mdx

Lines changed: 19 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,24 @@ order: 2
66
---
77

88
# Creating New Agents
9-
109
Create specialized agents from scratch using TypeScript files in the `.agents/` directory.
1110

1211
**Types:**
1312

14-
- **LLM-based** - Use prompts and language models
15-
- **Programmatic** - Use TypeScript generator functions with `handleSteps`
16-
17-
## Basic Structure
18-
19-
Create a new TypeScript file in `.agents/` directory:
20-
21-
**.agents/code-analyzer.ts**
22-
```typescript
23-
import { AgentDefinition } from './types/agent-definition'
24-
25-
const definition: AgentDefinition = {
26-
id: "code-analyzer",
27-
displayName: "Code Analysis Expert",
28-
spawnerPrompt: "Spawn for deep code analysis and refactoring suggestions",
29-
model: "anthropic/claude-4-sonnet-20250522",
30-
31-
toolNames: ["read_files", "code_search", "spawn_agents", "write_file"],
32-
spawnableAgents: ["codebuff/thinker@0.0.1", "codebuff/reviewer@0.0.1"],
33-
34-
handleSteps: function* ({ agentState, prompt, params }) {
35-
// First, find relevant files
36-
const { toolResult: files } = yield {
37-
toolName: 'find_files',
38-
input: { query: prompt }
39-
}
40-
41-
// Read the most important files
42-
if (files) {
43-
const filePaths = JSON.parse(files).slice(0, 5)
44-
45-
const { toolResult } = yield {
46-
toolName: 'read_files',
47-
input: { paths: ['file1.ts', 'file2.ts'] }
48-
}
49-
}
50-
51-
// Spawn a thinker for deep analysis
52-
yield {
53-
toolName: 'spawn_agents',
54-
input: {
55-
agents: [{
56-
agent_type: 'thinker',
57-
prompt: `Analyze the code structure and suggest improvements for: ${prompt}`
58-
}]
59-
}
60-
}
61-
62-
// Let the agent generate its response
63-
yield 'STEP_ALL'
64-
65-
export default definition
66-
```
67-
68-
```
13+
- **LLM-based** - Use prompts and language models
14+
- **Programmatic** - Use TypeScript generator functions with `handleSteps`
6915

7016
**Control Flow:**
71-
- `yield 'STEP'` - Run one LLM generation step
72-
- `yield 'STEP_ALL'` - Run until completion
73-
- `return` - End the agent's turn
17+
18+
- `yield 'STEP'` - Run one LLM generation step
19+
- `yield 'STEP_ALL'` - Run until completion
20+
- `return` - End the agent's turn
7421

7522
**Accessing Context:**
76-
- `agentState` - Current agent state and message history
77-
- `prompt` - User's prompt to the agent
78-
- `params` - Additional parameters passed to the agent
79-
# Creating New Agents
80-
Create specialized agents from scratch using TypeScript files in the `.agents/` directory.
81-
**Types:**
8223

83-
- **LLM-based** - Use prompts and language models
84-
- **Programmatic** - Use TypeScript generator functions with `handleSteps`
24+
- `agentState` - Current agent state and message history
25+
- `prompt` - User's prompt to the agent
26+
- `params` - Additional parameters passed to the agent
8527

8628
## Basic Structure
8729

@@ -118,22 +60,8 @@ const definition: AgentDefinition = {
11860

11961
export default definition
12062
```
121-
**.agents/templates/doc-writer-system.md**
122-
123-
```markdown
124-
# Documentation Writer
125-
126-
Create clear, comprehensive documentation for codebases.
127-
128-
## Guidelines
129-
130-
- Research codebase first
131-
- Use clear, concise language
132-
- Include practical examples
133-
- Test examples for accuracy
134-
```
13563

136-
## More Domain-Specific Examples
64+
## Domain-Specific Examples
13765

13866
### API Documentation Agent
13967

@@ -208,133 +136,16 @@ const definition: AgentDefinition = {
208136

209137
export default definition
210138
```
211-
**.agents/templates/migration-guidelines.md**
212-
213-
```markdown
214-
# Database Migration Guidelines
215-
216-
## Safety First
217-
218-
- Always create reversible migrations (up and down)
219-
- Test migrations on a copy of production data
220-
- Add indexes for new foreign keys
221-
- Use transactions where supported
222-
223-
## Performance Considerations
224-
225-
- Avoid locking tables during peak hours
226-
- Use `ADD COLUMN` with defaults carefully
227-
- Consider batching large data changes
228-
- Monitor migration execution time
229-
230-
## Best Practices
231-
232-
- Include descriptive migration names
233-
- Add comments explaining complex changes
234-
- Validate data integrity after migration
235-
- Keep migrations atomic and focused
236-
```
237-
238-
## Advanced Examples
239-
240-
### Frontend Development Coordinator
241-
242-
**.agents/frontend-coordinator.ts**
243-
```typescript
244-
import { AgentDefinition } from './types/agent-definition'
245-
246-
const definition: AgentDefinition = {
247-
id: "frontend-coordinator",
248-
version: "1.0.0",
249-
displayName: "Frontend Development Coordinator",
250-
spawnerPrompt: "Spawn this agent to coordinate frontend development tasks with React best practices and component architecture",
251-
model: "anthropic/claude-4-sonnet-20250522",
252-
outputMode: "last_message",
253-
includeMessageHistory: true,
254-
toolNames: ["read_files", "write_file", "code_search", "spawn_agents", "end_turn"],
255-
spawnableAgents: ["codebuff/reviewer@0.0.1", "codebuff/researcher@0.0.1", "codebuff/file-picker@0.0.1"],
256-
inputSchema: {
257-
prompt: {
258-
type: "string",
259-
description: "Frontend development task to coordinate"
260-
}
261-
},
262-
systemPrompt: "You are a frontend development coordinator specializing in React best practices. Guide development workflows and ensure code quality.",
263-
instructionsPrompt: "Coordinate the frontend development task, spawning appropriate agents as needed.",
264-
stepPrompt: "Continue coordinating the frontend development workflow. Use end_turn when complete."
265-
}
266-
267-
export default definition
268-
```
269-
270-
### API Development Specialist
271-
272-
**.agents/api-specialist.ts**
273-
```typescript
274-
import { AgentDefinition } from './types/agent-definition'
275-
276-
const definition: AgentDefinition = {
277-
id: "api-specialist",
278-
version: "1.0.0",
279-
displayName: "API Development Specialist",
280-
spawnerPrompt: "Spawn this agent for REST API development, OpenAPI compliance, and endpoint documentation",
281-
model: "anthropic/claude-4-sonnet-20250522",
282-
outputMode: "last_message",
283-
includeMessageHistory: true,
284-
toolNames: ["read_files", "write_file", "code_search", "spawn_agents", "run_terminal_command", "end_turn"],
285-
spawnableAgents: ["codebuff/reviewer@0.0.1", "codebuff/researcher@0.0.1", "codebuff/file-picker@0.0.1"],
286-
inputSchema: {
287-
prompt: {
288-
type: "string",
289-
description: "API development or documentation task"
290-
}
291-
},
292-
systemPrompt: "You are an API development specialist focused on creating robust, well-documented REST APIs following industry standards.",
293-
instructionsPrompt: "Handle the API development task, ensuring proper design patterns and documentation.",
294-
stepPrompt: "Continue working on the API development task. Use end_turn when complete."
295-
}
296-
297-
export default definition
298-
```
299-
300-
### DevOps Automation Agent
301-
302-
**.agents/devops-automator.ts**
303-
```typescript
304-
import { AgentDefinition } from './types/agent-definition'
305-
306-
const definition: AgentDefinition = {
307-
id: "devops-automator",
308-
version: "1.0.0",
309-
displayName: "DevOps Automation Specialist",
310-
spawnerPrompt: "Spawn this agent for infrastructure automation, CI/CD pipelines, and deployment configuration",
311-
model: "anthropic/claude-4-sonnet-20250522",
312-
outputMode: "last_message",
313-
includeMessageHistory: true,
314-
toolNames: ["read_files", "write_file", "code_search", "spawn_agents", "run_terminal_command", "end_turn"],
315-
spawnableAgents: ["codebuff/reviewer@0.0.1", "codebuff/researcher@0.0.1", "codebuff/file-picker@0.0.1"],
316-
inputSchema: {
317-
prompt: {
318-
type: "string",
319-
description: "Infrastructure or deployment automation task"
320-
}
321-
},
322-
systemPrompt: "You are a DevOps automation specialist focused on secure, scalable infrastructure and deployment pipelines.",
323-
instructionsPrompt: "Handle the infrastructure or deployment automation task with security and reliability in mind.",
324-
stepPrompt: "Continue working on the DevOps automation task. Use end_turn when complete."
325-
}export default definition
326-
```
327139

328140
## Programmatic Agents (Advanced)
329141

330-
**🎯 This is where Codebuff agents become truly powerful!** While LLM-based agents work well for many tasks, programmatic agents give you precise control over complex workflows.
142+
**🎯 This is where Codebuff agents become truly powerful!** While LLM-based agents work well for many tasks, programmatic agents give you precise control over complex workflows, while still letting you tap into LLMs when you want them.
331143

332144
### Why Use Programmatic Agents?
333145

334146
- **Deterministic workflows** - Guarantee specific steps happen in order
335-
- **Dynamic decision making** - Branch based on actual file contents or tool results
147+
- **Dynamic decision making** - Branch based on your own logic
336148
- **Complex orchestration** - Coordinate multiple agents and tools with logic
337-
- **Error handling** - Catch and handle tool errors programmatically
338149
- **State management** - Maintain state across multiple agent steps
339150

340151
### How It Works
@@ -397,9 +208,9 @@ Your `handleSteps` function receives context and yields actions:
397208

398209
```typescript
399210
handleSteps: function* ({ agentState, prompt, params }) {
400-
// agentState - Current conversation and agent state
401-
// prompt - What the user asked this agent to do
402-
// params - Additional parameters passed to the agent
211+
// agentState: Current conversation and agent state
212+
// prompt: What the user asked this agent to do
213+
// params: Additional parameters passed to the agent
403214

404215
// Your logic here...
405216
}
@@ -426,11 +237,10 @@ if (toolError) {
426237

427238
#### 3. Control Flow Options
428239

429-
| Command | Purpose | When to Use |
430-
|---------|---------|------------|
431-
| `yield 'STEP'` | Run one LLM generation | Need single response |
432-
| `yield 'STEP_ALL'` | Run until completion | Let LLM finish the task |
433-
| `return` | End immediately | Task complete or error |
240+
**Control Flow:**
241+
- `yield 'STEP'` - Run one LLM generation step
242+
- `yield 'STEP_ALL'` - Run until completion
243+
- `return` - End the agent's turn
434244

435245
#### 4. Advanced Example: Conditional Workflow
436246

0 commit comments

Comments
 (0)