Skip to content

Commit 2332dbc

Browse files
authored
Refresh current Claude prompt surface for v1.2.0
* [OBEY-CAMPAIGN-78887e36] refresh current claude prompt surface for 0.1.1 * [OBEY-CAMPAIGN-78887e36] Fix plugin hook execution and budget enforcement * [OBEY-CAMPAIGN-78887e36] Address inline review feedback * [OBEY-CAMPAIGN-78887e36] Address second review round * [OBEY-CAMPAIGN-78887e36] Correct release numbering to v1.2.0 * [OBEY-CAMPAIGN-78887e36] Polish v1.2.0 release notes
1 parent 310bc57 commit 2332dbc

31 files changed

Lines changed: 1896 additions & 556 deletions

File tree

README.md

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@
77
<a href="https://pkg.go.dev/github.com/lancekrogers/claude-code-go"><img src="https://pkg.go.dev/badge/github.com/lancekrogers/claude-code-go.svg" alt="Go Reference"></a>
88
</p>
99

10-
A comprehensive Go library for programmatically integrating the Claude Code CLI into Go applications. Build AI-powered coding assistants, automated workflows, and intelligent agents with full control over Claude Code's capabilities.
10+
A comprehensive Go library for programmatically integrating the Claude Code CLI into Go applications. Build AI-powered coding assistants, automated workflows, and intelligent agents on top of Claude Code's non-interactive `-p/--print` surface.
1111

1212
First Claude Code SDK, released before any official SDKs existed.
1313

14+
This SDK intentionally wraps the prompt-oriented `claude -p` workflow. Interactive sessions and management subcommands such as `auth`, `mcp`, `plugins`, `install`, and `update` remain out of scope.
15+
1416
## Highlights
1517

16-
- Full CLI wrapper with text/json/stream-json outputs
18+
- Current `claude -p` wrapper with text/json/stream-json outputs
1719
- Streaming, sessions (resume/fork), and context-aware APIs
1820
- MCP integration with fine-grained tool permissions
21+
- Current prompt flags including agents, effort, settings, tools, and budget controls
1922
- Subagents, plugins, retries, and budget tracking for production workflows
2023
- 9 interactive demos and comprehensive tests
2124

2225
## Features
2326

2427
### Core Capabilities
2528

26-
- **Full CLI Wrapper**: Complete access to all Claude Code features
29+
- **Prompt Surface Wrapper**: Accurate coverage of the current non-interactive `claude -p` flag surface
2730
- **Streaming Support**: Real-time response streaming with context cancellation
2831
- **Session Management**: Multi-turn conversations with custom IDs, forking, and persistence control
2932
- **MCP Integration**: Model Context Protocol support for extending Claude with external tools
@@ -218,8 +221,14 @@ pm.Register(filter, nil)
218221
audit := claude.NewAuditPlugin(1000) // Keep last 1000 records
219222
pm.Register(audit, nil)
220223

224+
ctx := context.Background()
225+
if err := pm.Initialize(ctx); err != nil {
226+
log.Fatal(err)
227+
}
228+
defer pm.Shutdown(ctx)
229+
221230
// Use with client
222-
result, err := cc.RunPrompt("Do something", &claude.RunOptions{
231+
result, err := cc.RunPromptCtx(ctx, "Do something", &claude.RunOptions{
223232
PluginManager: pm,
224233
})
225234

@@ -263,20 +272,21 @@ fmt.Printf("Spent: $%.4f, Remaining: $%.4f\n",
263272
// Define specialized agents
264273
agents := map[string]*claude.SubagentConfig{
265274
"security": {
266-
Description: "Security analysis and vulnerability detection",
267-
SystemPrompt: "You are a security expert. Analyze code for vulnerabilities.",
268-
AllowedTools: []string{"Read(*)", "Grep(*)"},
269-
Model: "opus",
275+
Description: "Security analysis and vulnerability detection",
276+
Prompt: "You are a security expert. Analyze code for vulnerabilities.",
277+
Tools: []string{"Read(*)", "Grep(*)"},
278+
Model: "opus",
270279
},
271280
"testing": {
272-
Description: "Test generation and coverage analysis",
273-
SystemPrompt: "You are a testing expert. Generate comprehensive tests.",
274-
AllowedTools: []string{"Read(*)", "Write(*)", "Bash(go test*)"},
281+
Description: "Test generation and coverage analysis",
282+
Prompt: "You are a testing expert. Generate comprehensive tests.",
283+
Tools: []string{"Read(*)", "Write(*)", "Bash(go test*)"},
275284
},
276285
}
277286

278-
// Use agents
287+
// Define agents and select one for this run
279288
result, err := cc.RunPrompt("Analyze this code", &claude.RunOptions{
289+
Agent: "security",
280290
Agents: agents,
281291
})
282292
```
@@ -349,7 +359,8 @@ result, err = cc.RunPrompt("Safe operations only", &claude.RunOptions{
349359
```go
350360
type RunOptions struct {
351361
// Output format
352-
Format OutputFormat // text, json, stream-json
362+
Format OutputFormat // text, json, stream-json
363+
InputFormat InputFormat // text, stream-json (stdin with --print)
353364

354365
// Prompts
355366
SystemPrompt string // Override default system prompt
@@ -362,6 +373,11 @@ type RunOptions struct {
362373
ForkSession bool // Fork from resumed session
363374
NoSessionPersistence bool // Don't save to disk
364375

376+
// Agent selection
377+
Agent string // Select a named agent for this run
378+
Agents map[string]*SubagentConfig // Inline agent definitions for --agents
379+
AgentsJSON string // Raw JSON passed directly to --agents
380+
365381
// MCP configuration
366382
MCPConfigPath string // Single MCP config path
367383
MCPConfigs []string // Multiple MCP configs
@@ -370,26 +386,41 @@ type RunOptions struct {
370386
// Tool permissions
371387
AllowedTools []string // Tools Claude can use
372388
DisallowedTools []string // Tools Claude cannot use
373-
PermissionMode PermissionMode // default, acceptEdits, bypassPermissions
389+
PermissionMode PermissionMode // default, acceptEdits, auto, bypassPermissions, dontAsk, plan
374390

375391
// Model selection
376-
Model string // Full model name
377-
ModelAlias string // sonnet, opus, haiku
378-
379-
// Execution control
380-
MaxTurns int // Limit agentic turns
381-
Timeout time.Duration // Request timeout
382-
383-
// Budget control
384-
MaxBudgetUSD float64 // Spending limit
392+
Model string // Full model name
393+
ModelAlias string // sonnet, opus, haiku
394+
Effort EffortLevel // low, medium, high, xhigh, max
395+
396+
// CLI prompt surface
397+
MaxBudgetUSD float64
398+
Settings string
399+
SettingSources []string
400+
Tools []string
401+
Name string
402+
PluginDirs []string
403+
Bare bool
404+
Brief bool
405+
Betas []string
406+
Files []string
407+
Debug string
408+
DebugFile string
409+
IncludeHookEvents bool
410+
IncludePartialMessages bool
411+
ReplayUserMessages bool
412+
ExcludeDynamicSystemPromptSections bool
413+
AllowDangerouslySkipPermissions bool
414+
Timeout time.Duration
415+
416+
// Lifecycle extensions
385417
BudgetTracker *BudgetTracker // Shared tracker
386-
387-
// Extensions
388-
Agents map[string]*SubagentConfig // Specialized agents
389-
PluginManager *PluginManager // Plugin system
418+
PluginManager *PluginManager // Plugin hooks
390419
}
391420
```
392421

422+
Deprecated compatibility fields remain in `RunOptions` for now, but the SDK no longer emits removed CLI flags such as `--max-turns`, `--config`, `--disable-autoupdate`, `--theme`, or `--permission-prompt-tool`.
423+
393424
### Core Methods
394425

395426
```go
@@ -475,7 +506,7 @@ just lint
475506

476507
- [docs/DEMOS.md](docs/DEMOS.md)
477508
- [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md)
478-
- [docs/RELEASE_NOTES_v1.0.0.md](docs/RELEASE_NOTES_v1.0.0.md)
509+
- [docs/RELEASE_NOTES_v1.2.0.md](docs/RELEASE_NOTES_v1.2.0.md)
479510

480511
## Contributing
481512

docs/RELEASE_NOTES_v1.0.0.md

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)