The input was one rough paragraph. This came out 28 seconds later.
PRDraft is a CLI tool that reads a git diff or GitHub PR and generates a high-quality PR description automatically. It produces a structured description including a change summary, motivation, affected files, and testing checklist — reducing the time a developer spends on PR hygiene from 5–15 minutes to under 30 seconds.
Developers write poor PR descriptions not because they don't care, but because they've already spent cognitive energy on the code. By the time a PR is ready, writing a clear description feels like overhead. The result: reviewers lack context, reviews take longer, and merge queues back up.
Existing tools require GitHub App installations, team accounts, or complex CI configuration. A solo developer with a local repo should be able to run a single command and get a draft description they're proud of.
git diff main output or read from stdin--pr 123 --repo owner/repo--format plainprdraft [options]--pr flag (GitHub API)ANTHROPIC_API_KEYtsconfig.json, package.json, Commander.js for CLI arg parsing, and a working prdraft --help command. Set up npm build script and local dev workflow with ts-node.npm run build compiles to dist/node dist/index.js --help shows usage--version flag returns version from package.json
--pr flag is passed, read from stdin. Detect if stdin is a TTY (no pipe) and show helpful error message. Parse raw diff text and pass to prompt builder.git diff main | prdraft works end-to-end~/.prdraft/config.json. Read order: config file → env var ANTHROPIC_API_KEY. Add prdraft config --set-key command to update.prdraft config --set-key works--pr 123 --repo owner/repo is passed, fetch the PR diff from GitHub API using Octokit. Requires GitHub token stored in config. Combine PR title + body + diff into prompt context.prdraft --pr 42 --repo alice/myapp fetches and generatesclipboardy. Show "✓ Copied to clipboard" message. Add --format plain flag that strips markdown formatting. Add --no-copy flag to disable auto-copy.--format plain removes markdown symbols--no-copy suppresses clipboard operation
npm test passes with no API callspackage.json for npm publish with bin pointing to CLI entry. Set up prepublish build step. Write README with installation, quickstart, all flags. Test npx prdraft flow works from scratch.npm install -g prdraft installs globallynpx prdraft works without install# CLAUDE.md — PRDraft
## Project Overview
PRDraft is a TypeScript CLI tool that reads a git diff or GitHub PR and generates a well-structured PR description using the Anthropic Claude API. Single developer project. Designed for simplicity and speed — zero config for basic use.
## Current Status
Early development. Building MVP toward npm publish.
## Tech Stack
- **Runtime:** Node.js (v18+)
- **Language:** TypeScript (strict mode)
- **CLI framework:** Commander.js
- **AI client:** Anthropic SDK (claude-haiku-3 for speed)
- **GitHub client:** Octokit REST
- **Clipboard:** clipboardy
- **Test runner:** Jest + ts-jest
- **Package manager:** npm
## Project Structure
```
src/
index.ts # CLI entry point, Commander.js setup
input/
stdin.ts # Read and parse git diff from stdin
github.ts # Fetch PR diff via Octokit
ai/
prompt.ts # Build Claude prompt from diff
client.ts # Anthropic API client wrapper
config/
store.ts # ~/.prdraft/config.json read/write
output/
format.ts # Markdown / plain text formatting
clipboard.ts # Copy to clipboard helper
utils/
tokens.ts # Diff truncation to token limit
dist/ # Compiled output (gitignored)
tests/
prompt.test.ts
stdin.test.ts
config.test.ts
```
## Key Design Decisions
- **Input priority:** stdin (git diff piped) is primary use case. GitHub API is secondary.
- **Token limit:** Hard cap at 8,000 tokens for diff input before sending to Claude. Warn user if truncated.
- **Streaming:** Stream Claude output to stdout for perceived speed. Also buffer for clipboard copy.
- **No framework bloat:** No React, no build complexity. Pure TypeScript CLI.
- **Config location:** `~/.prdraft/config.json` — follows XDG spirit, user-level config.
## Coding Guidelines
- No `any` types — TypeScript strict mode is on
- All async functions must handle errors explicitly (no unhandled rejections)
- CLI error messages should be user-readable, not stack traces
- Keep each module under 100 lines — extract helpers early
- No external state management — functions are pure where possible
## Environment Variables
- `ANTHROPIC_API_KEY` — overrides config file if set
- `GITHUB_TOKEN` — overrides config file for GitHub API calls
## What NOT to Build (MVP scope)
- Automatic PR submission or editing
- Web interface or GUI
- Team accounts or dashboards
- Webhooks or CI/CD integration
- Style fine-tuning or personalization
## Testing Approach
- Unit tests mock the Anthropic client entirely (no real API calls in tests)
- Use fixture files in `tests/fixtures/` for sample diffs
- Test truncation at the 8,000 token boundary
- Run: `npm test`
## Common Tasks
- Run locally: `ts-node src/index.ts < tests/fixtures/sample.diff`
- Build: `npm run build`
- Test: `npm test`
- Publish: `npm publish` (runs build first via prepublish)
Paste your rough idea. Get a PRD, GitHub tickets, and CLAUDE.md like this — in under 30 seconds.
Generate my spec →