Skip to content

Commit f26aa58

Browse files
JiriDeJongheclauderodrigo-olivareszealoushacker
authored
Add Claude Code SDK tutorials and examples (anthropics#195)
* Add Claude Code SDK tutorials and examples This PR adds comprehensive tutorials and examples for the Claude Code SDK, including: - Research agent implementation with web search capabilities - Chief of Staff agent with multi-agent coordination - Observability agent with Docker configuration - Supporting utilities and documentation The examples demonstrate key SDK features: - Multi-turn conversations with ClaudeSDKClient - Custom output styles and slash commands - Hooks for automated actions and governance - Script execution via Bash tool - Multi-agent orchestration patterns --------- Co-authored-by: Claude <[email protected]> Co-authored-by: rodrigo olivares <[email protected]> Co-authored-by: Alex Notov <[email protected]>
1 parent fa326a4 commit f26aa58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3978
-10
lines changed

.claude/commands/link-review.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ Provide a clear summary with:
2828

2929
If all links look good, provide a brief confirmation.
3030

31-
**IMPORTANT: Post your review as a comment on the pull request using the command: `gh pr comment ${{ github.event.pull_request.number }} --body "your review content"`**
31+
**IMPORTANT: Post your review as a comment on the pull request using the command: `gh pr comment $PR_NUMBER --body "your review content"`**

.claude/commands/model-check.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Then check:
1616

1717
Provide clear, actionable feedback on any issues found.
1818

19-
**IMPORTANT: Post your findings as a comment on the pull request using the command: `gh pr comment ${{ github.event.pull_request.number }} --body "your findings"`**
19+
**IMPORTANT: Post your findings as a comment on the pull request using the command: `gh pr comment $PR_NUMBER --body "your findings"`**

.claude/commands/notebook-review.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ Provide a clear summary with:
4141
- ⚠️ Suggestions for improvement
4242
- ❌ Critical issues that must be fixed
4343

44-
**IMPORTANT: Post your review as a comment on the pull request using the command: `gh pr comment ${{ github.event.pull_request.number }} --body "your review"`**
44+
**IMPORTANT: Post your review as a comment on the pull request using the command: `gh pr comment $PR_NUMBER --body "your review"`**

.github/workflows/claude-link-review.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ jobs:
2727
with:
2828
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
2929
github_token: ${{ secrets.GITHUB_TOKEN }}
30-
prompt: "/link-review"
30+
prompt: "/link-review"
31+
claude_args: |
32+
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(echo:*),Read,Glob,Grep,WebFetch"
33+
env:
34+
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/claude-model-check.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ jobs:
2626
with:
2727
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
2828
github_token: ${{ secrets.GITHUB_TOKEN }}
29-
prompt: "/model-check"
29+
prompt: "/model-check"
30+
claude_args: |
31+
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(echo:*),Read,Glob,Grep,WebFetch"
32+
env:
33+
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/claude-notebook-review.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ jobs:
2727
with:
2828
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
2929
github_token: ${{ secrets.GITHUB_TOKEN }}
30-
prompt: "/notebook-review"
30+
prompt: "/notebook-review"
31+
claude_args: |
32+
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(echo:*),Read,Glob,Grep,WebFetch"
33+
env:
34+
PR_NUMBER: ${{ github.event.pull_request.number }}

.github/workflows/notebook-quality.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,46 @@ jobs:
4141
uv run ruff format **/*.ipynb --check || true
4242
4343
- name: Validate notebook structure
44+
id: validate
4445
run: |
45-
uv run python scripts/validate_notebooks.py
46-
46+
uv run python scripts/validate_notebooks.py | tee validation_output.txt
47+
# Check if validation found issues
48+
if grep -q "❌" validation_output.txt; then
49+
echo "has_issues=true" >> $GITHUB_OUTPUT
50+
exit 1
51+
else
52+
echo "has_issues=false" >> $GITHUB_OUTPUT
53+
fi
54+
continue-on-error: true
55+
56+
- name: Summarize validation issues with Claude
57+
if: github.event_name == 'pull_request' && steps.validate.outputs.has_issues == 'true'
58+
uses: anthropics/claude-code-action@v1
59+
with:
60+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
61+
github_token: ${{ secrets.GITHUB_TOKEN }}
62+
prompt: |
63+
The notebook validation found these issues:
64+
65+
```
66+
$(cat validation_output.txt)
67+
```
68+
69+
Create a helpful PR comment that:
70+
- Summarizes the validation issues found
71+
- Groups similar issues together (e.g., "7 notebooks have empty cells")
72+
- Explains why empty cells are problematic and how to fix them (delete them or add content)
73+
- If there are error outputs, explain they should be cleared before committing
74+
- Uses friendly, constructive language
75+
- Includes specific notebook names and cell numbers for reference
76+
77+
Format as a nice GitHub comment with markdown. Use emoji sparingly for clarity.
78+
Post using: gh pr comment $PR_NUMBER --body "your comment"
79+
claude_args: |
80+
--allowedTools "Bash(gh pr comment:*),Bash(cat:*),Read"
81+
env:
82+
PR_NUMBER: ${{ github.event.pull_request.number }}
83+
4784
# Only run API tests on main branch or for maintainers (costs money)
4885
- name: Execute notebooks (API Testing)
4986
if: |

claude_code_sdk/.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# GitHub Personal Access Token
2+
# Required for the GitHub MCP server in 02_The_observability_agent.ipynb
3+
# Create a token at: https://github.com/settings/tokens
4+
GITHUB_TOKEN="your-github-personal-access-token-here"
5+
6+
# Anthropic API Key
7+
# Required for using Claude SDK
8+
# Get your key at: https://console.anthropic.com/settings/keys
9+
ANTHROPIC_API_KEY="sk-ant-api03-your-api-key-here"

claude_code_sdk/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Python-generated files
2+
__pycache__/
3+
*.py[oc]
4+
build/
5+
dist/
6+
wheels/
7+
*.egg-info
8+
9+
# Virtual environments
10+
.venv
11+
.env
12+
.python-version
13+
14+
# Claude Code settings
15+
.claude-code/
16+
/CLAUDE.md
17+
18+
# Package manager lock files (optional for tutorials)
19+
uv.lock
20+
21+
# Jupyter notebook checkpoints
22+
.ipynb_checkpoints/
23+
*.ipynb_checkpoints/
24+
25+
# macOS
26+
.DS_Store

0 commit comments

Comments
 (0)