Skip to content

Commit 17a5bc9

Browse files
Merge branch 'main' into update-memory-cookbook-context-editing
2 parents 5134c37 + 5abf30e commit 17a5bc9

File tree

192 files changed

+16410
-11524
lines changed

Some content is hidden

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

192 files changed

+16410
-11524
lines changed

.claude/commands/link-review.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)
33
description: Review links in changed files for quality and security issues
44
---
55

6-
Review the links in the changed files and check for potential issues:
6+
**IMPORTANT**: Only review the files explicitly listed in the prompt above. Do not search for or review additional files.
7+
8+
Review the links in the specified changed files and check for potential issues:
79

810
## Link Quality Checks
911
1. **Broken Links**: Identify any links that might be broken or malformed

.claude/commands/model-check.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)
33
description: Validate Claude model usage against current public models
44
---
55

6-
Review the changed files for Claude model usage.
6+
**IMPORTANT**: Only review the files explicitly listed in the prompt above. Do not search for or review additional files.
7+
8+
Review the specified changed files for Claude model usage.
79

810
First, fetch the current list of allowed models from:
911
https://docs.claude.com/en/docs/about-claude/models/overview.md
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,15 @@
11
---
2-
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)
2+
allowed-tools: Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(echo:*),Read,Glob,Grep,WebFetch
33
description: Comprehensive review of Jupyter notebooks and Python scripts
44
---
55

6-
Review the changes to Jupyter notebooks and Python scripts in this PR. Please check for:
6+
**IMPORTANT**: Only review the files explicitly listed in the prompt above. Do not search for or review additional files.
77

8-
## Code Quality
9-
- Python code follows PEP 8 conventions
10-
- Proper error handling
11-
- Clear variable names and documentation
12-
- No hardcoded API keys (use os.getenv("ANTHROPIC_API_KEY"))
13-
14-
## Notebook Structure
15-
- Clear introduction explaining what the notebook demonstrates and why it's useful
16-
- Configuration instructions (how to set up API keys, install dependencies, etc.)
17-
- Connecting explanations between cells that help users understand the flow
18-
- Clear markdown explanations between code cells
19-
- Logical flow from simple to complex
20-
- Outputs preserved for educational value
21-
- Dependencies properly imported
22-
23-
## Security
24-
- Check for any hardcoded API keys or secrets (not just Anthropic keys)
25-
- Ensure all sensitive credentials use environment variables (os.environ, getenv, etc.)
26-
- Flag any potential secret patterns (tokens, passwords, private keys)
27-
- Note: Educational examples showing "what not to do" are acceptable if clearly marked
28-
- Safe handling of user inputs
29-
- Appropriate use of environment variables
8+
Review the specified Jupyter notebooks and Python scripts using the Notebook review skill.
309

3110
Provide a clear summary with:
3211
- ✅ What looks good
3312
- ⚠️ Suggestions for improvement
3413
- ❌ Critical issues that must be fixed
3514

36-
**IMPORTANT: Post your review as a comment on the pull request using the command: `gh pr comment $PR_NUMBER --body "your review"`**
15+
**IMPORTANT: Post your review as a comment on the pull request using the command: `gh pr comment $PR_NUMBER --body "your review"`**
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Temporary files generated during notebook review
2+
tmp/
3+
*.pyc
4+
__pycache__/
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
---
2+
name: cookbook-audit
3+
description: Audit an Anthropic Cookbook notebook based on a rubric. Use whenever a notebook review or audit is requested.
4+
---
5+
6+
# Cookbook Audit
7+
8+
## Instructions
9+
10+
Review the requested Cookbook notebook using the guidelines and rubrics in `style_guide.md`. Provide a score based on scoring guidelines and recommendations on improving the cookbook.
11+
12+
The style guide provides detailed templates and examples for:
13+
- Problem-focused introductions with Terminal Learning Objectives (TLOs) and Enabling Learning Objectives (ELOs)
14+
- Prerequisites and setup patterns
15+
- Core content structure
16+
- Conclusions that map back to learning objectives
17+
18+
**IMPORTANT**: Always read `style_guide.md` first before conducting an audit. The style guide contains the canonical templates and good/bad examples to reference.
19+
20+
## Workflow
21+
22+
Follow these steps for a comprehensive audit:
23+
24+
1. **Read the style guide**: First review `style_guide.md` to understand current best practices
25+
2. **Identify the notebook**: Ask user for path if not provided
26+
3. **Run automated checks**: Use `python3 validate_notebook.py <path>` to catch technical issues and generate markdown
27+
- The script automatically runs detect-secrets to scan for hardcoded API keys and credentials
28+
- Uses custom patterns defined in `scripts/detect-secrets/plugins.py`
29+
- Checks against baseline at `scripts/detect-secrets/.secrets.baseline`
30+
4. **Review markdown output**: The script generates a markdown file in the `tmp/` folder for easier review (saves context vs raw .ipynb)
31+
- The tmp/ folder is gitignored to avoid committing review artifacts
32+
- Markdown includes code cells but excludes outputs for cleaner review
33+
5. **Manual review**: Read through the markdown version evaluating against style guide and rubric
34+
6. **Score each dimension**: Apply scoring guidelines objectively
35+
7. **Generate report**: Follow the audit report format below
36+
8. **Provide specific examples**: Show concrete improvements with line references using the style guide templates
37+
38+
## Audit Report Format
39+
40+
Present your audit using this structure:
41+
42+
### Executive Summary
43+
- **Overall Score**: X/20
44+
- **Key Strengths** (2-3 bullet points)
45+
- **Critical Issues** (2-3 bullet points)
46+
47+
### Detailed Scoring
48+
49+
#### 1. Narrative Quality: X/5
50+
[Brief justification with specific examples]
51+
52+
#### 2. Code Quality: X/5
53+
[Brief justification with specific examples]
54+
55+
#### 3. Technical Accuracy: X/5
56+
[Brief justification with specific examples]
57+
58+
#### 4. Actionability & Understanding: X/5
59+
[Brief justification with specific examples]
60+
61+
### Specific Recommendations
62+
63+
[Prioritized, actionable list of improvements with references to specific sections]
64+
65+
### Examples & Suggestions
66+
67+
[Show specific excerpts from the notebook with concrete suggestions for improvement]
68+
69+
## Quick Reference Checklist
70+
71+
Use this to ensure comprehensive coverage:
72+
73+
**Introduction** (See style_guide.md Section 1)
74+
- [ ] Hooks with the problem being solved (1-2 sentences)
75+
- [ ] Explains why it matters (1-2 sentences)
76+
- [ ] Lists learning objectives as bullet points (2-4 TLOs/ELOs)
77+
- [ ] Focuses on value delivered, not machinery built
78+
- [ ] Optional: mentions broader applications (1 sentence)
79+
80+
**Prerequisites & Setup** (See style_guide.md Section 2)
81+
- [ ] Lists required knowledge clearly
82+
- [ ] Lists required tools (Python version, API keys)
83+
- [ ] Mentions recommended background if applicable
84+
- [ ] Uses %%capture for pip install to suppress output
85+
- [ ] Uses dotenv.load_dotenv() not os.environ
86+
- [ ] Defines MODEL constant at top
87+
- [ ] Groups related installs in single command
88+
89+
**Structure & Organization**
90+
- [ ] Has logical section progression
91+
- [ ] Each section teaches through demonstration
92+
- [ ] Code blocks have explanatory text before them
93+
- [ ] Includes what we learned after code blocks
94+
- [ ] Uses headers to break up sections
95+
96+
**Conclusion** (See style_guide.md Section 4)
97+
- [ ] Maps back to learning objectives
98+
- [ ] Summarizes what was accomplished
99+
- [ ] Suggests ways to apply lessons to user's context
100+
- [ ] Points to next steps or related resources
101+
102+
**Code Quality**
103+
- [ ] All code blocks have explanatory text before them
104+
- [ ] No hardcoded API keys (automatically checked by detect-secrets)
105+
- [ ] Meaningful variable names
106+
- [ ] Comments explain "why" not "what"
107+
- [ ] Follows language best practices
108+
- [ ] Model name defined as constant at top of notebook
109+
110+
**Output Management**
111+
- [ ] pip install logs suppressed with %%capture
112+
- [ ] No verbose debug output
113+
- [ ] Shows relevant API responses
114+
- [ ] Stack traces only when demonstrating error handling
115+
116+
**Content Quality**
117+
- [ ] Explains why approaches work
118+
- [ ] Discusses when to use this approach
119+
- [ ] Mentions limitations/considerations
120+
- [ ] Provides transferable knowledge
121+
- [ ] Appropriate model selection
122+
123+
**Technical Requirements**
124+
- [ ] Executable without modification (except API keys)
125+
- [ ] Uses non-deprecated API patterns
126+
- [ ] Uses valid model names (claude-sonnet-4-5, claude-haiku-4-5, claude-opus-4-1)
127+
- [ ] Model name defined as constant at top of notebook
128+
- [ ] Includes dependency specifications
129+
- [ ] Assigned to primary category
130+
- [ ] Has relevant tags
131+
132+
### Content Philosophy: Action + Understanding
133+
134+
Cookbooks are primarily action-oriented but strategically incorporate understanding and informed by Diataxis framework.
135+
136+
**Core Principles:**
137+
- **Practical focus**: Show users how to accomplish specific tasks with working code
138+
- **Problem-first framing**: Lead with the problem being solved and value delivered, not the machinery
139+
- **Builder's perspective**: Written from the user's point of view, solving real problems
140+
- **Agency-building**: Help users understand why approaches work, not just how
141+
- **Transferable knowledge**: Teach patterns and principles that apply beyond the specific example
142+
- **Critical thinking**: Encourage users to question outputs, recognize limitations, make informed choices
143+
- **Learning contracts**: State learning objectives upfront, then map back to them in conclusions
144+
145+
### What Makes a Good Cookbook
146+
147+
A good cookbook doesn't just help users solve today's problem, it also helps them understand the underlying principles behind the solutions, encouraging them to recognize when and how to adapt approaches. Users will be able to make more informed decisions about AI system design, develop judgement about model outputs, and build skills that transfer to future AI systems.
148+
149+
### What Cookbooks Are NOT
150+
151+
Cookbooks are not pure tutorials: We assume users have basic technical skills and API familiarity. We clearly state prerequisites in our cookbooks, and direct users to the Academy to learn more on topics.
152+
They are not comprehensive explanations: We don't teach transformer architecture or probability theory. We need to understand that our users are following our cookbooks to solve problems they are facing today. They are busy, in the midst of learning or building, and want to be able to use what they learn to solve their immediate needs.
153+
Cookbooks are not reference docs: We don't exhaustively document every parameter, we link to appropriate resources in our documentation as needed.
154+
Cookbooks are not simple tips and tricks: We don't teach "hacks" that only work for the current model generation. We don't over-promise and under-deliver.
155+
Cookbooks are not production-ready code: They showcase use cases and capabilities, not production patterns. Excessive error handling is not required.
156+
157+
### Style Guidelines
158+
159+
#### Voice & Tone
160+
- Educational and agency-building
161+
- Professional but approachable
162+
- Respectful of user intelligence and time
163+
- Either second person ("you") or first person plural ("we") - be consistent within a notebook
164+
165+
#### Writing Quality
166+
- Clear, concise explanations
167+
- Active voice preferred
168+
- Short paragraphs (3-5 sentences)
169+
- Avoid jargon without definition
170+
- Use headers to break up sections
171+
172+
#### Code Presentation
173+
- **Always explain before showing**: Every code block should be preceded by explanatory text
174+
- **Explain after running**: Include what we learned after code blocks execute
175+
- **Comments explain why, not what**: Use meaningful variable names
176+
- **Use constants**: Define MODEL as a constant at the top
177+
- **Good habits**: Use `dotenv.load_dotenv()` instead of `os.environ`
178+
179+
#### Output Handling
180+
**Remove extraneous output** with %%capture:
181+
- pip install logs (always suppress these)
182+
- Verbose debug statements
183+
- Lengthy stack traces (unless demonstrating error handling)
184+
185+
**Show relevant output**:
186+
- API responses that demonstrate functionality
187+
- Examples of successful execution
188+
189+
### Structural Requirements
190+
191+
**See style_guide.md for detailed templates and examples**
192+
193+
#### 1. Introduction (Required)
194+
Must include:
195+
- **Problem hook** (1-2 sentences): What problem are we solving?
196+
- **Why it matters** (1-2 sentences): Why is this important?
197+
- **Learning objectives** (2-4 bullet points): "By the end of this cookbook, you'll be able to..."
198+
- Use action verbs (Build, Implement, Deploy, etc.)
199+
- Be specific about capabilities
200+
- Include context/constraints
201+
- **Optional**: Broader applications (1 sentence)
202+
203+
**Avoid**: Leading with machinery ("We will build a research agent...")
204+
**Do**: Lead with problem/value ("Your team spends hours triaging CI failures...")
205+
206+
#### 2. Prerequisites & Setup (Required)
207+
Must include:
208+
- **Required Knowledge**: Technical skills needed
209+
- **Required Tools**: Python version, API keys with links
210+
- **Recommended**: Optional background that helps
211+
- **Setup**: Step-by-step with explanations
212+
- Use `%%capture` for pip installs
213+
- Use `dotenv.load_dotenv()` not `os.environ`
214+
- Define `MODEL` constant at top
215+
216+
#### 3. Main Content (Required)
217+
Organized by logical steps or phases, each with:
218+
- Clear section headers
219+
- **Explanatory text before code blocks** (what we're about to do)
220+
- Code examples
221+
- **Explanatory text after code blocks** (what we learned)
222+
- Expected outputs (where relevant)
223+
- Optional: Understanding callouts (why it works, when to use, limitations)
224+
225+
#### 4. Conclusion (Recommended)
226+
Must include:
227+
- **Recap**: Map back to learning objectives
228+
- **What was accomplished**: Summary of key points
229+
- **Application guidance**: How to apply lessons to user's context
230+
- **Next steps**: Related resources or ideas to pursue
231+
232+
**Avoid**: Generic summaries ("We've demonstrated how the SDK enables...")
233+
**Do**: Actionable guidance ("Consider applying this to X... Next, try Y...")
234+
235+
#### Optional Sections
236+
- **How It Works**: Brief explanation of underlying mechanism
237+
- **When to Use This**: Appropriate use cases and contexts
238+
- **Limitations & Considerations**: Caveats, failure modes, constraints
239+
- **Troubleshooting**: Common issues and solutions
240+
- **Variations**: Alternative approaches or extensions
241+
- **Performance Notes**: Optimization considerations
242+
- **Further Reading**: Links to relevant docs, papers, or deeper explanations
243+
244+
### Common Anti-Patterns to Flag
245+
246+
Refer to style_guide.md for detailed good/bad examples. Watch for these issues:
247+
248+
#### Introduction Anti-Patterns
249+
❌ Leading with machinery: "We will build a research agent using the Claude SDK..."
250+
❌ Feature dumps: Listing SDK methods or tool capabilities
251+
❌ Vague learning objectives: "Learn about agents" or "Understand the API"
252+
✅ Problem-first framing with specific, actionable learning objectives
253+
254+
#### Setup Anti-Patterns
255+
❌ Noisy pip install output without `%%capture`
256+
❌ Multiple separate pip install commands
257+
❌ Using `os.environ["API_KEY"] = "your_key"` instead of dotenv
258+
❌ Hardcoding model names throughout instead of using a MODEL constant
259+
✅ Clean setup with grouped installs, dotenv, and constants
260+
261+
#### Code Presentation Anti-Patterns
262+
❌ Code blocks without explanatory text before them
263+
❌ No explanation of what we learned after running code
264+
❌ Comments that explain "what" the code does (code should be self-documenting)
265+
❌ Over-explaining obvious code
266+
✅ Context before code, insights after code, comments explain "why"
267+
268+
#### Conclusion Anti-Patterns
269+
❌ Generic summaries: "We've demonstrated how the SDK enables..."
270+
❌ Simply restating what the notebook did without guidance
271+
❌ Not mapping back to the stated learning objectives
272+
✅ Actionable guidance on applying lessons to user's specific context

0 commit comments

Comments
 (0)