Claude Agent SDK 命令行对话 Demo — Development agent for Claude Code
License: MIT Node.js Version.
How to install Claude Agent SDK 命令行对话 Demo
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open weidwonder/claude_agent_sdk_oauth_demo and copy the folder into
~/.claude/agents/.
What Claude Agent SDK 命令行对话 Demo does
License: MIT Node.js Version.
Alternatives in Development
- Nodejs Backend Patterns — Comprehensive guidance for building scalable, maintainable, and production-ready Node.js backend app 31.9k ★
- Agentica Agent — You are a specialized agent for building Python agents using the Agentica SDK 3.6k ★
- Gemini Skills — Skills for the Gemini API, SDK and model/agent interactions 2.3k ★
README
Claude Agent SDK 命令行对话 Demo
[](https://opensource.org/licenses/MIT) [](https://nodejs.org/) [](https://www.python.org/) [](https://docs.claude.com/en/api/agent-sdk/overview) [](https://www.anthropic.com/)
[English Documentation](README.md)
💎 用你的 Claude Pro/Max 订阅额度来调用 SDK 和 API!
**不用单独付费!不用按 Token 计费!直接使用你现有的 Claude Pro/Max 订阅额度!**
这个项目展示如何通过 **OAuth Token** 认证,让你的 Claude Pro/Max 账户额度用于 SDK 和 API 调用。告别昂贵的按 Token 付费,充分利用你已经订阅的固定月费额度!
**包含 TypeScript 和 Python 两个完整实现** - 选择你熟悉的语言,立即开始!
💰 成本对比
| 方式 | 费用模式 | 适用场景 |
|---|---|---|
| OAuth Token (本项目) | 使用 Pro/Max 订阅额度,无额外费用 | ✅ 已有 Pro/Max 订阅的用户 |
| 传统 API Key | 按 Token 使用量计费,每次调用都要钱 | 企业大规模应用 |
**如果你已经是 Claude Pro ($20/月) 或 Max ($200/月) 用户,为什么还要为 API 调用额外付费?**
📁 项目结构
claude-chat-demo/
├── ts_demo/ # TypeScript/JavaScript 版本
│ ├── index.js
│ ├── package.json
│ ├── .env.example
│ └── README.md
├── py_demo/ # Python 版本
│ ├── main.py
│ ├── requirements.txt
│ ├── .env.example
│ └── README.md
└── README.md # 本文件
🎯 功能特性
- ✅ 支持 OAuth Token 认证(推荐用于 Claude Pro/Max 用户)
- ✅ 支持 API Key 认证
- ✅ 简单的命令行交互界面
- ✅ 实时对话体验
- ✅ 提供 TypeScript 和 Python 两种实现
🚀 快速开始
TypeScript 版本
**前置要求**: Node.js 18+
cd ts_demo
npm install
cp .env.example .env
# 编辑 .env 文件,添加 CLAUDE_CODE_OAUTH_TOKEN 或 ANTHROPIC_API_KEY
npm start
详细说明请查看 [ts_demo/README.md](ts_demo/README.md)
Python 版本
**前置要求**: Python 3.8+
cd py_demo
python3 -m venv venv
source venv/bin/activate # macOS/Linux
pip install -r requirements.txt
cp .env.example .env
# 编辑 .env 文件,添加 CLAUDE_CODE_OAUTH_TOKEN 或 ANTHROPIC_API_KEY
python main.py
详细说明请查看 [py_demo/README.md](py_demo/README.md)
🔑 认证配置
方法 A:使用 OAuth Token(推荐)
如果你有 Claude Pro 或 Claude Max 订阅:
# 1. 安装 Claude CLI(如果还没安装)
npm install -g @anthropic-ai/claude-code
# 2. 获取 OAuth Token
claude setup-token
# 3. 复制生成的 token,添加到 .env 文件
CLAUDE_CODE_OAUTH_TOKEN=your-oauth-token-here
方法 B:使用 API Key
从 [Anthropic Console](https://console.anthropic.com) 获取 API Key:
ANTHROPIC_API_KEY=sk-ant-your-api-key-here
💬 使用示例
🤖 Claude Agent SDK 命令行对话 Demo
==================================================
✅ SDK 已初始化
💡 提示:输入 "exit" 或 "quit" 退出对话
你: 你好,介绍一下自己
🤔 Claude 正在思考...
Claude: 你好!我是 Claude,由 Anthropic 开发的 AI 助手...
你: 用 Python 写一个冒泡排序
🤔 Claude 正在思考...
Claude: 好的,这是一个冒泡排序的实现:...
你: exit
👋 再见!
📝 环境变量说明
| 变量名 | 说明 | 必需 |
|---|---|---|
CLAUDE_CODE_OAUTH_TOKEN |
OAuth Token(从 claude setup-token 获取) |
二选一 |
ANTHROPIC_API_KEY |
API Key(从 Ant |
Related Agents
Dashclaw Drift Auditor
Audits DashClaw's drift-prone hardcoded counts and version stamps — SDK method counts (Node/Python), MCP tool/
Metago Dependency Manager
Dependency & Version Manager - specializes in vulnerability scanning, license compliance, version conflict det
Act 1 Setup
Read-only narrative steward for Act I (slides 1-5) of the Workflow SDK GA deck. Covers the cold open, happy-pa
Act 2 Verbs
Read-only narrative steward for Act II (slides 6-14) of the Workflow SDK GA deck. Covers the three workflow sc
Instrumentation Gen
Generates language-specific OpenTelemetry SDK bootstrap files (Node.js / Python) from the context cache. Dispa
Toolchain
Ensures Node/pnpm match proto.json; activates toolchain and fixes version mismatches.
Related Skills
Claude Paper
将研究论文转化为综合学习环境 English 中文 License: MIT Node Version
Product Requirements Document — Agent-skill-manager
Product: agent-skill-manager (asm) Version: 1.10.0 (current) → 3.0 (vision) Author: luongnv89 Date: 2026-03-19
AI Agents Workshop
2-hour workshop: build an AI agent in under 150 lines of Node.js. Concepts, architecture, failure modes, and l