Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat(skills): Add agent-development and oauth-integrations skills
Jeremy Dawesbd95b44ab140
diff --git a/skills/agent-development/README.md b/skills/agent-development/README.mdnew file mode 100644index 00000000..14c45f42--- /dev/null+++ b/skills/agent-development/README.md@@ -0,0 +1,81 @@+# Agent Development Skill++Design and build custom Claude Code agents with effective descriptions, tool access patterns, and self-documenting prompts.++## Auto-Trigger Keywords++This skill should be automatically loaded when discussions involve:++- "create agent", "custom agent", "build agent"+- "agent description", "agent frontmatter"+- "Task tool", "subagent_type"+- "agent pipeline", "agent workflow"+- "agent memory", "memory limits", "heap size"+- "agent delegation", "auto-delegation"+- "agent not triggering", "agent not running"+- ".claude/agents/", "agents/*.md"+- "model selection", "Opus vs Sonnet vs Haiku"+- "declarative instructions", "agent prompts"+- "self-documenting", "agent documentation"+- "parallel agents", "batch agents"+- "sub-agent patterns", "agent design"++## What This Skill Covers++1. **Agent Description Patterns** - Strong trigger phrases for auto-delegation+2. **Tool Access** - When to give Bash, allowlist patterns+3. **Model Selection** - Opus/Sonnet/Haiku decision matrix+4. **Memory Management** - NODE_OPTIONS fix, parallel limits+5. **Sub-Agent vs API** - Why Task sub-agents are superior+6. **Declarative Design** - What vs how in agent instructions+7. **Self-Documentation** - Encoding learnings into prompts+8. **Pipeline Agents** - Linking agents in workflows+9. **Parallel Execution** - Batch patterns, workflow design++## Quick Start++### Create a New Agent++```yaml+---+name: my-agent+description: |+ [Role] specialist. MUST BE USED when [triggers].+ Use PROACTIVELY for [task category].+ Keywords: [trigger words]+tools: Read, Write, Edit, Glob, Grep, Bash+model: sonnet+---++# My Agent++## Your Role+[What this agent does]++## Process+[Steps to follow]++## Output+[Expected deliverables]+```++### Fix Memory Issues++```bash+# Add to ~/.bashrc+export NODE_OPTIONS="--max-old-space-size=16384"+source ~/.bashrc+```++### Fix Bash Approval Spam++Remove Bash from tools list, or use allowlists in `.claude/settings.json`.++## Related Skills++- `cloudflare-dev` - Development workflow (uses agents)+- `project-planning` - Project setup (creates agents)++## Version History++- **v1.0.0** (2025-01-18): Initial release with consolidated agent patternsdiff --git a/skills/agent-development/SKILL.md b/skills/agent-development/SKILL.mdnew file mode 100644index 00000000..345b1069--- /dev/null+++ b/skills/agent-development/SKILL.md@@ -0,0 +1,331 @@+---+name: agent-development+description: |+ Design and build custom Claude Code agents with effective descriptions, tool access patterns,+ and self-documenting prompts. Covers Task tool delegation, model selection, memory limits,+ and declarative instruction design.++ Use when: creating custom agents, designing agent descriptions for auto-delegation,+ troubleshooting agent memory issues, or building agent pipelines.+license: MIT+---++# Agent Development for Claude Code++Build effective custom agents for Claude Code with proper delegation, tool access, and prompt design.++## Agent Description Pattern++The description field determines whether Claude will automatically delegate tasks.++### Strong Trigger Pattern++```yaml+---+name: agent-name+description: |+ [Role] specialist. MUST BE USED when [specific triggers].+ Use PROACTIVELY for [task category].+ Keywords: [trigger words]+tools: Read, Write, Edit, Glob, Grep, Bash+model: sonnet+---+```++### Weak vs Strong Descriptions++| Weak (won't auto-delegate) | Strong (auto-delegates) |+|---------------------------|-------------------------|+| "Analyzes screenshots for issues" | "Visual QA specialist. MUST BE USED when analyzing screenshots. Use PROACTIVELY for visual QA." |+| "Runs Playwright scripts" | "Playwright specialist. MUST BE USED when running Playwright scripts. Use PROACTIVELY for browser automation." |++**Key phrases**:+- "MUST BE USED when..."+- "Use PROACTIVELY for..."+- Include trigger keywords++### Delegation Mechanisms++1. **Explicit**: `Task tool subagent_type: "agent-name"` - always works+2. **Automatic**: Claude matches task to agent description - requires strong phrasing++**Session restart required** after creating/modifying agents.++## Tool Access Principle++**If an agent doesn't need Bash, don't give it Bash.**++| Agent needs to... | Give tools | Don't give |+|-------------------|------------|------------|+| Create files only | Read, Write, Edit, Glob, Grep | Bash |+| Run scripts/CLIs | Read, Write, Edit, Glob, Grep, Bash | — |+| Read/audit only | Read, Glob, Grep | Write, Edit, Bash |++**Why?** Models default to `cat > file << 'EOF'` heredocs instead of Write tool. Each bash command requires approval, causing dozens of prompts per agent run.++### Allowlist Pattern++Instead of restricting Bash, allowlist safe commands in `.claude/settings.json`:++```json+{+ "permissions": {+ "allow": [+ "Write", "Edit", "WebFetch(domain:*)",+ "Bash(cd *)", "Bash(cp *)", "Bash(mkdir *)", "Bash(ls *)",+ "Bash(cat *)", "Bash(head *)", "Bash(tail *)", "Bash(grep *)",+ "Bash(diff *)", "Bash(mv *)", "Bash(touch *)", "Bash(file *)"+ ]+ }+}+```++## Model Selection (Quality First)++Don't downgrade quality to work around issues - fix root causes instead.++| Model | Use For |+|-------|---------|+| **Opus** | Creative work (page building, design, content) - quality matters |+| **Sonnet** | Most agents - content, code, research (default) |+| **Haiku** | Only script runners where quality doesn't matter |++## Memory Limits++### Root Cause Fix (REQUIRED)++Add to `~/.bashrc` or `~/.zshrc`:+```bash+export NODE_OPTIONS="--max-old-space-size=16384"+```++Increases Node.js heap from 4GB to 16GB.++### Parallel Limits (Even With Fix)++| Agent Type | Max Parallel | Notes |+|------------|--------------|-------|+| Any agents | 2-3 | Context accumulates; batch then pause |+| Heavy creative (Opus) | 1-2 | Uses more memory |++### Recovery++1. `source ~/.bashrc` or restart terminal+2. `NODE_OPTIONS="--max-old-space-size=16384" claude`+3. Check what files exist, continue from there++## Sub-Agent vs Remote API++**Always prefer Task sub-agents over remote API calls.**++| Aspect | Remote API Call | Task Sub-Agent |+|--------|-----------------|----------------|+| Tool access | None | Full (Read, Grep, Write, Bash) |+| File reading | Must pass all content in prompt | Can read files iteratively |+| Cross-referencing | Single context window | Can reason across documents |+| Decision quality | Generic suggestions | Specific decisions with rationale |+| Output quality | ~100 lines typical | 600+ lines with specifics |++```typescript+// ❌ WRONG - Remote API call+const response = await fetch('https://api.anthropic.com/v1/messages', {...})++// ✅ CORRECT - Use Task tool+// Invoke Task with subagent_type: "general-purpose"+```++## Declarative Over Imperative++Describe **what** to accomplish, not **how** to use tools.++### Wrong (Imperative)++```markdown+### Check for placeholders+```bash+grep -r "PLACEHOLDER:" build/*.html+```+```++### Right (Declarative)++```markdown+### Check for placeholders+Search all HTML files in build/ for:+- PLACEHOLDER: comments+- TODO or TBD markers+- Template brackets like [Client Name]++Any match = incomplete content.+```++### What to Include++| Include | Skip |+|---------|------|+| Task goal and context | Explicit bash/tool commands |+| Input file paths | "Use X tool to..." |+| Output file paths and format | Step-by-step tool invocations |+| Success/failure criteria | Shell pipeline syntax |+| Blocking checks (prerequisites) | Micromanaged workflows |+| Quality checklists | |++## Self-Documentation Principle++> "Agents that won't have your context must be able to reproduce the behaviour independently."++Every improvement must be encoded into the agent's prompt, not left as implicit knowledge.++### What to Encode++| Discovery | Where to Capture |+|-----------|------------------|+| Bug fix pattern | Agent's "Corrections" or "Common Issues" section |+| Quality requirement | Agent's "Quality Checklist" section |+| File path convention | Agent's "Output" section |+| Tool usage pattern | Agent's "Process" section |+| Blocking prerequisite | Agent's "Blocking Check" section |++### Test: Would a Fresh Agent Succeed?++Before completing any agent improvement:+1. Read the agent prompt as if you have no context+2. Ask: Could a new session follow this and produce the same quality?+3. If no: Add missing instructions, patterns, or references++### Anti-Patterns++| Anti-Pattern | Why It Fails |+|--------------|--------------|+| "As we discussed earlier..." | No prior context exists |+| Relying on files read during dev | Agent may not read same files |+| Assuming knowledge from errors | Agent won't see your debugging |+| "Just like the home page" | Agent hasn't built home page |++## Agent Prompt Structure++Effective agent prompts include:++```markdown+## Your Role+[What the agent does]++## Blocking Check+[Prerequisites that must exist]++## Input+[What files to read]++## Process+[Step-by-step with encoded learnings]++## Output+[Exact file paths and formats]++## Quality Checklist+[Verification steps including learned gotchas]++## Common Issues+[Patterns discovered during development]+```++## Pipeline Agents++When inserting a new agent into a numbered pipeline (e.g., `HTML-01` → `HTML-05` → `HTML-11`):++| Must Update | What |+|-------------|------|+| New agent | "Workflow Position" diagram + "Next" field |+| **Predecessor agent** | Its "Next" field to point to new agent |++**Common bug**: New agent is "orphaned" because predecessor still points to old next agent.++**Verification**:+```bash+grep -n "Next:.*→\|Then.*runs next" .claude/agents/*.md+```++## The Sweet Spot++**Best use case**: Tasks that are **repetitive but require judgment**.++Example: Auditing 70 skills manually = tedious. But each audit needs intelligence (check docs, compare versions, decide what to fix). Perfect for parallel agents with clear instructions.++**Not good for**:+- Simple tasks (just do them)+- Highly creative tasks (need human direction)+- Tasks requiring cross-file coordination (agents work independently)++## Effective Prompt Template++```+For each [item]:+1. Read [source file]+2. Verify with [external check - npm view, API call, etc.]+3. Check [authoritative source]+4. Score/evaluate+5. FIX issues found ← Critical instruction+```++**Key elements**:+- **"FIX issues found"** - Without this, agents only report. With it, they take action.+- **Exact file paths** - Prevents ambiguity+- **Output format template** - Ensures consistent, parseable reports+- **Batch size ~5 items** - Enough work to be efficient, not so much that failures cascade++## Workflow Pattern++```+1. ME: Launch 2-3 parallel agents with identical prompt, different item lists+2. AGENTS: Work in parallel (read → verify → check → edit → report)+3. AGENTS: Return structured reports (score, status, fixes applied, files modified)+4. ME: Review changes (git status, spot-check diffs)+5. ME: Commit in batches with meaningful changelog+6. ME: Push and update progress tracking+```++**Why agents don't commit**: Allows human review, batching, and clean commit history.++## Signs a Task Fits This Pattern++**Good fit**:+- Same steps repeated for many items+- Each item requires judgment (not just transformation)+- Items are independent (no cross-item dependencies)+- Clear success criteria (score, pass/fail, etc.)+- Authoritative source exists to verify against++**Bad fit**:+- Items depend on each other's results+- Requires creative/subjective decisions+- Single complex task (use regular agent instead)+- Needs human input mid-process++## Quick Reference++### Agent Frontmatter Template++```yaml+---+name: my-agent+description: |+ [Role] specialist. MUST BE USED when [triggers].+ Use PROACTIVELY for [task category].+ Keywords: [trigger words]+tools: Read, Write, Edit, Glob, Grep, Bash+model: sonnet+---+```++### Fix Bash Approval Spam++1. Remove Bash from tools if not needed+2. Put critical instructions FIRST (right after frontmatter)+3. Use allowlists in `.claude/settings.json`++### Memory Crash Recovery++```bash+export NODE_OPTIONS="--max-old-space-size=16384"+source ~/.bashrc && claude+```diff --git a/skills/agent-development/rules/agent-memory-limits.md b/skills/agent-development/rules/agent-memory-limits.mdnew file mode 100644index 00000000..c5601a62--- /dev/null+++ b/skills/agent-development/rules/agent-memory-limits.md@@ -0,0 +1,34 @@+# Agent Memory Limits++## Root Cause Fix (REQUIRED)++Add to `~/.bashrc` or `~/.zshrc`:+```bash+export NODE_OPTIONS="--max-old-space-size=16384"+```++This increases Node.js heap from default 4GB to 16GB. **With this set, you can run agents normally.**++## Model Selection (Quality First)++Don't downgrade model quality to work around memory - fix the heap limit instead.++| Model | Use For |+|-------|---------|+| **Opus** | Creative work (page building, design, content) - quality matters |+| **Sonnet** | Research, validation, synthesis - balanced |+| **Haiku** | Script runners, simple deployers - speed over quality |++## Parallel Limits (Even With Fix)++| Agent Type | Max Parallel | Notes |+|------------|--------------|-------|+| Any agents | 2-3 | Context accumulates; batch then pause |+| Heavy creative | 1-2 | Opus agents use more memory |++## Recovery++If crash occurs:+1. `source ~/.bashrc` or restart terminal+2. `NODE_OPTIONS="--max-old-space-size=16384" claude`+3. Check what files exist, continue from therediff --git a/skills/agent-development/rules/agent-pattern.md b/skills/agent-development/rules/agent-pattern.mdnew file mode 100644index 00000000..93038f8a--- /dev/null+++ b/skills/agent-development/rules/agent-pattern.md@@ -0,0 +1,61 @@+---+globs: ["**/*.ts", "**/*.tsx", ".claude/agents/*.md", "**/agents/*.md"]+---++# Agent Implementation Pattern++When building agent-like functionality in Claude Code projects, use Task sub-agents instead of remote API calls.++## Corrections++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| Script calling Claude/OpenAI API remotely | Task tool with `subagent_type: "general-purpose"` |+| `fetch('https://api.anthropic.com/v1/messages')` in script | Task sub-agent with comprehensive prompt |+| Remote agent with single-shot context | Sub-agent that can read files iteratively |++## Why Sub-Agents Are Superior++| Aspect | Remote API Call | Task Sub-Agent |+|--------|-----------------|----------------|+| Tool access | None | Full (Read, Grep, Write, Bash) |+| File reading | Must pass all content in prompt | Can read files iteratively |+| Cross-referencing | Single context window | Can reason across documents |+| Decision quality | Generic suggestions | Specific decisions with rationale |+| Output quality | ~100 lines typical | 600+ lines with specifics |++## Pattern++```typescript+// ❌ WRONG - Remote API call+const response = await fetch('https://api.anthropic.com/v1/messages', {+ method: 'POST',+ headers: { 'x-api-key': ANTHROPIC_API_KEY },+ body: JSON.stringify({ model: 'claude-sonnet-4-20250514', messages: [...] })+});++// ✅ CORRECT - Use Task tool in Claude Code+// Invoke Task with subagent_type: "general-purpose"+// Sub-agent reads files, synthesizes, writes output+```++## When This Applies++- Creative Director agents (synthesizing discovery into briefs)+- Code review agents+- Documentation generators+- Any multi-file analysis task+- Content generation from multiple sources++## Real Example++**Task**: Generate Creative Brief from 6 discovery files + media catalog++**Remote API result**: Generic brief with placeholder suggestions+**Sub-agent result**: 610-line brief with specific hex codes, image IDs by filename, actual headlines, cross-referenced statistics with citations++The difference is dramatic because sub-agents can:+1. Read all 6 discovery files (3,600+ lines)+2. Read media catalog and reference specific images+3. Cross-reference facts between documents+4. Make informed decisions based on full contextdiff --git a/skills/agent-development/rules/agent-self-documentation.md b/skills/agent-development/rules/agent-self-documentation.mdnew file mode 100644index 00000000..04a42c0c--- /dev/null+++ b/skills/agent-development/rules/agent-self-documentation.md@@ -0,0 +1,96 @@+---+globs: [".claude/agents/*.md", "**/agents/*.md", "**/teams/**/*.md", "**/prompts/**/*.md"]+---++# Agent Self-Documentation Principle++When building or improving agent systems, all changes must be captured IN the agent prompts/templates themselves. Future agent instances won't have your conversation context.++## The Principle++> "Agents that won't have your context must be able to reproduce the behaviour independently."++Every improvement, fix, or pattern discovered during development must be encoded into the agent's prompt, not left as implicit knowledge.++## Corrections++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| One-off fix in current session | Update the agent prompt/template |+| "Remember to do X" in conversation | Add X to agent's process section |+| Fixing output manually | Add quality check to agent's checklist |+| Explaining pattern verbally | Document pattern in agent's instructions |++## What to Encode++| Discovery | Where to Capture |+|-----------|------------------|+| Bug fix pattern | Agent's "Corrections" or "Common Issues" section |+| Quality requirement | Agent's "Quality Checklist" section |+| File path convention | Agent's "Output" section |+| Tool usage pattern | Agent's "Process" section |+| Blocking prerequisite | Agent's "Blocking Check" section |++## Example: Learning Becomes Instruction++**During development** (conversation context):+> "The grid was showing 3+1 orphan layout with 4 items. Fixed by using `:has(:nth-child(4):last-child)` to detect item count."++**Encoded in agent prompt**:+```markdown+### Grid Layout Rules+- Use `.services-grid` class - it auto-adapts to item count+- 4 items → 2x2 grid (not 3+1)+- See `teams/creative/layout-presets.md` for patterns+```++## Test: Would a Fresh Agent Succeed?++Before completing any agent system improvement:++1. **Read the agent prompt as if you have no context**+2. **Ask**: Could a new session follow this and produce the same quality?+3. **If no**: Add missing instructions, patterns, or references++## Anti-Patterns++| Anti-Pattern | Why It Fails |+|--------------|--------------|+| "As we discussed earlier..." | No prior context exists |+| Relying on files read during dev | Agent may not read same files |+| Assuming knowledge from errors | Agent won't see your debugging |+| "Just like the home page" | Agent hasn't built home page |++## Agent Prompt Structure++Effective agent prompts include:++```markdown+## Your Role+[What the agent does]++## Blocking Check+[Prerequisites that must exist]++## Input+[What files to read]++## Process+[Step-by-step with encoded learnings]++## Output+[Exact file paths and formats]++## Quality Checklist+[Verification steps including learned gotchas]++## Common Issues+[Patterns discovered during development]+```++## Applies To++- Custom agents in `.claude/agents/`+- Team prompts in `teams/*/`+- Any reusable prompt or workflow+- MCP server tool definitionsdiff --git a/skills/agent-development/rules/custom-agent-descriptions.md b/skills/agent-development/rules/custom-agent-descriptions.mdnew file mode 100644index 00000000..3f8bb88e--- /dev/null+++ b/skills/agent-development/rules/custom-agent-descriptions.md@@ -0,0 +1,56 @@+---+globs: ["**/agents/*.md", "**/.claude/agents/*"]+---++# Custom Agent Description Pattern++When creating custom agents in `.claude/agents/`, the description field determines whether Claude will automatically delegate tasks to the agent.++## Corrections++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `description: "Analyzes screenshots for issues"` | `description: "Visual QA specialist. MUST BE USED when analyzing screenshots. Use PROACTIVELY for any visual QA task."` |+| `description: "Runs Playwright scripts"` | `description: "Playwright specialist. MUST BE USED when running Playwright scripts. Use PROACTIVELY for browser automation."` |+| Weak/passive descriptions | Strong trigger phrases with "MUST BE USED" and "Use PROACTIVELY" |++## Pattern++```yaml+---+name: agent-name+description: "[Role] specialist. MUST BE USED when [specific triggers]. Use PROACTIVELY for [task category]."+tools: [tool list]+model: sonnet+---+```++## Why This Matters++Claude Code has two delegation mechanisms:+1. **Explicit**: `Task tool subagent_type: "agent-name"` - always works+2. **Automatic**: Claude matches task descriptions to agent descriptions - requires strong phrasing++Without "MUST BE USED" and "Use PROACTIVELY", automatic delegation may not trigger even when the task matches.++## Session Restart Required++After creating or modifying agents, restart the Claude Code session. Agents are loaded at session start and won't appear in available subagent_types until restart.++## Pipeline Agents: Update Predecessor++When inserting a new agent into a numbered pipeline (e.g., `HTML-01` → `HTML-05` → `HTML-11`):++| Must Update | What |+|-------------|------|+| New agent | "Workflow Position" diagram + "Next" field |+| **Predecessor agent** | Its "Next" field to point to new agent |++**Common bug**: New agent has correct position, but predecessor still points to the old next agent. The new agent is "orphaned" and gets skipped.++**Verification**:+```bash+grep -n "Next:.*→\|Then.*runs next" .claude/agents/*.md+```++Every pipeline agent should point to exactly one successor.diff --git a/skills/agent-development/rules/custom-agent-instructions.md b/skills/agent-development/rules/custom-agent-instructions.mdnew file mode 100644index 00000000..6f59cf8e--- /dev/null+++ b/skills/agent-development/rules/custom-agent-instructions.md@@ -0,0 +1,133 @@+---+globs: ["**/.claude/agents/*.md", "**/agents/*.md", "**/.claude/settings.json"]+---++# Custom Agent Design Principles++## 1. Declarative Over Imperative++Describe **what** to accomplish, not **how** to use tools.++Claude Code's harness already includes tool selection guidance - prescriptive instructions can conflict with it.++## 2. Give All Tools to All Agents++Don't micromanage tool lists per agent. Use a standard full toolset:++```yaml+tools: Read, Write, Edit, Glob, Grep, Bash+```++**Why**: Simpler config, more flexibility, trust the model to choose.++## 3. Use Allowlists for Bash Commands++Instead of restricting Bash access, allowlist safe commands in `.claude/settings.json`:++```json+{+ "permissions": {+ "allow": [+ "Write",+ "Edit",+ "WebFetch(domain:*)",+ "Bash(cd *)",+ "Bash(cp *)",+ "Bash(mkdir *)",+ "Bash(ls *)",+ "Bash(find *)",+ "Bash(cat *)",+ "Bash(head *)",+ "Bash(tail *)",+ "Bash(wc *)",+ "Bash(pwd)",+ "Bash(echo *)",+ "Bash(grep *)",+ "Bash(diff *)",+ "Bash(mv *)",+ "Bash(touch *)",+ "Bash(basename *)",+ "Bash(dirname *)",+ "Bash(sort *)",+ "Bash(uniq *)",+ "Bash(test *)",+ "Bash([ *)",+ "Bash(for *)",+ "Bash(cut *)",+ "Bash(file *)"+ ]+ }+}+```++This avoids permission prompts without limiting agent capabilities.++**Why these are included**:+- `Write`, `Edit` - Background agents can't prompt; without these, file ops fail silently+- `WebFetch(domain:*)` - Allow fetching from any domain without prompts+- `Bash(...)` - Safe read-only and file management commands++**Note**: `WebSearch` doesn't support wildcards - it requires exact search terms, so can't be blanket-allowed.++**Note**: Pattern matching is based on the **first token** - `for file in...` needs `Bash(for *)`, not just the commands inside the loop.++## Corrections++| If agent says... | Use instead... |+|------------------|----------------|+| `grep -r "PLACEHOLDER:" build/*.html` | "Find any PLACEHOLDER comments in build/*.html" |+| `ls build/` | "Check build/ folder exists and list its contents" |+| `cat discovery/report.json \| jq '.abn'` | "Read ABN from discovery/report.json" |+| "Use the Grep tool to..." | "Search for X in Y" |+| "Run this bash command:" | "Verify that X exists/matches/contains" |++## Pattern++**Imperative (avoid)**:+```markdown+### Check for placeholders+```bash+grep -r "PLACEHOLDER:" build/*.html+grep -ri "TODO\|TBD" build/*.html+```+```++**Declarative (prefer)**:+```markdown+### Check for placeholders+Search all HTML files in build/ for:+- PLACEHOLDER: comments+- TODO or TBD markers+- Template brackets like [Client Name]++Any match = incomplete content.+```++## What to Include in Agent Instructions++| Include | Skip |+|---------|------|+| Task goal and context | Explicit bash/tool commands |+| Input file paths | "Use X tool to..." |+| Output file paths and format | Step-by-step tool invocations |+| Success/failure criteria | Shell pipeline syntax |+| Blocking checks (prerequisites) | Micromanaged workflows |+| Quality checklists | |++## Exception++Bash commands in instructions are appropriate when:+- Running external CLIs (`jezpress-cli`, `npx tsx`, `wrangler`)+- Complex file operations that tools don't cover+- The specific command syntax matters (rare)++## Summary++**Philosophy**: Trust the model, simplify config, use allowlists.++| Instead of... | Do this... |+|---------------|------------|+| Curating tools per agent | Give all tools to all agents |+| Prescribing how to use tools | Describe what to accomplish |+| Restricting Bash access | Allowlist safe commands |+| Micromanaging workflows | Define inputs, outputs, criteria |diff --git a/skills/google-gemini-api/rules/google-gemini-api.md b/skills/google-gemini-api/rules/google-gemini-api.mdindex ab50872e..646d7f02 100644--- a/skills/google-gemini-api/rules/google-gemini-api.md+++ b/skills/google-gemini-api/rules/google-gemini-api.md@@ -94,3 +94,19 @@ const cache = await ai.caches.create({| Disabling thinking | Adjust `thinkingBudget` instead || `gemini-pro` | `gemini-2.5-pro` or `gemini-2.5-flash` || Generic model for caching | Explicit version (e.g., `gemini-2.5-flash-001`) |+| `genai.getGenerativeModel()` | `ai.models.generateContent()` |++## Image Generation Models++| Model ID | Codename | Use For |+|----------|----------|---------|+| `gemini-2.0-flash-exp-image-generation` | Nano Banana | Fast, 1024px |+| `gemini-2.5-flash-preview-image-generation` | Nano Banana | Fast iteration |+| `gemini-2.5-pro-preview-image-generation` | Nano Banana Pro | 4K, complex, text |++## NEVER++- Never use `@google/generative-ai` package+- Never use `GoogleGenerativeAI` class+- Never use `.getGenerativeModel()` pattern+- These are all deprecated patterns from the old SDKdiff --git a/skills/oauth-integrations/README.md b/skills/oauth-integrations/README.mdnew file mode 100644index 00000000..35901243--- /dev/null+++ b/skills/oauth-integrations/README.md@@ -0,0 +1,61 @@+# OAuth Integrations Skill++Implement OAuth 2.0 authentication with GitHub and Microsoft Entra (Azure AD) in Cloudflare Workers and other edge environments.++## Auto-Trigger Keywords++This skill should be automatically loaded when discussions involve:++- "GitHub OAuth", "GitHub authentication", "GitHub API"+- "Microsoft OAuth", "Azure AD", "Entra ID", "MSAL"+- "OAuth callback", "token exchange"+- "User-Agent header", "403 forbidden" (GitHub context)+- "User.Read scope", "Microsoft Graph"+- "github.com/login/oauth", "login.microsoftonline.com"+- "AADSTS", "AADSTS50058", "AADSTS700084"+- "private email", "/user/emails"+- "jose", "JWT validation"++## What This Skill Covers++1. **GitHub OAuth** - Required headers, private email handling, token exchange+2. **Microsoft Entra** - Manual OAuth without MSAL, required scopes, tenant config+3. **Edge Runtime** - Patterns for Cloudflare Workers without browser/Node APIs+4. **Error Handling** - Provider-specific error codes and fixes++## Quick Start++### GitHub OAuth++```typescript+// Always include User-Agent!+const resp = await fetch('https://api.github.com/user', {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ 'User-Agent': 'MyApp/1.0',+ 'Accept': 'application/vnd.github+json',+ },+});+```++### Microsoft OAuth++```typescript+// Always include User.Read scope!+const scope = 'openid email profile User.Read offline_access';++// Use Graph API for user info+const resp = await fetch('https://graph.microsoft.com/v1.0/me', {+ headers: { Authorization: `Bearer ${accessToken}` },+});+```++## Related Skills++- `cloudflare-worker-base` - Edge runtime setup+- `clerk-auth` - Managed auth alternative+- `better-auth` - Self-hosted auth library++## Version History++- **v1.0.0** (2025-01-18): Initial release with GitHub and Microsoft OAuth patternsdiff --git a/skills/oauth-integrations/SKILL.md b/skills/oauth-integrations/SKILL.mdnew file mode 100644index 00000000..02e75c1c--- /dev/null+++ b/skills/oauth-integrations/SKILL.md@@ -0,0 +1,169 @@+---+name: oauth-integrations+description: |+ Implement OAuth 2.0 authentication with GitHub and Microsoft Entra (Azure AD) in Cloudflare Workers+ and other edge environments. Covers provider-specific quirks, required headers, scope requirements,+ and token handling without MSAL.++ Use when: implementing GitHub OAuth, Microsoft/Azure AD authentication, handling OAuth callbacks,+ or troubleshooting 403 errors in OAuth flows.+license: MIT+---++# OAuth Integrations for Edge Environments++Implement GitHub and Microsoft OAuth in Cloudflare Workers and other edge runtimes.++## GitHub OAuth++### Required Headers++GitHub API has strict requirements that differ from other providers.++| Header | Requirement |+|--------|-------------|+| `User-Agent` | **REQUIRED** - Returns 403 without it |+| `Accept` | `application/vnd.github+json` recommended |++```typescript+const resp = await fetch('https://api.github.com/user', {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ 'User-Agent': 'MyApp/1.0', // Required!+ 'Accept': 'application/vnd.github+json',+ },+});+```++### Private Email Handling++GitHub users can set email to private (`/user` returns `email: null`).++```typescript+if (!userData.email) {+ const emails = await fetch('https://api.github.com/user/emails', { headers })+ .then(r => r.json());+ userData.email = emails.find(e => e.primary && e.verified)?.email;+}+```++Requires `user:email` scope.++### Token Exchange++Token exchange returns form-encoded by default. Add Accept header for JSON:++```typescript+const tokenResponse = await fetch('https://github.com/login/oauth/access_token', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/x-www-form-urlencoded',+ 'Accept': 'application/json', // Get JSON response+ },+ body: new URLSearchParams({ code, client_id, client_secret, redirect_uri }),+});+```++### GitHub OAuth Notes++| Issue | Solution |+|-------|----------|+| Callback URL | Must be EXACT - no wildcards, no subdirectory matching |+| Token exchange returns form-encoded | Add `'Accept': 'application/json'` header |+| Tokens don't expire | No refresh flow needed, but revoked = full re-auth |++## Microsoft Entra (Azure AD) OAuth++### Why MSAL Doesn't Work in Workers++MSAL.js depends on:+- Browser APIs (localStorage, sessionStorage, DOM)+- Node.js crypto module++Cloudflare's V8 isolate runtime has neither. Use manual OAuth instead:+1. Manual OAuth URL construction+2. Direct token exchange via fetch+3. JWT validation with `jose` library++### Required Scopes++```typescript+// For user identity (email, name, profile picture)+const scope = 'openid email profile User.Read';++// For refresh tokens (long-lived sessions)+const scope = 'openid email profile User.Read offline_access';+```++**Critical**: `User.Read` is required for Microsoft Graph `/me` endpoint. Without it, token exchange succeeds but user info fetch returns 403.++### User Info Endpoint++```typescript+// Microsoft Graph /me endpoint+const resp = await fetch('https://graph.microsoft.com/v1.0/me', {+ headers: { Authorization: `Bearer ${accessToken}` },+});++// Email may be in different fields+const email = data.mail || data.userPrincipalName;+```++### Tenant Configuration++| Tenant Value | Who Can Sign In |+|--------------|-----------------|+| `common` | Any Microsoft account (personal + work) |+| `organizations` | Work/school accounts only |+| `consumers` | Personal Microsoft accounts only |+| `{tenant-id}` | Specific organization only |++### Azure Portal Setup++1. App Registration → New registration+2. Platform: **Web** (not SPA) for server-side OAuth+3. Redirect URIs: Add both `/callback` and `/admin/callback`+4. Certificates & secrets → New client secret++### Token Lifetimes++| Token Type | Default Lifetime | Notes |+|------------|------------------|-------|+| Access token | 60-90 minutes | Configurable via token lifetime policies |+| Refresh token | 90 days | Revoked on password change |+| ID token | 60 minutes | Same as access token |++**Best Practice**: Always request `offline_access` scope and implement refresh token flow for sessions longer than 1 hour.++## Common Corrections++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| GitHub fetch without User-Agent | Add `'User-Agent': 'AppName/1.0'` (REQUIRED) |+| Using MSAL.js in Workers | Manual OAuth + jose for JWT validation |+| Microsoft scope without User.Read | Add `User.Read` scope |+| Fetching email from token claims only | Use Graph `/me` endpoint |++## Error Reference++### GitHub Errors++| Error | Cause | Fix |+|-------|-------|-----|+| 403 Forbidden | Missing User-Agent header | Add User-Agent header |+| `email: null` | User has private email | Fetch `/user/emails` with `user:email` scope |++### Microsoft Errors++| Error | Cause | Fix |+|-------|-------|-----|+| AADSTS50058 | Silent auth failed | Use interactive flow |+| AADSTS700084 | Refresh token expired | Re-authenticate user |+| 403 on Graph /me | Missing User.Read scope | Add User.Read to scopes |++## Reference++- GitHub API: https://docs.github.com/en/rest+- GitHub OAuth: https://docs.github.com/en/apps/oauth-apps+- Microsoft Graph permissions: https://learn.microsoft.com/en-us/graph/permissions-reference+- AADSTS error codes: https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codesdiff --git a/skills/oauth-integrations/rules/github-oauth.md b/skills/oauth-integrations/rules/github-oauth.mdnew file mode 100644index 00000000..7c4a29b5--- /dev/null+++ b/skills/oauth-integrations/rules/github-oauth.md@@ -0,0 +1,58 @@+---+globs: ["**/*github*", "**/oauth/**/*.ts", "**/auth/**/*.ts", "**/callback*.ts"]+---++# GitHub API & OAuth++GitHub API has strict requirements that differ from Google/Microsoft.++## Required Headers++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| Fetch without User-Agent | `'User-Agent': 'AppName/1.0'` (REQUIRED - 403 without) |+| No Accept header | `'Accept': 'application/vnd.github+json'` |++```typescript+const resp = await fetch('https://api.github.com/user', {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ 'User-Agent': 'MyApp/1.0',+ 'Accept': 'application/vnd.github+json',+ },+});+```++## Private Email Handling++GitHub users can set email to private (`/user` returns `email: null`).++```typescript+if (!userData.email) {+ const emails = await fetch('https://api.github.com/user/emails', { headers }).then(r => r.json());+ userData.email = emails.find(e => e.primary && e.verified)?.email;+}+```++Requires `user:email` scope.++## OAuth Specifics++| Issue | Solution |+|-------|----------|+| Callback URL | Must be EXACT - no wildcards, no subdirectory matching |+| Token exchange returns form-encoded | Add `'Accept': 'application/json'` header |+| Tokens don't expire | No refresh flow needed, but revoked = full re-auth |++## Token Exchange++```typescript+const tokenResponse = await fetch('https://github.com/login/oauth/access_token', {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/x-www-form-urlencoded',+ 'Accept': 'application/json',+ },+ body: new URLSearchParams({ code, client_id, client_secret, redirect_uri }),+});+```diff --git a/skills/oauth-integrations/rules/microsoft-oauth.md b/skills/oauth-integrations/rules/microsoft-oauth.mdnew file mode 100644index 00000000..adf12b3e--- /dev/null+++ b/skills/oauth-integrations/rules/microsoft-oauth.md@@ -0,0 +1,83 @@+---+globs: ["**/oauth*.ts", "**/auth*.ts", "**/microsoft*.ts", "**/azure*.ts", "**/entra*.ts", "**/callback*.ts"]+---++# Microsoft OAuth in Cloudflare Workers++Patterns for implementing Microsoft Entra (Azure AD) OAuth in Cloudflare Workers without MSAL.++## Corrections++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| Using MSAL.js in Workers | Manual OAuth + jose for JWT validation |+| Scope `openid email profile` for user info | Add `User.Read` scope |+| Fetching email from token claims only | Use Microsoft Graph `/me` endpoint |++## Why MSAL Doesn't Work in Workers++MSAL.js depends on:+- Browser APIs (localStorage, sessionStorage, DOM)+- Node.js crypto module++Cloudflare's V8 isolate runtime has neither. The workaround is simpler and more secure:+1. Manual OAuth URL construction+2. Direct token exchange via fetch+3. JWT validation with `jose` library++## Required Scopes++```typescript+// For user identity (email, name, profile picture)+const scope = 'openid email profile User.Read';++// For refresh tokens (long-lived sessions)+const scope = 'openid email profile User.Read offline_access';+```++**Critical**: `User.Read` is required for Microsoft Graph `/me` endpoint. Without it, token exchange succeeds but user info fetch returns 403.++## User Info Endpoint++```typescript+// Microsoft Graph /me endpoint+const resp = await fetch('https://graph.microsoft.com/v1.0/me', {+ headers: { Authorization: `Bearer ${accessToken}` },+});++// Email may be in different fields+const email = data.mail || data.userPrincipalName;+```++## Tenant Configuration++| Tenant Value | Who Can Sign In |+|--------------|-----------------|+| `common` | Any Microsoft account (personal + work) |+| `organizations` | Work/school accounts only |+| `consumers` | Personal Microsoft accounts only |+| `{tenant-id}` | Specific organization only |++## Azure Portal Setup++1. App Registration → New registration+2. Platform: **Web** (not SPA) for server-side OAuth+3. Redirect URIs: Add both `/callback` and `/admin/callback`+4. Certificates & secrets → New client secret++## Token Lifetimes++| Token Type | Default Lifetime | Notes |+|------------|------------------|-------|+| Access token | 60-90 minutes | Configurable via token lifetime policies |+| Refresh token | 90 days | Revoked on password change, can be extended |+| ID token | 60 minutes | Same as access token |++**Best Practice**: Always request `offline_access` scope and implement refresh token flow for sessions longer than 1 hour.++📚 **Source**: https://learn.microsoft.com/en-us/entra/identity-platform/access-tokens#token-lifetime++## Reference++- Graph API permissions: https://learn.microsoft.com/en-us/graph/permissions-reference+- AADSTS error codes: https://learn.microsoft.com/en-us/entra/identity-platform/reference-error-codes