mark3labs/kit/kit-sdk

Claude Code and agent skill by mark3labs/kit

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Guide for building Go applications with the Kit SDK. Use when the user asks to create a program, service, script, or application that uses Kit programmatically as a Go library — e.g. embedding LLM interactions, building agents, creating CLI tools powered by Kit, or integrating Kit into backend services. Do NOT use for Kit extensions (use kit-extensions skill instead).

Install

npx vskill@latest install mark3labs/kit/kit-sdk

SKILL.md

Kit SDK Development Guide

The Kit SDK (pkg/kit) lets you embed Kit's full agent capabilities — LLM interactions, tool execution, session management, streaming, hooks — into any Go application. Unlike extensions (which are interpreted scripts running inside Kit's TUI), SDK programs are standalone compiled Go binaries.

This file is the entry point. It gives the installation, a quick start, the core lifecycle, and the rules you must never miss. Detailed material lives in the references/ directory (see Reference files below). Read only the reference files that apply to your task.

Installation

bash
go get github.com/mark3labs/kit

Import path (alias recommended):

go
import kit "github.com/mark3labs/kit/pkg/kit"

Quick Start

go
package main
import (
"context"
"fmt"
"log"
kit "github.com/mark3labs/kit/pkg/kit"
)
func main() {
ctx := context.Background()
host, err := kit.New(ctx, nil) // nil = normal config-file discovery and field resolution
if err != nil {
log.Fatal(err)
}
defer func() { _ = host.Close() }()
response, err := host.Prompt(ctx, "What is 2+2?")
if err != nil {
log.Fatal(err)
}
fmt.Println(response)
}

Core Lifecycle

  1. Create: kit.New(ctx, opts) — loads config, initializes MCP servers, creates LLM provider, sets up agent
  2. Interact: host.Prompt(ctx, msg) — send messages, agent uses tools as needed
  3. Close: host.Close() — cleans up MCP connections, model resources, session file handle

Always defer Close():

go
defer func() { _ = host.Close() }()

API Map

AreaEntry pointsReference
Configure the instancekit.Options{Model, SystemPrompt, MaxSteps, Tools, ExtraTools, NoSession, ...}, kit.NewIsolatedAgent / kit.Isolated() for hermetic embedsreferences/options.md
Talk to the agentPrompt, PromptResult, PromptResultWithFiles, PromptWithOptions, Steer, FollowUp, PromptResultWithMessagesreferences/prompt-methods.md
Observe (read-only)host.OnToolCall(...), host.OnMessageUpdate(...), host.Subscribe(...)references/events.md
Intercept (read-write)host.OnBeforeToolCall(priority, fn), OnAfterToolResult, OnBeforeTurn, OnPrepareStep, OnContextPrepare, OnBeforeCompactreferences/hooks.md
Add capabilitieskit.NewTool(name, desc, fn), kit.TextResult, built-in tool constructors and bundlesreferences/tools.md
Persist conversationsSessionPath, Continue, NoSession, instance and package-level session methodsreferences/sessions.md
Decision APIkit.Decide, host.Decide, GetDecisionModels, typed question builders, custom decision providers (kit.RegisterDecisionProvider, Options.DecisionProviders)references/decisions.md
Models and MCPhost.SetModel, model registry, custom provider backends (kit.RegisterProvider, Options.Providers), AddMCPServer, in-process servers, MCP OAuthreferences/models-and-mcp.md
Manage the context windowEstimateContextTokens, Compact, AutoCompact, host.Subagentreferences/context-compaction-subagents.md

A minimal custom tool, which is the most common extension point:

go
type WeatherInput struct {
City string `json:"city" description:"City name, e.g. 'San Francisco'"`
}
weatherTool := kit.NewTool("get_weather", "Get current weather for a city",
func(ctx context.Context, input WeatherInput) (kit.ToolOutput, error) {
return kit.TextResult("72°F, sunny in " + input.City), nil
},
)
host, _ := kit.New(ctx, &kit.Options{
ExtraTools: []kit.Tool{weatherTool},
})

Critical Rules (never skip)

  1. `Tools` replaces, `ExtraTools` adds. Options.Tools replaces default core tools, not MCP or extension tools. Options.ExtraTools adds tools alongside the defaults. Use Tools to replace core tools; use ExtraTools to extend them.
  2. Register events and hooks before calling `Prompt`. Subscribers and hooks return an unsubscribe function — defer unsub() if the handler must not outlive a scope.
  3. Events are read-only; hooks are read-write. Use host.On<Event> to observe. Use host.On<Hook>(priority, fn) to block, modify, or inject. In hooks, return nil to allow/pass through; the first non-nil result wins. Lower priority values run first (kit.HookPriorityHigh = 0, Normal = 50, Low = 100).
  4. Pointer fields mean "unset". Generation parameters like Temperature, TopP, TopK are pointers so an explicit 0.0 differs from "leave the provider default". Zero-value MaxTokens auto-resolves; a non-zero value suppresses right-sizing.
  5. Sessions persist automatically as JSONL tree files. No explicit save call exists or is needed. Use NoSession: true for ephemeral, in-memory agents (scripts, subagents, tests).
  6. Context-window fill is not `InputTokens` alone. With prompt caching, sum InputTokens + CacheReadTokens + CacheCreationTokens + OutputTokens from result.FinalUsage.
  7. Reactive compaction is always on. A context-overflow error triggers one compact-and-replay. AutoCompact: true adds proactive compaction before turns that near the limit. If the replay still overflows, the turn fails with kit.ErrContextOverflow.
  8. MCP OAuth is opt-in. If MCPAuthHandler is nil, remote MCP servers that require OAuth fail with an authorization-required error. They do not open a browser silently.
  9. No dependency-name leakage. Use the kit.LLM* type aliases (LLMMessage, LLMUsage, ...) and kit.ConvertToLLM* helpers. Do not import the underlying LLM library into SDK-facing code.
  10. Configuration file selection is not field precedence. An explicit ConfigFile selects only that file; otherwise project config is preferred to home config. Effective generation/provider fields use explicit SDK values → environment → configuration → per-model/fallback values. Stored credentials beat provider environment variables unless explicitly overridden. See references/configuration.md. kit.New handles setup; use kit.InitConfig only for special cases.

Reference files

Read the file that matches the task. Paths are relative to this skill's root directory.

FileRead it when you need...
references/options.mdEvery kit.Options field with comments (model, behavior, generation parameters, provider overrides, session, tools, skills, feature toggles, compaction, MCP OAuth, in-process MCP), the generation/provider cheat-sheet table, and isolated agents (NewIsolatedAgent, Isolated, opt-in options).
references/prompt-methods.mdAll prompt variants: simple string, full result with usage stats, multimodal file attachments, per-call system message injection, system-level steering, continue without new input, multiple user messages in one turn.
references/events.mdTyped convenience subscribers, the generic subscriber, the full list of event types with their fields, and tool-kind constants.
references/hooks.mdEach hook (BeforeToolCall, AfterToolResult, BeforeTurn, AfterTurn, PrepareStep, ContextPrepare, BeforeCompact) with result types, plus hook priorities.
references/tools.mdCreating custom tools with kit.NewTool (schema auto-generation, struct tags, output helpers), built-in tool constructors, tool bundles, tool options, using tools in Options, querying tools at runtime.
references/sessions.mdSession modes, instance methods, package-level session operations, and implementing a custom SessionManager.
references/models-and-mcp.mdModel management at creation and runtime, the model registry, model string format, per-model system prompts and generation parameters, custom provider backends (ProviderFactory); dynamic MCP server management, in-process MCP servers, MCP prompts, MCP resources, MCP OAuth authorization and token storage.
references/context-compaction-subagents.mdContext token estimation, GetContextStats, manual and automatic compaction, reactive compaction; in-process subagents, subscribing to subagent events, named agents.
references/extension-api-auth-skills.mdThe ExtensionAPI (kit.Extensions()), credential management (auth), and skill loading/prompt building.
references/types.mdThe full list of re-exported types (LLMMessage, LLMUsage, tool types, event types, errors, ...).
references/common-patterns.mdRecipes: scripting/CLI pipe, long-running autonomous agent, streaming output to terminal, multi-turn conversation with memory, tool execution monitoring, guard rails with hooks, parallel subagents, read-only analysis agent.
references/configuration.mdConfig file discovery order, ${ENV_VAR} expansion, kit.InitConfig and kit.InitConfigWithOptions.

Key Files for Reference

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
143
Repository forks
30
7-day trend score
24

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mark3labs/kit/kit-sdk/badge)](https://verified-skill.com/skills/mark3labs/kit/kit-sdk)

Something wrong with this skill or its page? Tell us.