CKB AI

AI Tools for Nervos CKB Developers

What is CKB AI?

CKB AI is a collection of tools designed to help AI assistants build smart contracts and applications on Nervos CKB. It consists of three MCP servers that provide AI with direct access to CKB-specific documentation, blockchain data, and development utilities.

Recommended Base Stack

As AI technology advances and our tooling evolves these recommendations will change.

Claude Code + Claude Opus 4.5 + CKB AI + Playwright

This stack has consistently produced the best results for CKB development.

Why MCP?

Specializing AI for CKB development can be approached two ways: training models directly on domain-specific data, or augmenting existing models with external tools and resources. We chose the augmentation approach using MCP.

The AI landscape is evolving rapidly. Which model performs best for programming tasks changes frequently, and there is no way to predict which will lead in the long run.

Training a model directly on CKB data would yield marginally better results, but comes with significant drawbacks:

MCP takes a different approach. It is compatible with all major AI systems, both open and closed source. Rather than making a massive investment that could quickly become outdated, we build a portable knowledge base and tooling that moves with us to whatever the best model is at any given time.

We believe this is the best strategy for both the short term and the foreseeable future.

What CKB AI Provides

CKB AI provides three MCP servers, each designed to enhance AI's development capabilities:

Server Description
CKB Docs Curated documentation and examples formatted for AI. Enables AI to immediately understand CKB development without prior training.
CKB RPC Direct interface for querying blocks, transactions, cells, and network state. Allows AI to understand the chain and verify its own work.
CKB Tools Utilities for common tasks such as deploying cells and managing accounts. Reduces AI workload, increases success rates, and lowers costs.

CKB AI does not replace the need to understand CKB development fundamentals.

CKB AI still requires guidance from a knowledgeable engineer to be successful.

Installation

CKB AI Servers:

For best performance, run the servers locally. Alternatively, use the CKBDEV-hosted servers:

claude mcp add --transport http ckb-rpc http://mcp.ckbdev.com/rpc
claude mcp add --transport http ckb-docs http://mcp.ckbdev.com/docs
claude mcp add --transport http ckb-tools http://mcp.ckbdev.com/tools

Note: CKBDEV-hosted servers run development versions and may be unstable. For a more reliable experience, run the servers locally.

Playwright:

claude mcp add playwright npx @playwright/mcp@latest

Configure Your CLAUDE.md

Claude Code works great out of the box, but it works even better when you tailor it to fit your workflow. There are many base configurations available that continue to evolve. Some notable ones:

Regardless of which base you choose, consider adding these CKB-specific guidelines:

## CKB Development

- CRITICAL: Always use the CKB MCP servers as the primary source for CKB development information.
- Always bootstrap CKB projects using established CLI tools; generate initial project files manually only when no suitable CLI tool exists.

Usage Patterns

Where AI Excels

AI-assisted development works well across all parts of CKB application development, but each domain has different characteristics:

Across all domains, AI may struggle with poorly documented libraries and areas where tooling or examples are sparse. If you encounter gaps or work through solutions, please share your feedback so we can continue improving the experience for everyone.

The "Think Deeply" Instruction

At every step where careful reasoning is needed, explicitly instruct AI to "think deeply" on the topic. This produces noticeably better results. This instruction must be given in your prompts; placing it in CLAUDE.md does not have the same effect.

Recommended Libraries and Tools

Domain Recommendation
Frontend Stack Vite + React + TypeScript + Tailwind. This combination has excellent AI support and integrates well with CCC.
Frontend SDK CCC (@ckb-ccc/connector-react). Primary SDK for CKB applications providing transaction building, wallet integration, and cross-chain support.
Backend (Node.js) CCC (@ckb-ccc/core). Server-side transaction building and blockchain interaction.
Backend (Rust) CKB-SDK-Rust (ckb-sdk = "3.2.0"). Rust SDK for transaction building, cell collection, and RPC interaction.
Smart Contracts ckb-script-templates. Production-ready Rust templates for CKB smart contract development.
Local Devnet offckb. Local development environment with pre-funded accounts and pre-deployed system scripts.

Bootstrapping a Project

When starting a new project, explicitly tell AI the exact stack you want. For smart contracts, use ckb-script-templates via cargo generate. AI can sometimes struggle with scaffolding tools, so it may be more effective to perform the initial setup yourself and verify it compiles before handing off to AI. Regardless of approach, do not allow AI to manually generate boilerplate files, as this often leads to subtle errors.

For projects with multiple components (frontend, backend, smart contracts), use a monorepo structure. AI benefits from having all components in close proximity, allowing it to understand how they interact and maintain consistency across the codebase. Alternatively, keep separate repositories in a shared parent folder to achieve similar context visibility.

Use offckb to run a local devnet, or connect directly to testnet. A local devnet with a 1-5 second block time speeds up development cycles. Note that the CKBDEV-hosted CKB AI servers connect to testnet by default; using a local devnet requires running local MCP server instances configured for your devnet.

The Planning Cycle

Before writing code, invest significant time in planning. Instruct AI to fully plan the implementation and return with questions, concerns, and recommendations. Answer these, then have AI reevaluate and repeat the cycle.

┌────────────────────────────────────────────────────────────────┐
│                       THE PLANNING CYCLE                       │
│                                                                │
│      Plan  ───►  Questions / Concerns / Recommendations        │
│        ▲                                       │               │
│        │                                       ▼               │
│        └──────────  Reevaluate  ◄─────────  Answer             │
│                                                                │
│           Repeat until confident. Exit with spec doc.          │
└────────────────────────────────────────────────────────────────┘

Continue this cycle until AI has no remaining questions and the plan appears solid. At this point, have AI write a specification document that captures the full design. Reference this document in your CLAUDE.md to prevent drift as context accumulates.

Development Workflow

AI performs best when it can verify its own work. The CKB AI RPC and Tools servers enable AI to check transactions and state directly. Playwright allows AI to test frontend behavior across resolutions, but AI often misses visual problems like crowded layouts or cut-off text unless you specifically instruct it to look for them.

Test-driven development works well when feasible. AI can generate tests, but tends to miss edge cases; review test coverage yourself. Throughout development, monitor AI's progress and prevent it from taking shortcuts that compromise the design.

Smart Contract Considerations

Smart contracts require extra vigilance. The abstract nature of the cell model makes it difficult for AI to reason about correctly, and generated code often contains security vulnerabilities. You must understand how the cell model works and actively guide AI through the design. Provide it with the specific knowledge it needs rather than expecting it to figure things out independently. If you are new to the cell model, seek feedback from experienced developers to help guide the process.

Review and Optimization

After completing a major section, have AI perform a thorough review of its own code. Instruct it to check for proper structure, readability, dead code, and optimization opportunities. At the same time, set clear boundaries: instruct it to optimize at an appropriate level to prevent over-engineering or excessive abstraction. Developer judgment remains essential for keeping the codebase maintainable.

How to Contribute

If you encounter problems or discover solutions, your contributions help improve CKB AI for everyone:

Tools Under Investigation

We are actively investigating the following tools and may add them to our recommended stack in the future. However, they are not yet recommendations.