An interactive command-line tool that demonstrates every major feature of the Claude API from Anthropic. Select a feature from the menu, enter a prompt, and see a real API response — formatted and readable right in your terminal.
Built for developers who want to learn the Claude API by running the calls themselves and reading clean, focused source code.
Companion project: claude-features-app covers the same 16 features as an interactive Next.js web app.
The Claude API has a lot of surface area — streaming, extended thinking, tool use, code execution, citations, memory, and more. Reading the docs is a good start, but there's nothing like running the actual API calls and seeing what comes back.
Every feature in this CLI is:
- Runnable — pick it from the menu, hit Enter, see a real response
- Self-contained — each feature lives in one file under
src/demos/, easy to copy into your own project - Readable — no framework magic, no abstractions, just straightforward TypeScript calling the SDK directly
| Feature | What It Does | Key API Concept |
|---|---|---|
| Text Generation | Send a prompt, get a streamed response | messages.stream() with content_block_delta events |
| Vision | Describe a local image file | Base64 image source in a content block |
| Extended Thinking | See Claude's reasoning before the answer | thinking: { type: "enabled", budget_tokens: N } |
| Structured Outputs | Get JSON that matches your schema exactly | Forced tool use via tool_choice: { type: "tool" } |
| Citations | Responses grounded in source documents | citations: { enabled: true } on document blocks |
| PDF Support | Upload and analyze a local PDF file | Base64 PDF document source |
| Effort Control | Trade speed and cost for response quality | output_config: { effort: "low" | "medium" | "high" } |
| Search Results (RAG) | Feed search results, get cited answers | search_result content blocks |
| Feature | What It Does | Key API Concept |
|---|---|---|
| Tool Use | Claude calls your custom functions | Client-side tools with agentic loop |
| Web Search | Claude searches the web in real-time | web_search_20250305 server tool |
| Web Fetch | Claude fetches and reads a URL | web_fetch_20250910 server tool |
| Code Execution | Claude writes and runs code in a sandbox | code_execution_20250825 server tool |
| Memory | Claude stores and recalls info across turns | memory_20250818 client tool with agentic loop |
| Feature | What It Does | Key API Concept |
|---|---|---|
| Token Counting | Count tokens before sending a request | messages.countTokens() — no tokens consumed |
| Prompt Caching | Cache system prompts to save cost | cache_control: { type: "ephemeral" } on content blocks |
| Batch Processing | Send multiple requests at 50% cost savings | messages.batches.create(), retrieve(), results() |
- Node.js 18+
- An Anthropic API key
git clone https://github.com/robcost/claude-features-cli.git
cd claude-features-cli
npm installexport ANTHROPIC_API_KEY=sk-ant-...
npm run devIf ANTHROPIC_API_KEY is not set, the CLI will prompt you to enter it at startup. The key is used directly in memory and never written to disk.
You'll see a menu like this:
╔═══════════════════════════════════════╗
║ Claude API Features Explorer CLI ║
╚═══════════════════════════════════════╝
16 hands-on demos of every Claude API feature
? Select a feature to demo:
─── Model Capabilities ───
❯ Text Generation Basic Messages API with streaming
Vision Analyze images — provide a local file path
Extended Thinking See Claude's step-by-step reasoning
...
─── Tools ───
Tool Use Client-side tools with agentic loop
...
Pick a feature, choose a model, enter your prompt. That's it.
Each demo lets you choose which model to use:
| Model | Best For |
|---|---|
| Sonnet 4.6 (default) | Fast, capable, cost-effective |
| Haiku 4.5 | Fastest responses, lowest cost |
| Opus 4.6 | Most capable, best for complex reasoning |
Unlike the companion web app — which routes requests through a Next.js server — this CLI calls the Anthropic SDK directly from the same Node.js process. There is no HTTP layer between you and the API.
Terminal Input
│
▼
src/index.ts ← menu loop, model selection, API key
│
▼
src/demos/xyz.ts ← one file per feature, handles prompts + output
│
▼
@anthropic-ai/sdk ← direct SDK call, no intermediary
│
▼
Anthropic API
│
▼
chalk + renderMarkdown ← formatted terminal output
Streaming demos (Text Generation, Vision, Extended Thinking, etc.) collect tokens internally while showing a live character count, then render the complete response as formatted markdown when the stream ends. This gives you clean, readable output while still making a real streaming API call under the hood.
Extended Thinking is the exception — the thinking content streams in real-time in dim gray so you can watch it reason, and only the final answer is buffered and formatted.
All text responses are rendered with a built-in chalk-based markdown renderer (src/utils/display.ts → renderMarkdown). No external markdown library is used. It handles:
- Headings (H1–H3)
- Bold, italic, bold-italic
- Inline code and fenced code blocks
- Bullet and numbered lists
- Blockquotes
- Horizontal rules
- Links (label shown, URL stripped)
- Strikethrough
The Structured Outputs demo uses forced tool use — the correct, documented mechanism for schema-constrained JSON from Claude. A tool is defined with your JSON schema as its input_schema, and tool_choice: { type: "tool", name: "..." } forces Claude to always call it. Claude's tool inputs are always validated against the schema before the API returns.
The Memory demo keeps a Record<string, string> store in-process. It persists across multiple runs of the Memory feature within the same CLI session, so you can run it twice to see state accumulate.
claude-features-cli/
├── src/
│ ├── index.ts # Entry point: API key resolution + main menu loop
│ ├── types.ts # Feature list and model definitions
│ ├── client.ts # Anthropic SDK client factory
│ ├── utils/
│ │ └── display.ts # chalk helpers + renderMarkdown()
│ └── demos/
│ ├── text-generation.ts
│ ├── vision.ts
│ ├── extended-thinking.ts
│ ├── structured-outputs.ts
│ ├── citations.ts
│ ├── pdf-support.ts
│ ├── effort-control.ts
│ ├── search-results.ts
│ ├── tool-use.ts
│ ├── web-search.ts
│ ├── web-fetch.ts
│ ├── code-execution.ts
│ ├── memory.ts
│ ├── token-counting.ts
│ ├── prompt-caching.ts
│ └── batch-processing.ts
├── .env.example
├── package.json
└── tsconfig.json
Each demo file exports a single run(client, model) function. It handles its own input prompts, API call, and output — fully self-contained and easy to copy into another project.
If you're new to the Claude API, here's a suggested order:
- Text Generation — Start here. This is
messages.stream()with an async iterator. Every other feature builds on this pattern. - Token Counting — Count tokens before sending. Understand cost before you spend it.
- Structured Outputs — See how forced tool use constrains Claude to return valid JSON matching your schema.
- Extended Thinking — Watch Claude reason step-by-step. Set the
budget_tokenshigh and ask a hard question. - Tool Use — The most important advanced feature. See how the agentic loop works: Claude requests a tool call, you execute it, you return the result, Claude continues.
- Prompt Caching — Run it twice. Compare the
cache_creation_input_tokenson the first call with thecache_read_input_tokenson the second. - Code Execution — See a server-side tool in action. Claude writes Python, runs it in a sandbox, and streams the output.
- Batch Processing — Create a batch, watch it poll, read the results. Understand when async processing makes sense.
- Everything else — Citations, Vision, Memory, Web Search, Web Fetch, PDF Support, Effort Control, Search Results — explore in any order.
For each feature, read the source file first — it's short, focused, and has a comment at the top explaining the key API concept.
- Your API key is read from the
ANTHROPIC_API_KEYenvironment variable, or entered at the prompt - It is stored only in process memory for the duration of the session
- It is never written to disk, logged, or sent anywhere except directly to the Anthropic API
- For production applications, use server-side key management and never expose keys to clients
| Package | Purpose |
|---|---|
@anthropic-ai/sdk |
Official Anthropic SDK |
@inquirer/prompts |
Interactive CLI menus and inputs |
chalk |
Terminal colors and markdown rendering |
ora |
Spinners for async operations |
tsx |
Run TypeScript directly (dev) |
MIT — see LICENSE
Built with Claude Code using the Anthropic API.