AI News HubLIVE
站内改写2 分钟阅读

待翻译:PR-desc – generate PR descriptions from a Git diff, no AI required

AI 服务暂时不可用,以下为来源摘要,待恢复后补全翻译:Notifications You must be signed in to change notification settings Fork 0 Star 0 BranchesTags Open more actions menu Folders and files NameName Last commit message Last commit date Latest commit History 3 Commits 3 Com…

来源Hacker News AI作者: uzair702

AI 服务暂时不可用,以下为来源正文,待恢复后补全翻译。

Notifications You must be signed in to change notification settings Fork 0 Star 0 BranchesTags Open more actions menu Folders and files NameName Last commit message Last commit date Latest commit History 3 Commits 3 Commits .claude/memory .claude/memory bin bin examples examples .gitignore .gitignore CLAUDE.md CLAUDE.md LICENSE LICENSE README.md README.md package.json package.json Repository files navigation Turn a git diff into a ready-to-paste PR description — no more copying your diff into ChatGPT/Claude and asking "can you write a PR description for this?" every single time you open a pull request. npx pr-desc --branch main Before / after Without pr-desc With pr-desc git diff main npx pr-desc --branch main copy the whole diff (nothing to copy) paste into an AI chat (nothing to paste) type "write me a PR description for this" (nothing to ask) wait for a response, then reformat it markdown, ready to paste into GitHub, instantly Why Every PR needs a summary, a list of what changed, and a checklist — and most people generate that by hand-pasting their diff into an AI chat window. pr-desc does that step locally and deterministically: it reads a diff, groups the changes (source / tests / config / docs), counts additions and deletions per file, and produces clean markdown you can paste straight into GitHub or GitLab. It works fully offline, with zero runtime dependencies. An optional --ai flag will polish the wording with Claude if you want it — never required for basic use. Install npx pr-desc --branch main # no install, just run it or install it globally: npm install -g pr-desc pr-desc --branch main Usage Command What it does pr-desc Diff of staged changes (git diff --cached) pr-desc --branch Diff against another branch pr-desc --all Diff of all uncommitted changes (staged + unstaged) pr-desc Read a diff from a file cat some.diff | pr-desc - Read a diff from stdin pr-desc --ai Polish the output with Claude (needs ANTHROPIC_API_KEY) pr-desc --help Show help AI polish (optional) Set ANTHROPIC_API_KEY in your environment and pass --ai to have Claude rewrite the generated description for clarity. If the key isn't set, --ai silently falls back to the plain, locally generated description — never required for basic usage. Example node bin/cli.js examples/sample.diff Produces: ## Summary This PR updates 3 source file(s), adds 1 new file(s), removes 1 file(s), touches 1 test file(s), updates 1 doc file(s) (+25/-6 lines across 5 file(s)). ## Changes Source - src/auth/login.js (+8/-0) - src/auth/rateLimiter.js (new) (+8/-0) - src/auth/legacyLogin.js (deleted) (+0/-6) Tests - tests/auth/login.test.js (+7/-0) Docs - README.md (+2/-0) ## Checklist - [ ] Tests added/updated - [ ] Docs updated - [ ] Manually verified the change How it works pr-desc is a single file (bin/cli.js) with no runtime dependencies. It splits the unified diff per file, detects new/deleted/renamed files, counts additions and deletions, and categorizes each file as source, test, config, or docs by path pattern — all with plain string parsing, no external diff library. Contributing Issues and PRs welcome — especially around the file-categorization heuristic (more languages/path patterns). Run npm test before submitting, which runs the CLI against examples/sample.diff and checks it doesn't crash. License MIT MIT license Activity Stars 0 stars Watchers 0 watching Forks 0 forks Report repository