P

PR Enhance Command

Automatically generate comprehensive pull request descriptions, add review guidelines, highlight breaking changes, and suggest reviewers based on code ownership. Turns minimal PR descriptions into well-structured, reviewer-friendly documentation.

CommandCommunitycode reviewv1.0.0MIT
0 views0 copies

Command

/pr-enhance

Description

Analyzes your current branch's changes and generates a thorough pull request description with summary, impact analysis, testing notes, and review guidelines. Can either create a new PR or enhance an existing PR's description.

Behavior

  1. Diff the current branch against the base branch
  2. Categorize changes: features, fixes, refactors, tests, docs
  3. Detect breaking changes, migration requirements, env var changes
  4. Generate structured PR description
  5. Identify suggested reviewers from git blame/CODEOWNERS
  6. Output ready-to-use PR body in markdown

Output Format

## Summary Add sliding window rate limiting to all authenticated API endpoints to prevent abuse and ensure fair resource allocation. ## Changes ### New Files - `src/middleware/rateLimiter.ts` - Core rate limiting middleware - `src/config/rateLimits.ts` - Per-endpoint rate limit configuration - `tests/middleware/rateLimiter.test.ts` - Unit tests (15 test cases) ### Modified Files - `src/routes/api.ts` - Applied rate limit middleware to all routes - `src/lib/redis.ts` - Added rate limit key prefix constant ## Breaking Changes - API responses now include `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` headers - Requests exceeding limits receive `429 Too Many Requests` ## Environment Changes - New: `RATE_LIMIT_REDIS_URL` - Redis connection for rate limiting - New: `RATE_LIMIT_DEFAULT` - Default requests per minute (default: 60) ## How to Test 1. Start Redis locally: `docker run -p 6379:6379 redis:alpine` 2. Set `RATE_LIMIT_REDIS_URL=redis://localhost:6379` 3. Run tests: `npm test -- --grep "rate limit"` 4. Manual test: Send 61 requests in 60 seconds, verify 429 response ## Screenshots / API Examples ```bash # Normal response (request 1-60) curl -i https://api.example.com/users # X-RateLimit-Remaining: 59 # Rate limited response (request 61+) curl -i https://api.example.com/users # HTTP 429 {"error": "Rate limit exceeded", "retryAfter": 45}

Checklist

  • Tests added/updated
  • Documentation updated
  • Migration required
  • Backward compatible
  • Feature flag needed

Suggested Reviewers

  • @backend-team (owns src/middleware/)
  • @sarah (recent changes to src/routes/api.ts)

## Rules

1. **Never fabricate changes** - only describe what's actually in the diff
2. **Flag breaking changes prominently** at the top
3. **Include testing instructions** that a reviewer can follow
4. **Be specific** about what changed and why
5. **Mention environment changes** (new env vars, config changes)
6. **Keep the summary** to 1-2 sentences

## Examples

```bash
# Generate PR description for current branch
/pr-enhance

# Enhance an existing PR
/pr-enhance --pr 234

# Auto-create PR with generated description
/pr-enhance --create --base main

# Include specific reviewers
/pr-enhance --reviewers @sarah,@backend-team
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates