CKB + Cursor: Supercharging Your AI Editor
By CKB Team
Cursor is a popular AI-powered code editor. By default, it searches your codebase with text matching. CKB upgrades that to semantic understanding—your AI knows what functions call what, not just where strings appear.
This guide covers setting up CKB with Cursor.
The Difference CKB Makes
Without CKB:
You: "What calls the handlePayment function?"
Cursor: "I found handlePayment mentioned in these files:
- payment.go (definition)
- payment_test.go (tests)
- README.md (documentation)
- old_payment.go.bak (backup file)"
With CKB:
You: "What calls the handlePayment function?"
Cursor: "handlePayment in internal/payment/handler.go is called by:
- CheckoutController.Process() in controllers/checkout.go:45
- RefundController.Execute() in controllers/refund.go:78
- WebhookHandler.ProcessPayment() in webhooks/stripe.go:123
It has 3 callees: validateCard(), chargeCard(), sendReceipt()
12 tests cover this function."
Setup
Step 1: Install CKB
npm install -g @tastehub/ckb
Step 2: Index Your Project
cd /your/project
ckb init
Step 3: Configure Cursor
Open Cursor's MCP configuration:
# macOS
~/.cursor/mcp.json
# Windows
%APPDATA%\Cursor\mcp.json
# Linux
~/.config/cursor/mcp.json
Add CKB:
{
"mcpServers": {
"ckb": {
"command": "npx",
"args": ["@tastehub/ckb", "mcp"]
}
}
}
Step 4: Restart Cursor
Close and reopen Cursor for the config to take effect.
Choosing a Preset
The default includes all tools, but you can optimize for your workflow:
{
"mcpServers": {
"ckb": {
"command": "npx",
"args": ["@tastehub/ckb", "mcp", "--preset=core"]
}
}
}
| Preset | Tools | Best For |
|---|---|---|
| core | 21 | General development |
| review | 27 | Code review |
| refactor | 33 | Large refactoring |
| full | 92 | Everything |
Verify It's Working
In Cursor's chat, type:
What CKB tools do you have access to?
You should see a list including searchSymbols, getCallGraph, prepareChange, etc.
Test with a real query:
What's the most complex function in this codebase?
CKB will analyze cyclomatic complexity and report the results.
Cursor-Specific Tips
Use Cmd+K with CKB Context
When using Cursor's inline edit (Cmd+K), you can reference CKB analysis:
You: [select a function, press Cmd+K]
"Refactor this to reduce complexity. CKB says it has 15 branches."
Combine with Cursor's @ References
You: "What calls @symbol:handlePayment and what tests cover it?"
Cursor's @ reference plus CKB's semantic analysis gives you precise answers.
Use Chat for Impact Analysis
Before making changes:
You: "I'm about to modify the User struct. What's the impact?"
Cursor: [uses prepareChange]
"Modifying the User struct affects:
- 23 functions that use User fields
- 8 API endpoints that serialize User
- 45 tests
Risk score: 67 (Medium-High)
Suggested reviewers: @alice, @bob"
Common Workflows
Understanding New Code
You: "Explain the authentication flow in this codebase"
Cursor: [uses explore and getCallGraph]
"Authentication flows through these components:
1. AuthMiddleware (middleware/auth.go)
- Extracts JWT from headers
- Calls TokenService.Validate()
2. TokenService (services/token.go)
- Validates token signature
- Checks expiration
- Returns user claims
3. UserContext (context/user.go)
- Attaches user to request context
- Used by downstream handlers
Entry points: /api/login, /api/refresh
All protected routes go through AuthMiddleware."
Pre-Change Analysis
You: "I want to rename getUserById to fetchUser. What needs to change?"
Cursor: [uses prepareChange with rename]
"Renaming getUserById → fetchUser requires updates in:
Direct callers (12):
- user_controller.go:34, 67, 89
- profile_service.go:23, 45
- admin_handler.go:12
... and 6 more
Tests (8):
- user_controller_test.go
- profile_service_test.go
- integration_test.go
No external API impact (internal function).
Would you like me to perform this rename?"
Finding Dead Code
You: "Are there any unused functions in the utils package?"
Cursor: [uses findDeadCode]
"Found 4 unused functions in pkg/utils/:
- formatOldDate() - last modified 2024-03, no callers
- validateLegacyToken() - replaced by new auth system
- convertV1Response() - V1 API removed
- debugPrint() - debugging helper, test-only usage
Total: 89 lines of dead code"
Keeping Index Updated
Manual Update
ckb index
Automatic via File Watcher
# Run in terminal, keeps index fresh
ckb watch
Git Hook
# .git/hooks/post-merge
#!/bin/bash
ckb index --incremental --quiet
Troubleshooting
"CKB is indexed for the wrong project"
Cursor doesn't pass your workspace directory to MCP servers. CKB may start indexed for a different project.
What happens: Error messages say something like "CKB index is for /some/other/path". The AI agent will automatically call switchProject to fix this — no action needed on your part.
If auto-correction doesn't work: Tell Cursor explicitly:
Switch CKB to this project using switchProject
"CKB tools not available"
- Check mcp.json syntax is valid JSON
- Verify CKB is installed:
which ckb - Restart Cursor completely
- Check Cursor's MCP logs in Developer Tools
Slow responses
- Use a smaller preset (
--preset=core) - Check index size:
ckb status - Exclude large generated files in
.ckb/config.json
Stale results
# Force rebuild
ckb index --force
vs. Built-in Cursor Search
| Feature | Cursor Built-in | With CKB |
|---|---|---|
| Find text | ✓ | ✓ |
| Find symbol | ✓ | ✓ |
| Find callers | ~ (text search) | ✓ (semantic) |
| Impact analysis | ✗ | ✓ |
| Dead code detection | ✗ | ✓ |
| Code ownership | ✗ | ✓ |
| Cross-repo search | ✗ | ✓ |
CKB complements Cursor's built-in features—use both.
Next Steps
- Prompt Cookbook - Ready-to-use prompts for Cursor
- Compound Operations - Efficient multi-queries
- Token Economics - Optimize AI costs
Links: