Build with Claude Code
Konstera is designed so an LLM coding agent can build a working agent for you end-to-end — from scaffold through local test through deploy — without you reading the SDK source. This page is the single-source-of-truth preamble to give the coding agent before you start.
Same guide works for Claude Code, Cursor, Windsurf, ChatGPT, or any other LLM that can edit files + run commands. Just paste the Preamble section into your agent before asking it to build.
Install the Konstera plugin (Claude Code only)#
If you're on Claude Code, there's a native plugin that gives it first-class access to your tenant — your connectors, LLM engines, glossary, and more — via MCP, so Claude Code can author agents against what your tenant actually has, not training-data defaults.
Only want the tools, not the plugin's skills and commands? Connect Claude
Code (or Cursor) straight to https://api.konstera.ai/mcp/devx and sign in
in the browser: see Add Konstera to Claude Code or Cursor.
Use one way, not both.
One command installs + activates it:
# macOS / Linux
curl -fsSL https://konstera.ai/install/plugin-claude-code.sh | sh
# Windows (PowerShell)
irm https://konstera.ai/install/plugin-claude-code.ps1 | iex
Before you run it, install Claude Code itself — the Konstera installer adds the plugin to an existing Claude Code, it doesn't install Claude Code:
# Windows (PowerShell)
irm https://claude.ai/install.ps1 | iex
# macOS / Linux
curl -fsSL https://claude.ai/install.sh | bash
Then open a new terminal. Full guide: Claude Code setup.
What the script does:
- Checks everything it needs and reports it in one list — marked
[ OK ],[ WARN ]or[MISSING], with the fix for each. If anything required is missing it stops before installing anything. - Installs the
konsteraCLI, or updates it if it's older than 0.3.2. - Downloads and verifies the plugin.
- Adds it to Claude Code with Claude Code's own
claude plugin install, so every new Claude Code session loads it — no flags, no config files.
To see the dependency report without installing anything:
# Windows (PowerShell)
$env:KONSTERA_CHECK_ONLY = "1"; irm https://konstera.ai/install/plugin-claude-code.ps1 | iex
# macOS / Linux
curl -fsSL https://konstera.ai/install/plugin-claude-code.sh | KONSTERA_CHECK_ONLY=1 sh
| Checked | Windows | macOS / Linux | Required |
|---|---|---|---|
| Operating system | 64-bit Windows 10 (1809) or later | macOS or Linux, x86_64 or arm64 | Yes |
| Shell and tools | PowerShell 5.1+, TLS 1.2 | curl, tar, gzip, sha256sum or shasum | Yes |
| Network (HTTPS) | konstera.ai, api.konstera.ai, platform-api.konstera.ai, api.github.com, github.com, release-assets.githubusercontent.com | same | Yes |
| Claude Code | claude installed and new enough to support plugins (claude update if not) | same | Yes |
| Konstera CLI | installed or updated by the script | same | No |
| Git | optional; Claude Code's Bash tool uses Git Bash on Windows | optional | No |
You don't need an Administrator window: everything installs for your own
user. If Claude Code is installed but claude isn't on your PATH yet, the
script still finds it and prints the PATH fix.
When it finishes, open (or restart) Claude Code, then inside Claude Code run:
/konstera-signin
A tenant admin approves the pairing in a browser, and Claude Code lights up with Konstera MCP tools. From that point on, the Preamble below plus a sentence like "build me a refund-eligibility agent" produces working code against your real tenant shape.
Not on Claude Code? The Preamble pattern works identically for Cursor, Windsurf, ChatGPT or any other LLM that edits files + runs commands — just paste it as the first message. Native plugins for those tools are planned (ADR-057).
Preamble (paste this to your coding agent)#
You are building a Konstera agent.
What a Konstera agent is: an OCI container that speaks the Model Context Protocol (MCP). It subclasses
konstera_sdk.Agent(Python) or inherits fromKonstera.Sdk.Agent(.NET), overrideshandle(), callsrun(). The agent reaches back to the kernel for LLM calls, state, credentials, logging viactx.log,ctx.llm,ctx.state, etc.Entry point —
konstera_sdk.Agent+run():Pythonfrom konstera_sdk import Agent, AgentContext, AgentRequest, AgentResponse, run class MyAgent(Agent): async def handle(self, req: AgentRequest, ctx: AgentContext) -> AgentResponse: await ctx.log.info("hello", input=req.input) return AgentResponse(content=f"got: {req.input}") run(MyAgent())Services available on
ctx:log,llm,state,vector,credentials,cost,tool,agents,artifact,human,rule,connector,capability,semantic. All are async methods. See /docs/kernel for the full surface.Required files:
main.py— the agent codemanifest.json— see /docs/manifest-schema for the full schemaDockerfile— multi-stage,pip install konstera-sdkRules:
- Prefer
purpose="narrator"overmodel="claude-sonnet-4-6"for LLM calls so the tenant admin can rebind without touching your code.- For optional capabilities, call
await ctx.capability.available(name)beforectx.capability.call(name, ...)— otherwiseCapabilityUnboundraises.- Never log a secret value (
ctx.credentials.get()returns one — don't echo).- Agents MUST not import vendor SDKs (
shopify,stripe, …). Go viactx.capability.call(...)instead — the full set of canonical names lives in the capability catalogue. See /docs/kernel#capability and /docs/errors for why.Env vars the kernel injects (don't set these yourself — see /docs/env-vars):
KONSTERA_KERNEL_MCP_URL,KONSTERA_AGENT_INSTANCE_ID,KONSTERA_TENANT_ID,KONSTERA_AGENT_ID,KONSTERA_AGENT_VERSION.Common pitfalls: see /docs/errors for every error the SDK/CLI/API can emit + how to recover.
To validate your work:
Terminal# Local run in direct-run mode (no kernel): pip install -e . python -m main # Then POST a test invocation: curl -X POST http://localhost:8080/invoke \ -H content-type:application/json \ -d '{"invocationId":"test-1","input":"hello","config":{}}'Reference agents to copy patterns from: github.com/Konstera/agents —
hello-world-pythonfor the minimum shape,customer-service-agentfor a real reference with kernel services + eval harness + ADR-037 context service.
Three authoring patterns#
| Pattern | Tools | Status | What you get |
|---|---|---|---|
| A — IDE-integrated | Cursor, Windsurf, Claude Code | Works today | The coding agent edits files and runs commands in your repo |
| B — Chat with MCP | Claude Desktop + Konstera MCP | Works today | Your tenant's connectors, models, agents and runs, and manifest validation, as chat tools |
| C — Pure chat | ChatGPT, Claude.ai web, Gemini | Works today | Three files to save to disk; you build + deploy manually |
Pattern A — IDE-integrated (Cursor, Windsurf, Claude Code)#
- Clone a reference agent as a starterTerminal
git clone https://github.com/Konstera/agents cp -r agents/hello-world-python my-agent && cd my-agent - Open in your IDEPaste the Preamble into the agent chat.
- Describe what you want to build
"Build a Konstera agent that triages inbound support tickets by severity and drafts a reply. Use
ctx.capability.call('tickets.list_new')to fetch tickets,ctx.llm.complete(purpose='classifier')for severity, andctx.human.request(tier='T1')for approval before replying viactx.capability.call('tickets.reply')." - Review the generated codeRun through the review checklist below.
- Smoke-test, then shipRun locally in direct-run mode to smoke-test, then build + deploy.
handle()isasync- All kernel calls are
await-ed AgentResponseis returned, not raised- Optional capabilities are guarded by
available()
Pattern B — Chat with MCP (Claude Desktop + Konstera DevX MCP)#
- Add Konstera as a connectorIn Claude Desktop, open Customize › Connectors › + Add › Add custom connector with the URL
https://api.konstera.ai/mcp/devx, click Connect and sign in with your Konstera account. Claude then acts as you, with your role. Details and the alternative (the Konstera extension): Add Konstera to Claude Desktop. - Ask about your tenantClaude can now list your connectors, models and agents, look at runs, and validate a manifest while you design the agent.
Prefer Konstera running on your computer? Install the Konstera extension instead, or, if you already use the CLI, run konstera plugin activate claude-desktop (quit Claude Desktop first). Use one way only, or Claude sees the Konstera tools twice.
Pattern C — Pure chat (ChatGPT, Claude.ai web, Gemini)#
- Prime the chatPaste the Preamble + your requirements into the chat.
- Ask for the three files
main.py,manifest.json,Dockerfile. - Save and shipSave to disk. Build + deploy manually.
- Check every method nameIf the chat LLM hallucinates a method name (e.g.
ctx.database.query), check against /docs/kernel — only the 15 services listed there exist.
Four workflows that come up often#
| Workflow | You give the coding agent | You should get back | Status |
|---|---|---|---|
| Scaffold from a one-sentence requirement | The requirement | A working agent | Works today |
| Edit-test-fix loop | The failing error | A graceful fallback | Works today |
| Capture fixtures from a live run | — | — | Planned |
| Debug a failing invocation | Trace + handle() code | Root cause + fix | Works today |
"Scaffold from a one-sentence requirement"#
Build a Konstera agent that polls a Zendesk inbox every hour, classifies new
tickets by product area, and routes them to the right team's Slack channel.
Use ctx.capability.call('tickets.list_new') for polling and
ctx.capability.call('chat.reply') for Slack. Classification uses
ctx.llm.complete(purpose='classifier').
Expected output: a working agent with manifest schedule + capability declarations + handle() logic + a reasonable prompt.
"Edit-test-fix loop"#
The invocation is failing with CapabilityUnbound: Agent has no binding for
'tickets.reply'. Fix the agent so it falls back gracefully.
Expected fix: wrap the tickets.reply call with await ctx.capability.available(name)
and route to ctx.log.warn() + ctx.human.request(tier='T1', ...) fallback.
"Capture fixtures from a live run"#
Planned Planned via konstera dev --record (per roadmap). Not shipping yet.
"Debug a failing invocation"#
Open the portal invocation trace. Paste the exception + stack trace + the relevant handle() code into your coding agent with:
This Konstera agent invocation failed with the attached trace. The agent's
handle() code is attached. Diagnose the root cause and fix.
The coding agent should be able to identify things like missing await,
unguarded optional capability calls, or incorrect manifest needs[]
declarations.
Pattern gotchas (what coding agents commonly get wrong)#
| Gotcha | ❌ Coding agent writes | ✅ Should write |
|---|---|---|
| 1. Import vendor SDKs | import shopify | ctx.capability.call(...) |
2. Forget await | ctx.log.info("x") | await ctx.log.info("x") |
| 3. Return instead of raise | an exception for a business error | return AgentResponse(...) |
| 4. Store secrets in config | req.config["stripe_key"] | ctx.credentials.get(...) |
5. Over-declare needs[] | services the code never calls | only what the code uses |
| 6. Hard-code the model | model="claude-sonnet-4-6" | purpose="narrator" |
Why each one matters:
-
Import vendor SDKs. ❌
import shopify/ ✅await ctx.capability.call("orders.lookup_by_id", ...). Vendor-specific logic goes in the connector, not the agent — this is the whole point of the capability layer. See /docs/kernel. -
Forget
await. The SDK is fully async. Everyctx.*call returns a coroutine.ctx.log.info("x")withoutawaitis a no-op — the message is never sent. -
Return instead of raise. Business errors go in the response:
return AgentResponse(content="", structured={"error": "..."}). Exceptions mean "the invocation itself failed" and produce HTTP 500 — reserve them for actual bugs. -
Store secrets in config. ❌
req.config["stripe_key"]/ ✅await ctx.credentials.get("stripe-api-key"). Config is per-instance tenant-set tenant-visible; credentials are tenant-scoped encrypted. -
Over-declare
needs[]. The manifest'sneeds[]is a permission list — the kernel refuses runtime calls to anything not declared. But over-declaring broadens the capability footprint shown in the portal (and under some policies, blocks install). Only list what you actually use. -
Hard-code
model="claude-sonnet-4-6". Preferpurpose="narrator"— the tenant admin can rebind the purpose to a different model + credentials via portal without redeploying your agent.
What next#
Every error you might hit + how to recover.
Every env var the SDK/kernel reads.
Full JSON Schema, every field.
All 15 services with examples.
Recipe examples for common patterns.
Editor-specific setup for the same Preamble.