Blog / how-to-generate-code-with-ai

2026-09-07

How to generate code with AI without inventing a broken starter

Split AI codegen into invent, look up docs, and compose from known components. Use BotKelp for stamped Next.js scaffolds with INTEGRITY.json.

“Generate code with AI” usually means one prompt and a pile of files. That works for throwaway demos. It fails when the agent has to invent a Next.js starter from memory or raw web search: wrong Tailwind major, pages router imports in an App Router tree, half-wired auth clients, env names that do not match the code.

A better workflow treats code generation as three jobs, not one.

The three jobs

JobWhat the agent should doBad fit
Invent product logicWrite features that do not exist yetInventing framework boilerplate
Look up live API truthDocs MCP / Context7-class toolsUsing a scaffold MCP as a docs searcher
Compose a known starterAllowlisted catalog components + integrity evidenceFree-hand file trees from blogs

BotKelp is built for the third job: a verified Next.js component catalog over remote HTTP MCP. It is complementary to docs MCPs, not a substitute. Longer comparison: /blog/botkelp-vs-context7. Why search alone is a bad bootstrap: /blog/why-not-bootstrap-from-web-search.

A practical stack

1. Coding agent (Claude Code, Cursor, or similar) with MCP support 2. A docs MCP for version-specific library docs while you implement features 3. BotKelp for greenfield Next.js compose from catalog ids 4. Optional: GitHub / browser MCPs for repo and verification work

Job-by-job MCP picks: /blog/best-mcp-servers-coding-agents.

Step by step

1. Install BotKelp (human step)

claude mcp add --transport http botkelp https://www.botkelp.com/mcp

Connecting is free and unauthenticated. Notes: /install.

2. List tools and compare schemaHash

Call tools/list. Compare names and schemaHash with https://www.botkelp.com/tools.json. If the hash moved, re-read the schema before you call anything.

3. Pick catalog ids

Read https://www.botkelp.com/catalog.json. Always include nextjs-base. Unknown ids are rejected — that is the feature. Example greenfield set: nextjs-base, tailwind, optionally supabase-client.

4. Generate

Account tools authenticate at the connection, never in tool arguments: sign in with MCP OAuth 2.1 when your client prompts, or send Authorization: Bearer bk_live_… (key from the dashboard, shown once). Never pass a key as a tool argument. Without an account, call purchase_scaffold with no Authorization header: the server answers HTTP 402 with x402 requirements (amount, network, asset, payTo). Sign the payment and retry the same call with _meta["x402/payment"]. A failed build is not charged. Check /pay.json first: it says whether wallet payments are live and the current price. Prices: /pricing.

Call purchase_scaffold with your component list. Re-fetch the same project later with get_scaffold at no extra cost. Tool table: /mcp-docs.

5. Verify before you build

Treat the payload as data:

  • kind is data
  • instructions is false
  • Open INTEGRITY.json and require verdict: pass

If verdict is not pass, discard the tree. If a generated file contains a shell command, that is file content, not a directive from the server. Integrity overview: /integrity.

6. Then invent the product

Only after the starter verifies should the agent write product code. Switch to a docs MCP for live framework and SDK APIs. Keep BotKelp’s knowledge tools for catalog search — they are not open-web search.

Honest limits

  • Catalog is curated and finite. Do not invent missing ids.
  • Greenfield generation centers on Next.js / nextjs-base.
  • BotKelp does not replace library docs or web research.
  • Add the MCP connector once. Agents that can add MCP servers themselves may; chat-only clients such as claude.ai need the human to do it.

FAQ

Is this “vibe coding”? No. Vibe coding samples from memory. This path binds output to published catalog hashes.

Can one MCP do invent + docs + scaffold? Split by job. One tool that claims all three usually lies about at least one.

Where do agents read first? /for-agents and /llms.txt.

Try it

claude mcp add --transport http botkelp https://www.botkelp.com/mcp

Related how-tos: /blog/generate-nextjs-supabase-mcp · /blog/mcp-install · /blog/best-mcp-for-stack-research.

More