plugins/developer-guides/skills/devguide-patterns/SKILL.md
# Developer Guide Patterns ## Diátaxis in Practice ### Tutorial characteristics - The user is in a **learning** state, not trying to accomplish a real task - Provide a safe sandbox environment (don't operate on real data) - Every step must succeed - no choices, no optional paths - Show expected output after every step - The goal is the learning experience, not the artifact built ```markdown # Tutorial: Build Your First Webhook Handler In this tutorial, you will build a simple webhook receive
npx skillsauth add hermeticormus/librecopy-claude-code plugins/developer-guides/skills/devguide-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
# Tutorial: Build Your First Webhook Handler
In this tutorial, you will build a simple webhook receiver that logs
incoming events from the payment API.
**What you'll learn:**
- How webhook payloads are structured
- How to verify webhook signatures
- How to respond to webhook events
**What you will NOT need**: an existing account or real payment data.
We use the sandbox environment throughout.
# How to Configure Webhook Signature Verification
**Prerequisites:**
- Webhook endpoint set up (see [Creating a Webhook Endpoint](/guides/create-webhook))
- Your webhook secret from the dashboard
## Steps
1. Store the webhook secret in an environment variable:
```bash
export WEBHOOK_SECRET="whsec_your_secret_here"
Verify the signature in your handler:
import hmac, hashlib
def verify_signature(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(f"sha256={expected}", signature)
Return 200 immediately, process asynchronously: ...
## Code Example Best Practices
### Minimal but complete
```python
# Bad: incomplete example (what is client? what does .charge return?)
result = client.charge(amount=1000)
print(result)
# Good: complete, runnable, handles the error case
import os
from acme import AcmeClient
client = AcmeClient(api_key=os.environ["ACME_API_KEY"])
try:
charge = client.charges.create(
amount=1000, # $10.00 in cents
currency="usd",
source="tok_visa", # Test card token
description="Order #1234",
)
print(f"Charged {charge.amount_formatted}: {charge.id}")
except acme.CardError as e:
print(f"Card declined: {e.user_message}")
Every code example in a developer guide should show:
Run the server:
```bash
python server.py
You should see:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [28720]
The expected output block prevents "is this working?" anxiety. It is the most underused element in developer documentation.
## Prerequisites Format
Never describe prerequisites in prose. Use a structured table or checklist:
```markdown
| Requirement | Version | Verify | Install |
|-------------|---------|--------|---------|
| Python | 3.11+ | `python --version` | [python.org](https://python.org) |
| pip | 23+ | `pip --version` | Included with Python |
| Redis | 7.0+ | `redis-server --version` | `brew install redis` or [redis.io](https://redis.io) |
**Accounts needed:**
- [ ] Acme account with API key ([sign up free](https://acme.com/signup))
- [ ] Stripe account in test mode (optional, for payment examples)
Each step should end in a testable state:
Step 1: Scaffold → `python app.py` runs without error
Step 2: Add database → `python app.py` connects successfully, logs "DB connected"
Step 3: Add first endpoint → `curl localhost:8000/health` returns `{"status": "ok"}`
Step 4: Add authentication → `curl localhost:8000/users` returns 401 without token
Step 5: Test auth → `curl -H "Authorization: Bearer test" localhost:8000/users` returns user list
Place troubleshooting at the end of each step that commonly fails, not in a separate appendix.
## Step 3: Configure the database
[step content]
**If you see "Connection refused":**
This usually means the database server isn't running.
Start it with: `brew services start postgresql` (macOS) or `sudo systemctl start postgresql` (Linux)
**If you see "role does not exist":**
Create the role: `createuser -s $(whoami)`
# Bad: Tutorial requires existing account with real data
## Prerequisites
- An active subscription (minimum Pro plan)
- API key from production dashboard
- At least 10,000 rows in your database
# Good: Tutorial uses sandbox/demo data
## Prerequisites
- Free developer account (sign up at sandbox.acme.com)
- (All data used in this tutorial is generated test data)
# Bad: How-to with embedded explanation (slow, distracts from task)
## How to Add Authentication
JWT (JSON Web Token) is an open standard (RFC 7519) that defines a compact
and self-contained way for securely transmitting information as a JSON object.
Tokens consist of three parts separated by dots...
[3 paragraphs of JWT explanation before any steps]
# Good: How-to with link to explanation
## How to Add JWT Authentication
For background on how JWT tokens work, see [Understanding Authentication Tokens](/concepts/jwt).
**Prerequisites:** Running Express app (see [Getting Started](/get-started))
1. Install the JWT library: `npm install jsonwebtoken`
...
Examples should work outside the tutorial context. If a user copies the code into their own project, it should work with minimal changes (environment variable substitution, not architecture rewrites).
tools
# User Doc Patterns > Patterns for writing clear, accessible end-user documentation. ## Knowledge Base ### User Documentation vs Developer Documentation | User Docs | Developer Docs | |-----------|---------------| | Task-oriented ("How do I...") | Concept-oriented ("How does it work...") | | Plain language | Technical language | | Screenshots and visual aids | Code examples | | Step-by-step procedures | API references | | Feature names and UI labels | Function signatures and parameters | | A
tools
# Tutorial Structures > Pedagogical patterns and frameworks for creating effective technical tutorials. ## Knowledge Base ### The Tutorial Spectrum Tutorials exist on a spectrum between two extremes: | Recipe | Concept Guide | |--------|--------------| | "Do exactly this" | "Understand this idea" | | Step-by-step | Explanation-heavy | | Fast to complete | Deep understanding | | Low retention | High retention | The best tutorials blend both: steps for doing, explanations for understanding.
tools
# Tutorial Patterns ## Tutorial vs. How-to Guide: The Critical Distinction Before writing, identify which document is actually needed: | Tutorial | How-to Guide | |----------|-------------| | "Build a REST API in Node.js" | "Add JWT authentication to your Express API" | | For someone new to this | For someone who knows the domain | | Explains why each step is done | Steps are efficient, minimal explanation | | Has checkpoints, explores | Numbered steps, no detours | | Learner reaches a comple
tools
# Tech Blogging Patterns ## The Developer Reading Pattern Developers do not read technical posts linearly. They scan in this order: 1. Headline (is this relevant to me?) 2. Code blocks (is this real code I can use?) 3. Headers (what does this cover?) 4. First paragraph (what's the point?) 5. Key takeaways / conclusion (is it worth reading fully?) Design for scanning first, reading second. Put real code within the first 25% of the post. ## The Before/After Pattern The contrast between a pain