No description
  • TypeScript 100%
Find a file
keeb 253ac2a9c2 feat: run Claude through the local claude CLI (cli_generate, cli_generate_many)
Upstreams the CLI methods from swamp-club's repo-local claude_cli.ts into
the base @keeb/anthropic/claude model:

- cli_generate: headless `claude -p` with no tools in an empty temp dir,
  authenticated by the CLI login; optional jsonSchema for structured
  output, kept on result.structured
- cli_generate_many: bounded-concurrency batch, one cliResult per request,
  failures recorded with ok:false; duplicate keys are rejected

apiKey is now optional (only generate needs it) and marked sensitive;
no-op upgrade to 2026.10.15.1. generate checks the response shape, both
backends log entry/completion, and claude_test.ts covers both backends
with a stubbed fetch and a fake claude on PATH. README and the bundled
skill are rewritten for current swamp commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:51:54 -07:00
.claude/skills/anthropic feat: run Claude through the local claude CLI (cli_generate, cli_generate_many) 2026-10-15 13:51:54 -07:00
extensions/models feat: run Claude through the local claude CLI (cli_generate, cli_generate_many) 2026-10-15 13:51:54 -07:00
tests/property Add property-based schema tests (fast-check via @traversable/zod-test) 2026-07-18 09:19:17 -07:00
.gitignore feat: add descriptions to all schema fields 2026-03-13 08:28:46 -07:00
.swamp.yaml feat: add descriptions to all schema fields 2026-03-13 08:28:46 -07:00
CLAUDE.md Initial commit: @keeb/anthropic swamp extension 2026-03-13 08:17:45 -07:00
LICENSE.txt feat: run Claude through the local claude CLI (cli_generate, cli_generate_many) 2026-10-15 13:51:54 -07:00
manifest.yaml feat: run Claude through the local claude CLI (cli_generate, cli_generate_many) 2026-10-15 13:51:54 -07:00
README.md feat: run Claude through the local claude CLI (cli_generate, cli_generate_many) 2026-10-15 13:51:54 -07:00

@keeb/anthropic

Swamp extension for generating text with Anthropic Claude, via the Messages API or the local claude CLI.

Models

@keeb/anthropic/claude

Method Backend Description
generate Messages API Generate text from prompt. Requires apiKey.
cli_generate claude CLI Generate text from prompt; optional jsonSchema for structured output (lands in structured), effort, timeoutSeconds.
cli_generate_many claude CLI Run a batch of requests ({key, prompt, systemPrompt?, jsonSchema?}) with bounded concurrency; one cliResult per request.

Global arguments: apiKey (only for generate), model, systemPrompt, maxTokens (only for generate)

The cli_* methods run claude -p headless with no tools, in an empty temp directory (so no repo CLAUDE.md or settings leak in), authenticated by the CLI's own login. They never read apiKey. Claude Code must be installed and logged in on the host that runs the method.

Install

swamp extension pull @keeb/anthropic

Usage

With an API key:

swamp model create @keeb/anthropic/claude claude --global-arg model=claude-opus-5-5
swamp behavior run claude generate --input prompt="Summarize the release notes"

With the local claude login (no key):

swamp behavior run claude cli_generate --input prompt="Summarize the release notes"

generate and cli_generate write the result resource (response, structured?, model, timestamp), readable downstream via data.latest("claude", "result").attributes.response. cli_generate_many writes cliResult instances named cli-<batch>-<key> with ok, response, structured, error, costUsd, and durationMs; a failed request is recorded with ok: false rather than failing the batch.

License

MIT