mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
docs: add hooks guide, expand planner agent, add Django example
- Add hooks/README.md: comprehensive hook documentation with input schema, customization guide, 4 ready-to-use hook recipes, and cross-platform notes - Expand planner agent with full worked example (Stripe subscriptions plan) and sizing/phasing guidance (119 → 212 lines) - Add Django REST API example config (DRF + Celery + pytest + Factory Boy) - Update README directory tree with new files
This commit is contained in:
@@ -98,6 +98,85 @@ Create detailed steps with:
|
||||
6. **Think Incrementally**: Each step should be verifiable
|
||||
7. **Document Decisions**: Explain why, not just what
|
||||
|
||||
## Worked Example: Adding Stripe Subscriptions
|
||||
|
||||
Here is a complete plan showing the level of detail expected:
|
||||
|
||||
```markdown
|
||||
# Implementation Plan: Stripe Subscription Billing
|
||||
|
||||
## Overview
|
||||
Add subscription billing with free/pro/enterprise tiers. Users upgrade via
|
||||
Stripe Checkout, and webhook events keep subscription status in sync.
|
||||
|
||||
## Requirements
|
||||
- Three tiers: Free (default), Pro ($29/mo), Enterprise ($99/mo)
|
||||
- Stripe Checkout for payment flow
|
||||
- Webhook handler for subscription lifecycle events
|
||||
- Feature gating based on subscription tier
|
||||
|
||||
## Architecture Changes
|
||||
- New table: `subscriptions` (user_id, stripe_customer_id, stripe_subscription_id, status, tier)
|
||||
- New API route: `app/api/checkout/route.ts` — creates Stripe Checkout session
|
||||
- New API route: `app/api/webhooks/stripe/route.ts` — handles Stripe events
|
||||
- New middleware: check subscription tier for gated features
|
||||
- New component: `PricingTable` — displays tiers with upgrade buttons
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Phase 1: Database & Backend (2 files)
|
||||
1. **Create subscription migration** (File: supabase/migrations/004_subscriptions.sql)
|
||||
- Action: CREATE TABLE subscriptions with RLS policies
|
||||
- Why: Store billing state server-side, never trust client
|
||||
- Dependencies: None
|
||||
- Risk: Low
|
||||
|
||||
2. **Create Stripe webhook handler** (File: src/app/api/webhooks/stripe/route.ts)
|
||||
- Action: Handle checkout.session.completed, customer.subscription.updated,
|
||||
customer.subscription.deleted events
|
||||
- Why: Keep subscription status in sync with Stripe
|
||||
- Dependencies: Step 1 (needs subscriptions table)
|
||||
- Risk: High — webhook signature verification is critical
|
||||
|
||||
### Phase 2: Checkout Flow (2 files)
|
||||
3. **Create checkout API route** (File: src/app/api/checkout/route.ts)
|
||||
- Action: Create Stripe Checkout session with price_id and success/cancel URLs
|
||||
- Why: Server-side session creation prevents price tampering
|
||||
- Dependencies: Step 1
|
||||
- Risk: Medium — must validate user is authenticated
|
||||
|
||||
4. **Build pricing page** (File: src/components/PricingTable.tsx)
|
||||
- Action: Display three tiers with feature comparison and upgrade buttons
|
||||
- Why: User-facing upgrade flow
|
||||
- Dependencies: Step 3
|
||||
- Risk: Low
|
||||
|
||||
### Phase 3: Feature Gating (1 file)
|
||||
5. **Add tier-based middleware** (File: src/middleware.ts)
|
||||
- Action: Check subscription tier on protected routes, redirect free users
|
||||
- Why: Enforce tier limits server-side
|
||||
- Dependencies: Steps 1-2 (needs subscription data)
|
||||
- Risk: Medium — must handle edge cases (expired, past_due)
|
||||
|
||||
## Testing Strategy
|
||||
- Unit tests: Webhook event parsing, tier checking logic
|
||||
- Integration tests: Checkout session creation, webhook processing
|
||||
- E2E tests: Full upgrade flow (Stripe test mode)
|
||||
|
||||
## Risks & Mitigations
|
||||
- **Risk**: Webhook events arrive out of order
|
||||
- Mitigation: Use event timestamps, idempotent updates
|
||||
- **Risk**: User upgrades but webhook fails
|
||||
- Mitigation: Poll Stripe as fallback, show "processing" state
|
||||
|
||||
## Success Criteria
|
||||
- [ ] User can upgrade from Free to Pro via Stripe Checkout
|
||||
- [ ] Webhook correctly syncs subscription status
|
||||
- [ ] Free users cannot access Pro features
|
||||
- [ ] Downgrade/cancellation works correctly
|
||||
- [ ] All tests pass with 80%+ coverage
|
||||
```
|
||||
|
||||
## When Planning Refactors
|
||||
|
||||
1. Identify code smells and technical debt
|
||||
@@ -106,6 +185,17 @@ Create detailed steps with:
|
||||
4. Create backwards-compatible changes when possible
|
||||
5. Plan for gradual migration if needed
|
||||
|
||||
## Sizing and Phasing
|
||||
|
||||
When the feature is large, break it into independently deliverable phases:
|
||||
|
||||
- **Phase 1**: Minimum viable — smallest slice that provides value
|
||||
- **Phase 2**: Core experience — complete happy path
|
||||
- **Phase 3**: Edge cases — error handling, edge cases, polish
|
||||
- **Phase 4**: Optimization — performance, monitoring, analytics
|
||||
|
||||
Each phase should be mergeable independently. Avoid plans that require all phases to complete before anything works.
|
||||
|
||||
## Red Flags to Check
|
||||
|
||||
- Large functions (>50 lines)
|
||||
@@ -115,5 +205,8 @@ Create detailed steps with:
|
||||
- Hardcoded values
|
||||
- Missing tests
|
||||
- Performance bottlenecks
|
||||
- Plans with no testing strategy
|
||||
- Steps without clear file paths
|
||||
- Phases that cannot be delivered independently
|
||||
|
||||
**Remember**: A great plan is specific, actionable, and considers both the happy path and edge cases. The best plans enable confident, incremental implementation.
|
||||
|
||||
Reference in New Issue
Block a user