{"id":50887459,"url":"https://github.com/nurettincoban/diff2ai","last_synced_at":"2026-06-15T18:00:59.548Z","repository":{"id":313974966,"uuid":"1052312119","full_name":"nurettincoban/diff2ai","owner":"nurettincoban","description":"Turn your Git diffs into beautiful, high-signal AI code review prompts — fast, local, and repo-safe.","archived":false,"fork":false,"pushed_at":"2025-09-10T18:59:10.000Z","size":479,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-14T01:13:22.933Z","etag":null,"topics":["ai","chatgpt","claude-code","cli","code-review","diff","git","pull-request"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nurettincoban.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-07T20:42:11.000Z","updated_at":"2025-10-12T10:47:41.000Z","dependencies_parsed_at":"2025-09-09T22:35:59.624Z","dependency_job_id":"f68d91e5-630b-4c0f-a0d1-ec25d575bd49","html_url":"https://github.com/nurettincoban/diff2ai","commit_stats":null,"previous_names":["nurettincoban/diff2ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nurettincoban/diff2ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurettincoban%2Fdiff2ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurettincoban%2Fdiff2ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurettincoban%2Fdiff2ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurettincoban%2Fdiff2ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nurettincoban","download_url":"https://codeload.github.com/nurettincoban/diff2ai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nurettincoban%2Fdiff2ai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34374146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chatgpt","claude-code","cli","code-review","diff","git","pull-request"],"created_at":"2026-06-15T18:00:57.216Z","updated_at":"2026-06-15T18:00:59.540Z","avatar_url":"https://github.com/nurettincoban.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diff2ai\n\n[![npm version](https://img.shields.io/npm/v/diff2ai.svg?logo=npm\u0026label=npm)](https://www.npmjs.com/package/diff2ai)\n[![npm downloads](https://img.shields.io/npm/dm/diff2ai.svg?color=blue)](https://www.npmjs.com/package/diff2ai)\n![node version](https://img.shields.io/badge/node-%3E%3D18.0-brightgreen)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#license) [![TypeScript](https://img.shields.io/badge/TypeScript-Strict-blue?logo=typescript)](#)\n\n\u003e ⭐️ If you find diff2ai useful, please give it a star on GitHub — it helps a lot!\n\nQuick links: [Installation](#installation) • [Quickstart](#quickstart) • [CLI](#cli-at-a-glance) • [Demos](#demos) • [Configuration](#configuration)\n\nTurn your Git diffs into beautiful, high-signal AI code review prompts — fast, local, and repo-safe.\n\n- ⚡️ Zero network by default (pure git)\n- 🧠 Strict, opinionated default template that drives high‑quality AI feedback\n- 🧩 Smart chunking for large diffs with merge guidance\n- 🛡️ Safety preflight checks; no destructive actions without consent\n- 🖼️ Pretty CLI output in TTY; stays script‑friendly for CI\n\n---\n\n## ✨ Why diff2ai?\n\nMost AI reviews are noisy. diff2ai generates a focused prompt from your actual diff, with a strict schema that forces actionable feedback (severity, file/line ranges, proposed fix). Paste it into your favorite AI coding agent and get a concise, useful review.\n\n---\n\n## 📦 Installation\n\nRequirements\n\n- Node.js \u003e= 18\n\nGlobal install (recommended)\n\n```bash\nnpm i -g diff2ai\ndiff2ai --version   # verify (e.g., 0.0.3)\n```\n\nUse without installing (npx)\n\n```bash\nnpx diff2ai --help\n```\n\nUpgrade to latest\n\n```bash\nnpm i -g diff2ai@latest\n```\n\n## 🚀 Quickstart\n\n```bash\n# Generate AI-ready prompt for your MR against main\ngit fetch origin main\ndiff2ai review feature/my-branch --target main --copy\n\n# Optional: let diff2ai switch to the branch for you (repo will remain on it)\ndiff2ai review feature/my-branch --target main --copy --switch --fetch\n\n# Paste the generated prompt from your clipboard into Claude, Cursor, or Copilot\n```\n\n---\n\n## 🧰 CLI at a glance\n\n- `review \u003cref\u003e`: end‑to‑end — generate a diff from a branch/ref and immediately produce an AI prompt (default template). Add `--copy` to place the prompt on your clipboard. Use `--save-diff` if you also want the raw `.diff` file written.\n  - Flags:\n    - `--switch` Switch to `\u003cref\u003e` before running (refuses if dirty/untracked unless `--yes`)\n    - `--fetch` Fetch `origin/\u003ctarget\u003e` and `origin/\u003cref\u003e` before running\n- `prompt \u003cdiff\u003e`: render an AI prompt from an existing `.diff` file.\n  - Flags:\n    - `--template \u003cnameOrPath\u003e` Use a template by name (project `./templates/` or packaged) or a direct `.md` file path (absolute or relative)\n    - `--templates-dir \u003cdir\u003e` Directory to resolve named templates from (defaults to project `./templates/`)\n- `templates`: list available templates (project and packaged)\n- `diff [--staged]`: write a `.diff` from your working tree (or staged changes).\n- `show \u003csha\u003e`: write a `.diff` for a specific commit.\n- `chunk \u003cdiff\u003e`: split a large `.diff` into `batch_*.md` files + index.\n\nGlobal flags (MVP):\n\n- `--no-interactive` Disable prompts (for CI/non‑TTY)\n- `--yes` Auto‑confirm safe prompts\n\n---\n\n## 🎬 Demos\n\n\u003cdetails\u003e\n\u003csummary\u003eShow demos\u003c/summary\u003e\n\nReview a branch (auto‑prompt + copy to clipboard):\n\n```bash\ndiff2ai review feature/payments --copy\n# writes:\n#  - review_YYYY-MM-DD_HH-mm-ss-SSS.md  (default template)\n#  - copies prompt content to your clipboard\n#  - add --save-diff to also write review_YYYY-MM-DD_HH-mm-ss-SSS.diff\n# Recommended for AI agents (Cursor/Claude):\n# Ensure the tool is on the branch being reviewed and fetch refs\ndiff2ai review feature/payments --target main --copy --switch --fetch\n```\n\nPick a template explicitly:\n\n```bash\ndiff2ai review feature/api --template default\n# or a minimal one\ndiff2ai review feature/api --template basic\n# or your own project template (./templates/my-template.md)\ndiff2ai review feature/api --template my-template\n# or via direct file path\ndiff2ai review feature/api --template ./templates/my-template.md\n# specify a custom templates directory\ndiff2ai review feature/api --templates-dir ./my-templates --template code-review\n# use packaged templates by name (no copying needed)\ndiff2ai review feature/api --template security\ndiff2ai review feature/api --template api-best-practices\ndiff2ai review feature/api --template reliability\ndiff2ai review feature/api --template event-driven\n```\n\nWork from an existing diff:\n\n```bash\ndiff2ai diff --staged         # produce staged_*.diff\ndiff2ai prompt staged_*.diff  # produce staged_*.md (uses default template)\n# with a custom template\ndiff2ai prompt staged_*.diff --template my-template\n# To save the AI response yourself, use native OS commands, e.g. on macOS:\n# pbpaste \u003e reviews/review_response.md\n```\n\nHandle big diffs:\n\n```bash\ndiff2ai chunk huge.diff --profile generic-medium\n# writes batch_*.md and review_index.md (merge instructions included)\n```\n\n \u003c/details\u003e\n\n---\n\n## 🧱 The default template (strict)\n\nThe default template enforces a clean, repeatable review structure. AI reviewers must output only numbered issue blocks — no preambles, no conclusions, no diff echo.\n\nIssue block schema:\n\n```text\n## \u003cn\u003e) Severity: CRITICAL|HIGH|MEDIUM|LOW|INFO | Type: Implementation|Bug|Security|Test|Performance|Style|Doc|Maintainability\nTitle: \u003cshort imperative\u003e\n\nAffected:\n- path/to/file.ext:lineStart-lineEnd\n\nExplanation:\n\u003cwhat is wrong, why it matters, how to fix\u003e\n\nProposed fix:\n~~~\u003clang\u003e\n\u003cminimal snippet or steps\u003e\n~~~\n```\n\nFor chunked reviews: “Do not assume context outside this chunk; if cross‑file risks are suspected, note briefly.”\n\nTemplates available:\n\n- `default` (strict, recommended)\n- `basic` (lightweight)\n\n## 🧪 Example output\n\n```text\n## 1) Severity: HIGH | Type: Implementation\nTitle: Avoid mutation of request body in middleware\n\nAffected:\n- src/middleware/auth.ts:42-57\n\nExplanation:\nMutating the incoming request object can introduce side effects across downstream handlers. Use a cloned object or limit changes to a derived value.\n\nProposed fix:\n~~~ts\nconst sanitized = { ...req.body, password: undefined };\nnext();\n~~~\n```\n\n---\n\n## 🗂️ Output files\n\n- Default output location: current working directory.\n- Recommended: use a dedicated `reviews/` directory and add it to `.gitignore`.\n\n- `*.md` AI‑ready prompt (paste into your AI coding agent)\n- `*.diff` unified diff (optional for `review` via `--save-diff`; always produced by `diff`/`show`)\n- `batch_*.md` chunked prompts for large diffs\n- `review_index.md` guidance for merging batch results into a single review\n\n```bash\ndiff2ai review feature/api --target main --save-diff\n# writes reviews/*.md and reviews/*.diff (with --save-diff)\n```\n\nPaste the generated `*.md` into the MR/PR description or as a top comment.\nUse the prompt with your AI reviewer. Save the AI’s response locally with `diff2ai pasteback` and commit or share as needed.\n\n---\n\n## 🛡️ Safety \u0026 behavior\n\n- Preflight checks warn about dirty/untracked files, stash, and divergence.\n- Interactive prompts guide target selection; non‑interactive mode stays quiet.\n- No destructive actions are taken without explicit confirmation.\n- `--switch` will refuse to change branches if the working tree is dirty or has untracked files unless you pass `--yes`. The repository remains on `\u003cref\u003e` after completion.\n\n---\n\n## ⚙️ Configuration\n\nCreate `.aidiff.json` (JSON5 supported):\n\n```json5\n{\n  target: 'main', // default target branch\n  profile: 'generic-medium', // default chunking profile\n  include: ['src/**', 'apps/**'],\n  exclude: ['**/*.lock', 'dist/**', '**/*.min.*'],\n  // Optional: default template config\n  // Use a name (resolved from project ./templates by default) or a file path\n  template: 'my-template',\n  // Optional: where to resolve named templates from (defaults to ./templates)\n  templatesDir: './templates',\n}\n```\n\nIgnore paths in `.aidiffignore` (minimatch):\n\n```\n**/*.lock\n**/dist/**\n**/*.min.*\n```\n\nProfiles (token budgets):\n\n- `claude-large` ≈ 150k tokens\n- `generic-large` ≈ 100k tokens\n- `generic-medium` ≈ 30k tokens\n\n---\n\n## 🧯 Troubleshooting\n\n- Templates directory not found\n  - Fixed in \u003e= 0.0.2. Update to latest: `npm i -g diff2ai@latest`.\n  - If developing locally, ensure `npm run build` copied `templates/` into `dist/templates/`.\n  - Project-local `templates/` in your CWD are also supported.\n\n- Custom template not found\n  - When using a name (e.g., `--template my-template`), diff2ai looks for `./templates/my-template.md` by default, or under `--templates-dir`/`templatesDir` if provided.\n  - You can also pass a direct path: `--template ./my-templates/review.md`.\n  - Packaged templates can be used by name without copying (e.g., `--template security`).\n\n- \"Missing required placeholder {diff_content}\"\n  - Your custom template must include `{diff_content}` where you want the unified diff injected.\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions! Ways to help:\n\n- Improve templates and review schema\n- Enhance chunking heuristics and performance\n- Add tests and fixtures for edge cases\n- Polish CLI UX and docs\n\nDev setup:\n\n```bash\nnpm install\nnpm run build\nnpm test\nnpm run lint\nnpm run format\n```\n\nConventional flow:\n\n1. Fork \u0026 branch (small, focused changes)\n2. Add tests when adding features/fixing bugs\n3. Keep files \u003c 300 lines where practical\n4. Ensure `npm test` and `npm run lint` pass\n5. Open a PR with a clear description and screenshots/terminal output when relevant\n\n---\n\n## ❓ FAQ\n\n- “Why did `chunk` produce only one file?”\n  - Your diff likely fits within the selected profile’s token budget; that’s expected.\n- “Where do I put the AI’s response?”\n  - Wherever you prefer: PR comments, a `review.md` file, or your internal tools.\n- “Can I script this in CI?”\n  - Yes. Use `--no-interactive` (and `--yes` if needed).\n\n- “Does this upload my code anywhere?”\n  - No. It runs 100% locally and writes to your filesystem. You decide what to paste into an AI.\n- “How do I handle huge MRs?”\n  - Use `diff2ai chunk \u003cdiff\u003e --profile \u003cname\u003e`, paste each `batch_*.md` to your AI, then merge the results guided by `review_index.md`.\n- “Can I use this on GitLab MRs?”\n  - Yes. Checkout the MR branch locally (or fetch the refs), then run `diff2ai review \u003cbranch\u003e --target \u003cbase\u003e`.\n\n---\n\n## 🪪 License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnurettincoban%2Fdiff2ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnurettincoban%2Fdiff2ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnurettincoban%2Fdiff2ai/lists"}