Skip to content

Commit fe63970

Browse files
PedramNavidclaude
andauthored
feat(skills): add comprehensive style guide for cookbook audits (anthropics#272)
* feat(skills): add comprehensive style guide for cookbook audits * fix(ci): resolve lychee "No links were found" error Fixed two issues in the link checking workflow: 1. **Fixed bash variable scoping bug**: The while-read loop was running in a subshell, causing FILES variable assignments to be lost. Changed to use process substitution (< <(...)) to keep the loop in the current shell. 2. **Added failIfEmpty: false**: Added this parameter to both lychee-action invocations to prevent failures when no links are found (legitimate for some PRs). 3. **Skip lychee when no files**: Added has_files output and conditional check to skip the lychee step entirely when no markdown files are found. 4. **Exclude .claude/ directory**: Added .claude/ to lychee.toml exclude_path since it contains tooling/config files that don't need link checking. These changes ensure the link checker works correctly for PRs that only modify files in excluded directories or files without external links. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent 236faa4 commit fe63970

File tree

4 files changed

+355
-169
lines changed

4 files changed

+355
-169
lines changed

.claude/skills/cookbook-audit/SKILL.md

Lines changed: 154 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,33 @@ description: Audit an Anthropic Cookbook notebook based on a rubric. Use wheneve
77

88
## Instructions
99

10-
Review the requested Cookbook notebook using the following guidelines. Provide a score based on scoring guidelines and recommendations on improving the cookbook.
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.
1119

1220
## Workflow
1321

1422
Follow these steps for a comprehensive audit:
1523

16-
1. **Identify the notebook**: Ask user for path if not provided
17-
2. **Run automated checks**: Use `python3 validate_notebook.py <path>` to catch technical issues and generate markdown
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
1827
- The script automatically runs detect-secrets to scan for hardcoded API keys and credentials
1928
- Uses custom patterns defined in `scripts/detect-secrets/plugins.py`
2029
- Checks against baseline at `scripts/detect-secrets/.secrets.baseline`
21-
3. **Review markdown output**: The script generates a markdown file in the `tmp/` folder for easier review (saves context vs raw .ipynb)
30+
4. **Review markdown output**: The script generates a markdown file in the `tmp/` folder for easier review (saves context vs raw .ipynb)
2231
- The tmp/ folder is gitignored to avoid committing review artifacts
2332
- Markdown includes code cells but excludes outputs for cleaner review
24-
4. **Manual review**: Read through the markdown version evaluating against rubric
25-
5. **Score each dimension**: Apply scoring guidelines objectively
26-
6. **Generate report**: Follow the audit report format below
27-
7. **Provide specific examples**: Show concrete improvements with line references
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
2837

2938
## Audit Report Format
3039

@@ -61,12 +70,34 @@ Present your audit using this structure:
6170

6271
Use this to ensure comprehensive coverage:
6372

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+
6489
**Structure & Organization**
65-
- [ ] Has clear introduction (1-2 paragraphs)
66-
- [ ] States problem, audience, and outcome
67-
- [ ] Lists prerequisites clearly
6890
- [ ] Has logical section progression
69-
- [ ] Includes conclusion/summary
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
70101

71102
**Code Quality**
72103
- [ ] All code blocks have explanatory text before them
@@ -102,11 +133,14 @@ Use this to ensure comprehensive coverage:
102133

103134
Cookbooks are primarily action-oriented but strategically incorporate understanding and informed by Diataxis framework.
104135

105-
Practical focus: Show users how to accomplish specific tasks with working code
106-
Builder's perspective: Written from the user's point of view, solving real problems
107-
Agency-building: Help users understand why approaches work, not just how
108-
Transferable knowledge: Teach patterns and principles that apply beyond the specific example
109-
Critical thinking: Encourage users to question outputs, recognize limitations, make informed choices
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
110144

111145
### What Makes a Good Cookbook
112146

@@ -123,160 +157,116 @@ Cookbooks are not production-ready code: They showcase use cases and capabilitie
123157
### Style Guidelines
124158

125159
#### Voice & Tone
126-
127-
Educational and agency-building
128-
Professional but approachable
129-
Respectful of user intelligence and time
130-
Either second person ("you") or first person plural ("we") - be consistent within a notebook
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
131164

132165
#### Writing Quality
133-
134-
Clear, concise explanations
135-
Active voice preferred
136-
Short paragraphs (3-5 sentences)
137-
Avoid jargon without definition
138-
Use headers to break up sections
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
139171

140172
#### Code Presentation
141-
142-
Every code block should be preceded by explanatory text
143-
Comments should explain why, not what
144-
Use meaningful variable names
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`
145178

146179
#### Output Handling
147-
Remove extraneous output, e.g with %%capture
148-
pip install logs
149-
Verbose debug statements
150-
Lengthy stack traces (unless demonstrating error handling)
151-
Show relevant output:
152-
API responses that demonstrate functionality
153-
Examples of successful execution
154-
155-
### Structural Requirements
156-
157-
Required Sections
158-
159-
1. Introduction (Required)
160-
[Cookbook Title]
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)
161184

162-
[1-2 paragraphs covering:]
163-
- What problem this solves
164-
- Who this is for
165-
- What you'll build/accomplish
185+
**Show relevant output**:
186+
- API responses that demonstrate functionality
187+
- Examples of successful execution
166188

167-
Prerequisites
168-
- Required technical skills
169-
- API keys needed
170-
- Dependencies to install
189+
### Structural Requirements
171190

172-
2. Main Content (Required)
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)
173217
Organized by logical steps or phases, each with:
174-
Clear section headers
175-
Explanatory text before code blocks
176-
Code examples
177-
Expected outputs (where relevant)
178-
Understanding callouts: Brief explanations of why approaches work, when to use them, or important considerations
179-
180-
3. Conclusion (Recommended)
181-
182-
Summary of what was accomplished
183-
Limitations or considerations
184-
Next steps or related resources
185-
186-
Optional Sections
187-
How It Works: Brief explanation of the underlying approach or mechanism
188-
When to Use This: Guidance on appropriate use cases and contexts
189-
Limitations & Considerations: Important caveats, failure modes, or constraints
190-
Troubleshooting: Common issues and solutions
191-
Variations: Alternative approaches or extensions
192-
Performance Notes: Optimization considerations
193-
Further Reading: Links to relevant docs, papers, or deeper explanations
194-
195-
## Examples
196-
197-
### Example 1: High-Quality Notebook Audit (Score: 18/20)
198-
199-
**Notebook**: "Building a Customer Support Agent with Tool Use"
200-
201-
#### Executive Summary
202-
- **Overall Score**: 18/20
203-
- **Key Strengths**:
204-
- Excellent narrative flow from problem to solution
205-
- Clean, well-documented code with proper error handling
206-
- Strong focus on transferable patterns (tool schema design, error recovery)
207-
- **Critical Issues**:
208-
- Missing %%capture on pip install cells
209-
- Could benefit from a limitations section discussing when NOT to use this approach
210-
211-
#### Detailed Scoring
212-
213-
**1. Narrative Quality: 5/5**
214-
Opens with clear problem statement about reducing support ticket volume. Each section builds logically. Concludes with discussion of production considerations.
215-
216-
**2. Code Quality: 4/5**
217-
Excellent structure and naming. Clean, idiomatic code. Model defined as constant. Minor issue: pip install output not suppressed in cells 1-2.
218-
219-
**3. Technical Accuracy: 5/5**
220-
Demonstrates best practices for tool use. Appropriate model selection (using valid claude-sonnet-4-5 model). Correct API usage with streaming.
221-
222-
**4. Actionability & Understanding: 4/5**
223-
Very practical with clear adaptation points. Explains why tool schemas are designed certain ways. Could add more discussion on when this approach isn't suitable.
224-
225-
#### Specific Recommendations
226-
1. Add `%%capture` to cells 1-2 to suppress pip install logs
227-
2. Add "Limitations & Considerations" section discussing scenarios where simpler approaches might be better
228-
3. Consider adding a "Variations" section showing how to adapt for different support scenarios
229-
230-
---
231-
232-
### Example 2: Needs Improvement Notebook Audit (Score: 11/20)
233-
234-
**Notebook**: "Text Classification with Claude"
235-
236-
#### Executive Summary
237-
- **Overall Score**: 11/20
238-
- **Key Strengths**:
239-
- Working code that demonstrates basic classification
240-
- Covers multiple classification approaches
241-
- **Critical Issues**:
242-
- No introduction explaining use case or prerequisites
243-
- Code blocks lack explanatory text
244-
- No discussion of why approaches work or when to use them
245-
- Missing error handling and best practices
246-
247-
#### Detailed Scoring
248-
249-
**1. Narrative Quality: 2/5**
250-
Jumps directly into code without context. No introduction explaining what problem this solves or who it's for. Sections lack connecting narrative.
251-
252-
**2. Code Quality: 3/5**
253-
Code is functional but lacks structure. Variable names like `x1`, `result`, `temp` are unclear. No comments explaining non-obvious choices. Model not defined as constant at top.
254-
255-
**3. Technical Accuracy: 3/5**
256-
API calls work but use invalid or deprecated model names. Model selection not explained. No discussion of token efficiency or performance.
257-
258-
**4. Actionability & Understanding: 3/5**
259-
Shows multiple approaches but doesn't explain when to use each. No discussion of trade-offs. Unclear how to adapt to different classification tasks.
260-
261-
#### Specific Recommendations
262-
263-
**High Priority:**
264-
1. Add introduction section (1-2 paragraphs) explaining:
265-
- What classification problems this addresses
266-
- Prerequisites (basic Python, API key, familiarity with classification)
267-
- What readers will accomplish
268-
269-
2. Add explanatory text before EVERY code block explaining what it does and why
270-
271-
3. Update to current API patterns and explain model selection rationale
272-
273-
**Medium Priority:**
274-
4. Improve variable names: `x1``sample_text`, `result``classification_result`
275-
5. Define model as constant at top: `MODEL = 'claude-sonnet-4-5'`
276-
6. Update to use valid model names (claude-sonnet-4-5, claude-haiku-4-5, or claude-opus-4-1)
277-
7. Add "When to Use This" section explaining which approach for which scenario
278-
279-
**Low Priority:**
280-
8. Add conclusion summarizing trade-offs between approaches
281-
9. Add "Limitations" section discussing accuracy considerations
282-
10. Consider adding evaluation metrics example
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)