|
| 1 | +# commitprompt |
| 2 | + |
| 3 | +Turn your `git diff --staged` into a ready-to-paste AI prompt for commit messages, PR descriptions, and changelogs. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install -g commitprompt |
| 9 | +``` |
| 10 | + |
| 11 | +Or use without installing: |
| 12 | + |
| 13 | +```bash |
| 14 | +npx commitprompt |
| 15 | +``` |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### Commit message (default) |
| 20 | + |
| 21 | +```bash |
| 22 | +git add src/my-fix.ts |
| 23 | +commitprompt |
| 24 | +# Prints a structured prompt - paste it into ChatGPT, Claude, or any LLM |
| 25 | +``` |
| 26 | + |
| 27 | +### PR description |
| 28 | + |
| 29 | +```bash |
| 30 | +git add . |
| 31 | +commitprompt --mode pr |
| 32 | +``` |
| 33 | + |
| 34 | +### Changelog entry |
| 35 | + |
| 36 | +```bash |
| 37 | +commitprompt --mode changelog |
| 38 | +``` |
| 39 | + |
| 40 | +### Read diff from a file |
| 41 | + |
| 42 | +```bash |
| 43 | +commitprompt --diff path/to/change.diff |
| 44 | +commitprompt --diff path/to/change.diff --mode pr |
| 45 | +``` |
| 46 | + |
| 47 | +## How it works |
| 48 | + |
| 49 | +1. **Reads** your staged diff (via `git diff --staged`) or a diff file |
| 50 | +2. **Parses** the diff: extracts changed files with +/- counts, detects change type (feat, fix, docs, test, ci...) |
| 51 | +3. **Builds** a structured prompt with file list, diff summary, and mode-specific instructions - ready to paste into any LLM |
| 52 | + |
| 53 | +## Output example |
| 54 | + |
| 55 | +``` |
| 56 | +# Commit Message Request |
| 57 | +
|
| 58 | +## Changed Files |
| 59 | +- src/error-extractor.ts (+50 -14) |
| 60 | +
|
| 61 | +## Diff Summary |
| 62 | +\`\`\`diff |
| 63 | +diff --git a/src/error-extractor.ts b/src/error-extractor.ts |
| 64 | +... |
| 65 | +\`\`\` |
| 66 | +
|
| 67 | +## Instructions |
| 68 | +Write a conventional commit message for these changes. |
| 69 | +Format: <type>(<scope>): <description> |
| 70 | +Types: feat, fix, docs, refactor, test, chore, ci, perf |
| 71 | +Keep the subject line under 72 characters. |
| 72 | +If the change is complex, add a body paragraph explaining WHY (not WHAT). |
| 73 | +``` |
| 74 | + |
| 75 | +## Options |
| 76 | + |
| 77 | +| Flag | Description | Default | |
| 78 | +| ---- | ----------- | ------- | |
| 79 | +| `--mode <commit\|pr\|changelog>` | Output format | `commit` | |
| 80 | +| `--diff <path>` | Read diff from file instead of git | - | |
| 81 | +| `--staged` | Explicit staged diff (same as default) | - | |
| 82 | +| `--context` | Include package.json name in output | - | |
| 83 | + |
| 84 | +## AAHP case study |
| 85 | + |
| 86 | +This tool was built using the [AAHP (AI-to-AI Handoff Protocol)](https://github.com/homeofe/AAHP). |
| 87 | + |
| 88 | +Its sibling project [failprompt](https://github.com/homeofe/failprompt) does the same thing for CI failure logs: turn GitHub Actions errors into structured AI prompts for debugging. |
| 89 | + |
| 90 | +Both tools follow the same 4-module pattern: reader, parser, builder, CLI. |
| 91 | + |
| 92 | +## License |
| 93 | + |
| 94 | +MIT |
0 commit comments