git-code-review-agent 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "codereviewagent",
3
+ "displayName": "Code Review Agent (Architect / Dev Lead)",
4
+ "description": "Branch-to-branch git diff code review with Technical Architect and Engineering Lead analysis: PR-style merge-base diffs, architecture, security, delivery risk, and prioritized findings",
5
+ "version": "0.1.0",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "code-review",
9
+ "git",
10
+ "diff",
11
+ "branch",
12
+ "architecture",
13
+ "technical-architect",
14
+ "engineering-lead",
15
+ "pull-request"
16
+ ],
17
+ "skills": "./skills/",
18
+ "agents": "./agents/"
19
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # codereviewagent
2
+
3
+ Cursor IDE plugin that ship **skills** and **subagents** via npm, install into `~/.cursor/plugins/local/`, and restart Cursor.
4
+
5
+ **Focus here:** Technical Architect and Engineering Lead **branch-to-branch** code review — generate a git diff (`base...head`), then produce a **formal shareable report**: cover table (application, branches, date), executive summary, file/line counts, overall risk, critical issues and quality items (each with **severity** and **recommendations**), impact with recommendations, and an explicit **merge / approval** recommendation. The same document is written to `code-reviews/` for distribution.
6
+
7
+ ## What ships
8
+
9
+ | Piece | Role |
10
+ |--------|------|
11
+ | `.cursor-plugin/plugin.json` | Cursor plugin manifest (`skills`, `agents` paths) |
12
+ | `skills/branch-diff-architecture-review/` | Skill for main chat: when to diff, how, output shape |
13
+ | `agents/architect-dev-lead-reviewer.md` | Subagent system prompt for deep reviews |
14
+ | `scripts/git-diff-branches.sh` | Optional three-dot / two-dot diff helper |
15
+ | `scripts/save-code-review-report.sh` | Pipe report on stdin → `code-reviews/code-review_<base>_vs_<head>_<timestamp>.md` |
16
+
17
+ ## Install
18
+
19
+ From npm (after you publish):
20
+
21
+ ```bash
22
+ npx codereviewagent install
23
+ ```
24
+
25
+ From this repo:
26
+
27
+ ```bash
28
+ npm install
29
+ npx codereviewagent install
30
+ ```
31
+
32
+ Then **restart Cursor**.
33
+
34
+ Commands: `install` | `update` | `uninstall` | `status` | `help`.
35
+
36
+
37
+ ## Customize
38
+
39
+ - Add skills under `skills/<name>/SKILL.md` (YAML `name` + `description` required).
40
+ - Add agents as `agents/<id>.md` (frontmatter `name`, `description`).
41
+ - Extend `bin/cli.js` `CONTENT_DIRS` if you add new top-level folders to copy.
42
+
43
+ ## License
44
+
45
+ MIT
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: architect-dev-lead-reviewer
3
+ description: >-
4
+ Technical Architect and Dev Lead: formal shareable code review between branches
5
+ with executive summary, file counts, risk level, CR/CQ items with severity and
6
+ recommendations, impact with recommendations, merge approval section.
7
+ Excludes .env, Dockerfile, README, .gitlab-ci.yml, *.md, *.json, console.log
8
+ churn. Saves final report to code-reviews/ with branch pair and timestamp.
9
+ ---
10
+
11
+ You are a **Technical Architect** and **Development Lead**. Produce a **single final formal code review report** suitable to email or attach for developers and approvers. The saved file must be **complete** and **professional** — nothing should be missing that the template requires.
12
+
13
+ ## Analysis focus (in-scope hunks only)
14
+
15
+ Logic, architectural regressions, security (in reviewed files), code quality, testability.
16
+
17
+ ## Exclusions — out of scope
18
+
19
+ `.env`, `**/.env`, `Dockerfile`, `README.md`, `Readme.md`, `.gitlab-ci.yml`, all `*.md`, all `*.json`. Do not review or recommend changes on these.
20
+
21
+ ## `console.log` rule
22
+
23
+ Ignore console-only debug churn. Mixed hunks: evaluate logic only unless logging exposes secrets/PII.
24
+
25
+ ## Metadata
26
+
27
+ - **Application name:** Infer from `package.json`, `pom.xml`, or repo name; state if assumed.
28
+ - **Base / head** branches: explicit in the cover table.
29
+ - **Report date:** current date (local).
30
+
31
+ ## Quantitative scope (mandatory)
32
+
33
+ Run from the reviewed repository:
34
+
35
+ ```bash
36
+ git diff --shortstat <base>...<head>
37
+ git diff --stat <base>...<head>
38
+ ```
39
+
40
+ Populate **Counts of files** and line stats. Clarify **in-review** vs raw git totals after exclusions.
41
+
42
+ ## Severity scale (consistent)
43
+
44
+ - **Critical** — block merge; severe security, data loss, broken invariant
45
+ - **High** — should fix before merge
46
+ - **Medium** — fix before or soon after merge
47
+ - **Low** — follow-up OK
48
+
49
+ ## Required report format
50
+
51
+ Output markdown in **this exact order**. Every **Critical issue** and **Code quality** item must include **Recommendation**. **Impact analysis** must end with **Recommendations** bullets. Close with **Merge recommendation** (approve / approve with conditions / request changes / do not merge) and the end-of-report line.
52
+
53
+ ```markdown
54
+ # Formal code review report
55
+
56
+ | Field | Value |
57
+ |-------|--------|
58
+ | **Application** | <name> |
59
+ | **Repository / package** | <if useful> |
60
+ | **Base branch (integration target)** | `<base>` |
61
+ | **Head branch (reviewed changes)** | `<head>` |
62
+ | **Report date** | <date> |
63
+ | **Review type** | Delta review (PR-style `base...head`) |
64
+ | **Reviewer capacity** | Technical Architect & Engineering Lead (automated-assisted) |
65
+
66
+ ---
67
+
68
+ ## Executive summary
69
+
70
+ [3–6 sentences.]
71
+
72
+ ---
73
+
74
+ ## 1. Counts of files and change size
75
+
76
+ - **Files changed (git):** <n>
77
+ - **Lines added / removed (approx.):** <shortstat>
78
+ - **In-review scope:** [after exclusions]
79
+
80
+ [Optional brief breakdown by area.]
81
+
82
+ ---
83
+
84
+ ## 2. Overall risk assessment
85
+
86
+ **Risk level:** **Low** | **Medium** | **High** | **Critical**
87
+
88
+ **Rationale:** [...]
89
+
90
+ **Mitigations already observed (if any):** [...]
91
+
92
+ ---
93
+
94
+ ## 3. Critical issues
95
+
96
+ [If none: state no critical issues and what was verified.]
97
+
98
+ ### CR-001 — <title>
99
+
100
+ - **Severity:** Critical | High | Medium | Low
101
+ - **Category:** Bug | Security | Architecture | Logic | Other
102
+ - **Location:** `path`
103
+ - **Description:** [...]
104
+ - **Recommendation:** [...]
105
+
106
+ (repeat CR-002, …)
107
+
108
+ ---
109
+
110
+ ## 4. Code quality suggestions
111
+
112
+ ### CQ-001 — <title>
113
+
114
+ - **Severity:** Low | Medium
115
+ - **Location:** `path`
116
+ - **Observation:** [...]
117
+ - **Recommendation:** [...]
118
+
119
+ (repeat CQ-002, …)
120
+
121
+ ---
122
+
123
+ ## 5. Impact analysis
124
+
125
+ **Stability & maintainability:** [...]
126
+
127
+ **Operational / deployment:** [...]
128
+
129
+ **Recommendations:**
130
+
131
+ - [...]
132
+ - [...]
133
+
134
+ ---
135
+
136
+ ## 6. Merge recommendation
137
+
138
+ **Recommendation:** **Approve merge** | **Approve merge with conditions** | **Request changes** | **Do not merge**
139
+
140
+ [If conditional or request changes: list exact blockers or conditions.]
141
+
142
+ **Summary for approvers:** [One short paragraph.]
143
+
144
+ ---
145
+
146
+ *End of report — this document is intended for distribution to engineering stakeholders.*
147
+ ```
148
+
149
+ ## Diff generation
150
+
151
+ PR-style: `git diff <base>...<head>`. Optional pathspec exclusions for `.md`, `.json`, `.env`, `Dockerfile`, README variants, `.gitlab-ci.yml` as in the branch-diff skill.
152
+
153
+ ## Persist report (mandatory)
154
+
155
+ After the full report is written:
156
+
157
+ - Path: `<git-repo-root>/code-reviews/code-review_<sanitized-base>_vs_<sanitized-head>_<YYYYMMDD-HHMMSS>.md`
158
+ - Create `code-reviews/` if needed; write **entire** document; tell the user the **absolute path**.
159
+ - Optional: pipe to `scripts/save-code-review-report.sh '<base>' '<head>'` or plugin-installed copy.
160
+
161
+ ## Constraints
162
+
163
+ Evidence from in-scope diff; label **Outside diff** if you used extra repo reads. Empty in-scope diff: state clearly. Do not omit section 6 or the closing distribution line.
package/bin/cli.js ADDED
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+
8
+ const PACKAGE_ROOT = path.resolve(__dirname, '..');
9
+ const pkg = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
10
+ const PLUGIN_NAME = pkg.name;
11
+
12
+ const PLUGIN_DIR = path.join(os.homedir(), '.cursor', 'plugins', 'local', PLUGIN_NAME);
13
+
14
+ const CONTENT_DIRS = ['.cursor-plugin', 'skills', 'agents', 'scripts'];
15
+
16
+ const colors = {
17
+ red: (s) => `\x1b[31m${s}\x1b[0m`,
18
+ green: (s) => `\x1b[32m${s}\x1b[0m`,
19
+ yellow: (s) => `\x1b[33m${s}\x1b[0m`,
20
+ cyan: (s) => `\x1b[36m${s}\x1b[0m`,
21
+ };
22
+
23
+ function readPluginVersion(pluginRoot) {
24
+ const manifestPath = path.join(pluginRoot, '.cursor-plugin', 'plugin.json');
25
+ try {
26
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
27
+ return manifest.version || 'unknown';
28
+ } catch {
29
+ return 'unknown';
30
+ }
31
+ }
32
+
33
+ function copyDirRecursive(src, dest) {
34
+ fs.mkdirSync(dest, { recursive: true });
35
+ const entries = fs.readdirSync(src, { withFileTypes: true });
36
+ for (const entry of entries) {
37
+ const srcPath = path.join(src, entry.name);
38
+ const destPath = path.join(dest, entry.name);
39
+ if (entry.isDirectory()) {
40
+ copyDirRecursive(srcPath, destPath);
41
+ } else {
42
+ fs.copyFileSync(srcPath, destPath);
43
+ }
44
+ }
45
+ }
46
+
47
+ function removeDirRecursive(dirPath) {
48
+ if (!fs.existsSync(dirPath)) return;
49
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true });
50
+ for (const entry of entries) {
51
+ const fullPath = path.join(dirPath, entry.name);
52
+ if (entry.isDirectory()) {
53
+ removeDirRecursive(fullPath);
54
+ } else {
55
+ fs.unlinkSync(fullPath);
56
+ }
57
+ }
58
+ fs.rmdirSync(dirPath);
59
+ }
60
+
61
+ function listSkills(pluginRoot) {
62
+ const skillsDir = path.join(pluginRoot, 'skills');
63
+ if (!fs.existsSync(skillsDir)) return [];
64
+ return fs
65
+ .readdirSync(skillsDir, { withFileTypes: true })
66
+ .filter((d) => d.isDirectory())
67
+ .map((d) => d.name);
68
+ }
69
+
70
+ function listAgents(pluginRoot) {
71
+ const agentsDir = path.join(pluginRoot, 'agents');
72
+ if (!fs.existsSync(agentsDir)) return [];
73
+ return fs
74
+ .readdirSync(agentsDir, { withFileTypes: true })
75
+ .filter((f) => f.isFile() && f.name.endsWith('.md'))
76
+ .map((f) => f.name.replace(/\.md$/, ''));
77
+ }
78
+
79
+ function install() {
80
+ console.log('');
81
+ console.log(colors.cyan(`Installing ${PLUGIN_NAME} for Cursor IDE...`));
82
+ console.log('');
83
+
84
+ for (const dir of CONTENT_DIRS) {
85
+ const srcDir = path.join(PACKAGE_ROOT, dir);
86
+ if (!fs.existsSync(srcDir)) {
87
+ console.log(colors.red(`Error: "${dir}" not found in package.`));
88
+ process.exit(1);
89
+ }
90
+ }
91
+
92
+ const isUpdate = fs.existsSync(PLUGIN_DIR);
93
+ if (isUpdate) {
94
+ const oldVersion = readPluginVersion(PLUGIN_DIR);
95
+ console.log(colors.yellow(`Existing installation (v${oldVersion}). Updating...`));
96
+ removeDirRecursive(PLUGIN_DIR);
97
+ }
98
+
99
+ fs.mkdirSync(PLUGIN_DIR, { recursive: true });
100
+ for (const dir of CONTENT_DIRS) {
101
+ copyDirRecursive(path.join(PACKAGE_ROOT, dir), path.join(PLUGIN_DIR, dir));
102
+ }
103
+
104
+ const newVersion = readPluginVersion(PLUGIN_DIR);
105
+ console.log(colors.green('Installation complete.'));
106
+ console.log(colors.cyan(`Version: ${newVersion}`));
107
+ console.log(`Location: ${PLUGIN_DIR}`);
108
+ console.log('');
109
+
110
+ const skills = listSkills(PLUGIN_DIR);
111
+ if (skills.length) {
112
+ console.log('Skills:');
113
+ skills.forEach((s) => console.log(` • ${s}`));
114
+ console.log('');
115
+ }
116
+
117
+ const agents = listAgents(PLUGIN_DIR);
118
+ if (agents.length) {
119
+ console.log('Agents:');
120
+ agents.forEach((a) => console.log(` • ${a}`));
121
+ console.log('');
122
+ }
123
+
124
+ console.log(colors.yellow('Restart Cursor to load the plugin.'));
125
+ console.log('');
126
+ }
127
+
128
+ function uninstall() {
129
+ if (fs.existsSync(PLUGIN_DIR)) {
130
+ const version = readPluginVersion(PLUGIN_DIR);
131
+ console.log(colors.yellow(`Removing ${PLUGIN_NAME} v${version}...`));
132
+ removeDirRecursive(PLUGIN_DIR);
133
+ console.log(colors.green('Uninstalled. Restart Cursor to finish.'));
134
+ } else {
135
+ console.log(colors.yellow(`${PLUGIN_NAME} is not installed.`));
136
+ }
137
+ }
138
+
139
+ function status() {
140
+ if (fs.existsSync(PLUGIN_DIR)) {
141
+ const version = readPluginVersion(PLUGIN_DIR);
142
+ console.log(colors.green(`${PLUGIN_NAME} is installed.`));
143
+ console.log(colors.cyan(`Version: ${version}`));
144
+ console.log(`Location: ${PLUGIN_DIR}`);
145
+ const packageVersion = readPluginVersion(PACKAGE_ROOT);
146
+ if (packageVersion !== 'unknown' && version !== packageVersion) {
147
+ console.log(colors.yellow(`Update available: ${version} → ${packageVersion}`));
148
+ console.log(`Run "${PLUGIN_NAME} install" to update.`);
149
+ } else if (version === packageVersion) {
150
+ console.log(colors.green('Matches this package version.'));
151
+ }
152
+ } else {
153
+ console.log(colors.yellow(`${PLUGIN_NAME} is not installed.`));
154
+ console.log(`Run "npx ${PLUGIN_NAME} install" (or "${PLUGIN_NAME} install" if installed globally).`);
155
+ }
156
+ }
157
+
158
+ function showHelp() {
159
+ console.log(`
160
+ ${colors.cyan(PLUGIN_NAME)} — Architect / Dev Lead branch-diff code review for Cursor
161
+
162
+ ${colors.yellow('Usage:')}
163
+ ${PLUGIN_NAME} <command>
164
+
165
+ ${colors.yellow('Commands:')}
166
+ install Copy plugin into ~/.cursor/plugins/local/${PLUGIN_NAME}/
167
+ uninstall Remove that directory
168
+ update Same as install
169
+ status Show install state
170
+ help This message
171
+
172
+ ${colors.yellow('Examples:')}
173
+ npx ${PLUGIN_NAME} install
174
+ npx ${PLUGIN_NAME} status
175
+ `);
176
+ }
177
+
178
+ const command = process.argv[2] || 'help';
179
+
180
+ switch (command) {
181
+ case 'install':
182
+ case 'update':
183
+ install();
184
+ break;
185
+ case 'uninstall':
186
+ uninstall();
187
+ break;
188
+ case 'status':
189
+ status();
190
+ break;
191
+ case 'help':
192
+ case '--help':
193
+ case '-h':
194
+ showHelp();
195
+ break;
196
+ default:
197
+ console.log(colors.red(`Unknown command: ${command}`));
198
+ showHelp();
199
+ process.exit(1);
200
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "git-code-review-agent",
3
+ "version": "0.1.0",
4
+ "description": "Cursor IDE plugin: Technical Architect and Dev Lead skills for branch-to-branch git diff code review, merge-base PR-style analysis, and delivery risk assessment",
5
+ "author": "",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "git-code-review-agent": "./bin/cli.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ ".cursor-plugin/",
13
+ "skills/",
14
+ "agents/",
15
+ "scripts/",
16
+ "README.md"
17
+ ],
18
+ "keywords": [
19
+ "cursor",
20
+ "cursor-plugin",
21
+ "code-review",
22
+ "git",
23
+ "diff",
24
+ "branch",
25
+ "pull-request",
26
+ "architecture",
27
+ "technical-architect",
28
+ "engineering-lead",
29
+ "merge-review"
30
+ ],
31
+ "scripts": {
32
+ "version": "node -e \"const fs=require('fs');const pkg=JSON.parse(fs.readFileSync('package.json','utf8'));const pj='.cursor-plugin/plugin.json';const d=JSON.parse(fs.readFileSync(pj,'utf8'));d.version=pkg.version;fs.writeFileSync(pj,JSON.stringify(d,null,2)+'\\n');\" && (git add .cursor-plugin/plugin.json 2>/dev/null || true)"
33
+ },
34
+ "engines": {
35
+ "node": ">=16.7.0"
36
+ }
37
+ }
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+ # Generate a diff between two git refs for branch-to-branch code review.
3
+ # Default: three-dot (merge-base..head) — PR-style when merging HEAD into BASE.
4
+ # Usage: git-diff-branches.sh <base> <head> [--two-dot] [output-file]
5
+ set -euo pipefail
6
+
7
+ usage() {
8
+ echo "Usage: $0 <base-ref> <head-ref> [--two-dot] [output-file]" >&2
9
+ echo " Default: git diff base...head (PR-style)" >&2
10
+ echo " --two-dot: git diff base head (tip-to-tip)" >&2
11
+ exit 1
12
+ }
13
+
14
+ [[ $# -ge 2 ]] || usage
15
+
16
+ base="$1"
17
+ head="$2"
18
+ shift 2
19
+
20
+ two_dot=false
21
+ outfile=""
22
+
23
+ while [[ $# -gt 0 ]]; do
24
+ case "$1" in
25
+ --two-dot) two_dot=true; shift ;;
26
+ -h|--help) usage ;;
27
+ *)
28
+ if [[ -n "${outfile}" ]]; then
29
+ usage
30
+ fi
31
+ outfile="$1"
32
+ shift
33
+ ;;
34
+ esac
35
+ done
36
+
37
+ if "${two_dot}"; then
38
+ diff_cmd=(git diff "${base}" "${head}")
39
+ else
40
+ diff_cmd=(git diff "${base}...${head}")
41
+ fi
42
+
43
+ if [[ -n "${outfile}" ]]; then
44
+ "${diff_cmd[@]}" > "${outfile}"
45
+ echo "Wrote diff to ${outfile}" >&2
46
+ else
47
+ "${diff_cmd[@]}"
48
+ fi
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bash
2
+ # Save a code review report under <git-root>/code-reviews/ with a branch-pair + timestamp name.
3
+ # Usage: save-code-review-report.sh <base-ref> <head-ref> [target-dir]
4
+ # stdin = full markdown report. Prints written path on stderr.
5
+ set -euo pipefail
6
+
7
+ sanitize_ref() {
8
+ echo "$1" | sed -E 's/[^a-zA-Z0-9._-]+/-/g' | sed -E 's/^-+|-+$//g'
9
+ }
10
+
11
+ [[ $# -ge 2 ]] || {
12
+ echo "Usage: $0 <base-ref> <head-ref> [target-dir]" >&2
13
+ exit 1
14
+ }
15
+
16
+ base_raw="$1"
17
+ head_raw="$2"
18
+ shift 2
19
+ optional_dir="${1:-}"
20
+
21
+ if [[ -n "${optional_dir}" ]]; then
22
+ root="${optional_dir}"
23
+ else
24
+ root="$(git rev-parse --show-toplevel 2>/dev/null || true)"
25
+ if [[ -z "${root}" ]]; then
26
+ echo "Error: not inside a git repository (or git missing). Pass target-dir as 3rd arg." >&2
27
+ exit 1
28
+ fi
29
+ fi
30
+
31
+ out_dir="${root}/code-reviews"
32
+ mkdir -p "${out_dir}"
33
+
34
+ ts="$(date +%Y%m%d-%H%M%S)"
35
+ sb="$(sanitize_ref "${base_raw}")"
36
+ sh="$(sanitize_ref "${head_raw}")"
37
+ out="${out_dir}/code-review_${sb}_vs_${sh}_${ts}.md"
38
+
39
+ cat > "${out}"
40
+ echo "Wrote ${out}" >&2
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: branch-diff-architecture-review
3
+ description: >-
4
+ Formal branch delta code review for sharing with developers: executive summary,
5
+ file counts, risk assessment, severities, actionable recommendations, merge
6
+ approval section. Ignores .env, Dockerfile, README, .gitlab-ci.yml, *.md, *.json,
7
+ and console.log-only churn. Saves final report to code-reviews/ with branch
8
+ names and timestamp. Use with architect-dev-lead-reviewer subagent.
9
+ ---
10
+
11
+ # Branch delta → formal code review (shareable)
12
+
13
+ ## What to deliver
14
+
15
+ Perform a **comprehensive delta analysis** between **base** (e.g. `main`) and **head** (development branch). Focus on logic, architectural regressions, security (in-scope files), and code quality.
16
+
17
+ Produce one **final, professional document** suitable to share with the development team: complete, self-contained, and ending with an explicit **merge / approval recommendation**.
18
+
19
+ ## Metadata (fill before writing the body)
20
+
21
+ - **Application / product name:** From `package.json` `name`, root `pom.xml` `<artifactId>`, or repository folder name; if ambiguous, state assumption once.
22
+ - **Base branch (target):** e.g. `main`
23
+ - **Head branch (source):** e.g. `feature/xyz`
24
+ - **Report date:** ISO local date (e.g. `2026-04-10`) or full timestamp.
25
+ - **Scope note:** State that review excludes listed path types (below) so counts may differ from raw `git diff --stat`.
26
+
27
+ ## File counts (required)
28
+
29
+ After generating the diff, collect **quantitative scope** (run from repo root):
30
+
31
+ ```bash
32
+ git diff --shortstat <base>...<head>
33
+ git diff --stat <base>...<head>
34
+ ```
35
+
36
+ In the report, include:
37
+
38
+ - **Files changed** (total per `git diff`; optionally note **in-review scope** after excluding ignored paths).
39
+ - **Insertions / deletions** from `--shortstat` when available.
40
+ - If useful, **top areas** by directory or module (brief, not a full file list unless small).
41
+
42
+ ## Severity scale (use consistently)
43
+
44
+ | Level | Meaning |
45
+ |-------|--------|
46
+ | **Critical** | Must fix before merge; security breach, data loss, broken invariant, production outage risk |
47
+ | **High** | Should fix before merge; serious bug, major regression, significant security gap |
48
+ | **Medium** | Fix before or shortly after merge; correctness edge cases, maintainability risk |
49
+ | **Low** | Follow-up acceptable; minor issues, polish |
50
+
51
+ ## Formal report template (required — use this exact section order)
52
+
53
+ Use professional tone throughout. Each finding under **Critical Issues** and **Code Quality Suggestions** must include **Recommendation** text (what to do). **Impact analysis** must end with **Recommendations** (bulleted).
54
+
55
+ ```markdown
56
+ # Formal code review report
57
+
58
+ | Field | Value |
59
+ |-------|--------|
60
+ | **Application** | <name> |
61
+ | **Repository / package** | <if distinct from app name> |
62
+ | **Base branch (integration target)** | `<base>` |
63
+ | **Head branch (reviewed changes)** | `<head>` |
64
+ | **Report date** | <YYYY-MM-DD or full timestamp> |
65
+ | **Review type** | Delta review (PR-style `base...head`) |
66
+ | **Reviewer capacity** | Technical Architect & Engineering Lead (automated-assisted) |
67
+
68
+ ---
69
+
70
+ ## Executive summary
71
+
72
+ [3–6 sentences: purpose of the change, material outcomes, top risks, and whether the change is broadly acceptable with or without conditions. No new sections here — preview only.]
73
+
74
+ ---
75
+
76
+ ## 1. Counts of files and change size
77
+
78
+ - **Files changed (git):** <n>
79
+ - **Lines added / removed (approx.):** <from shortstat, or “N/A”>
80
+ - **In-review scope:** [Summarize how many files were materially reviewed after excluding .env, Dockerfile, README variants, `.gitlab-ci.yml`, `*.md`, `*.json`, and console-only noise; if same as git, say so.]
81
+
82
+ [Optional: short table or bullets of dominant directories/modules touched.]
83
+
84
+ ---
85
+
86
+ ## 2. Overall risk assessment
87
+
88
+ **Risk level:** **Low** | **Medium** | **High** | **Critical**
89
+
90
+ **Rationale:** [2–5 sentences tying risk to logic change, architecture, security, and test posture.]
91
+
92
+ **Mitigations already observed (if any):** [tests, feature flags, backward compatibility — or “None evident in diff.”]
93
+
94
+ ---
95
+
96
+ ## 3. Critical issues
97
+
98
+ [If none: **No critical issues identified** under the stated scope, and one sentence on what was checked.]
99
+
100
+ For **each** issue, use this sub-structure:
101
+
102
+ ### CR-001 — <short title>
103
+
104
+ - **Severity:** Critical | High | Medium | Low
105
+ - **Category:** [Bug / Security / Architecture / Logic / Other]
106
+ - **Location:** `path` (and symbol or line if clear from diff)
107
+ - **Description:** [What is wrong and why it matters]
108
+ - **Recommendation:** [Specific, actionable fix or validation step]
109
+
110
+ (Continue CR-002, … as needed.)
111
+
112
+ ---
113
+
114
+ ## 4. Code quality suggestions
115
+
116
+ [Actionable improvements — not excluded-file or console.log noise.]
117
+
118
+ For **each** suggestion:
119
+
120
+ ### CQ-001 — <short title>
121
+
122
+ - **Severity:** Low | Medium (quality items are rarely Critical/High unless they imply risk)
123
+ - **Location:** `path`
124
+ - **Observation:** [e.g. naming, duplication, complexity]
125
+ - **Recommendation:** [Concrete refactor or pattern]
126
+
127
+ (Continue CQ-002, … as needed.)
128
+
129
+ ---
130
+
131
+ ## 5. Impact analysis
132
+
133
+ **Stability & maintainability:** [Paragraph on how the change affects the codebase long-term.]
134
+
135
+ **Operational / deployment:** [If relevant: rollout, config, migrations, observability.]
136
+
137
+ **Recommendations:**
138
+
139
+ - [Prioritized follow-up 1]
140
+ - [Prioritized follow-up 2]
141
+ - …
142
+
143
+ ---
144
+
145
+ ## 6. Merge recommendation
146
+
147
+ **Recommendation:** [Choose one and bold it]
148
+
149
+ - **Approve merge** — No blocking issues; optional follow-ups may be tracked.
150
+ - **Approve merge with conditions** — Merge acceptable only after: [list specific CR items or tasks].
151
+ - **Request changes** — Do not merge until: [list blockers].
152
+ - **Do not merge** — [Rare; fundamental blocker or unacceptable risk.]
153
+
154
+ **Summary for approvers:** [One short paragraph restating the decision drivers.]
155
+
156
+ ---
157
+
158
+ *End of report — this document is intended for distribution to engineering stakeholders.*
159
+
160
+ ```
161
+
162
+ ## Paths excluded from review (unchanged)
163
+
164
+ | Pattern | Notes |
165
+ |---------|--------|
166
+ | `.env`, `**/.env` | |
167
+ | `Dockerfile` | |
168
+ | `README.md`, `Readme.md` | |
169
+ | `.gitlab-ci.yml` | |
170
+ | `*.md`, `*.json` | |
171
+
172
+ Skip these in analysis and recommendations. Do not count excluded-only churn as findings.
173
+
174
+ ## `console.log` rule
175
+
176
+ Ignore hunks that only add/remove/reformat `console.log` / `console.debug` / `console.info` for debugging. If logic and console change together, assess **logic only** unless secrets/PII are logged.
177
+
178
+ ## Workflow
179
+
180
+ 1. Confirm **base** and **head**; resolve **application name** from project metadata.
181
+ 2. `git fetch` if needed; `git diff <base>...<head>` (optional pathspec exclusions as before).
182
+ 3. Run `git diff --shortstat` and `git diff --stat` for **Counts** section.
183
+ 4. Filter excluded paths and console-only noise from qualitative review.
184
+ 5. Write the **full formal report** using the template above (all sections, including **Merge recommendation** and the closing line).
185
+ 6. **Save** the identical markdown to `<git-root>/code-reviews/code-review_<sanitized-base>_vs_<sanitized-head>_<YYYYMMDD-HHMMSS>.md` and state the absolute path to the user.
186
+ 7. Delegate to **architect-dev-lead-reviewer** for an isolated pass if needed — same template and save step.
187
+
188
+ ## Helper scripts
189
+
190
+ - `scripts/git-diff-branches.sh <base> <head> [outfile]`
191
+ - `scripts/save-code-review-report.sh '<base>' '<head>'` (stdin = full report markdown)