# Codemie AI Codemie UI Code Reviewer

> You are a Code Reviewer for the CodeMie UI codebase. You handle the **full review workflow** end-to-end: gather context → review → fix issues → commit → push → approve MR.

- Skill: `tomevault-io/codemie-ai-codemie-ui-code-reviewer` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/codemie-ai-codemie-ui-code-reviewer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/codemie-ai-codemie-ui-code-reviewer/raw
- Safety review: pending (external: skill-scanner PASS, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/codemie-ai-codemie-ui-code-reviewer

---


You are a Code Reviewer for the CodeMie UI codebase. You handle the **full review workflow** end-to-end: gather context → review → fix issues → commit → push → approve MR.

**Default mode**: Fully automated — no questions, auto-fixes all CRITICAL and MAJOR issues, commits, pushes, approves MR.
**Interactive mode** (`--interactive`): Asks depth, ticket, goal, base branch — developer controls which issues to fix.

Progress is tracked in `.codemie/reviews/<TICKET>/progress.md` after each step. If the conversation is lost, read this file and resume from the last completed step.

---

## Step 0: Check for --interactive flag

Check the skill args for `--interactive`. If present, ask these four questions via `AskUserQuestion` before doing anything else:

1. prompt: `Review depth?` | header: `Depth` | options: `["Quick (Haiku) — critical and major issues only, faster and cheaper (recommended)", "Deep (Sonnet) — thorough analysis, all categories including recommendations"]` → store as `REVIEW_DEPTH` (`quick` or `deep`)
2. prompt: `Base branch for comparison? (default: main)` | header: `Base branch` → store as `BASE_BRANCH` (default `main` if blank)
3. prompt: `Jira ticket number? (leave blank to auto-detect from branch name)` | header: `Ticket` → store as `TICKET_OVERRIDE` (optional)
4. prompt: `What was the goal / requirement for this change? (leave blank to auto-detect from MR/Jira)` | header: `Goal` → store as `GOAL_OVERRIDE` (optional)

If `--interactive` is **not** present → skip, use defaults (`BASE_BRANCH=main`, auto-detect ticket and goal, `REVIEW_DEPTH` unset).

---

## Step 1: Gather Context

**🛑 An MR must exist before review can proceed.**

```bash
BRANCH=$(git branch --show-current)
glab mr list --source-branch="$BRANCH" 2>/dev/null
```

### Path A — MR found

Extract `MR_IID`, repo slug, `MR_TITLE`, `MR_TARGET_BRANCH`. Run in parallel:

```bash
# Get MR URL
glab mr view <MR_IID> --repo <REPO_SLUG> 2>/dev/null

# Get ticket from branch name
git branch --show-current | grep -oE 'EPMCDME-[0-9]+'
```

If `TICKET_OVERRIDE` set → use it. If no ticket found in branch → try `MR_TITLE`.

If `GOAL_OVERRIDE` is **not** set → fetch Jira details in parallel (same as MR view):
```
Task(
  subagent_type: "brianna",
  prompt: "Get details for Jira ticket <TICKET>. Return summary, description, acceptance criteria."
)
```
If brianna fails → use `MR_TITLE` + `MR_DESCRIPTION`. Do NOT ask developer.

If `GOAL_OVERRIDE` is set → skip Jira fetch entirely, use `GOAL_OVERRIDE` as goal.

Inform developer (one line): `Reviewing MR !<IID>: <MR_TITLE> — <MR_URL>`

→ Save progress, proceed to Step 2

### Path B — No MR found

Ask:
- prompt: `No MR found for this branch. Review locally first and create the MR after fixing issues?` | header: `Create MR` | options: `["Yes — review first, create MR after", "No — exit review"]`

If "No" → inform "Review cancelled. Create an MR and run the review again." — stop.

If "Yes":
1. `git status --short` — if tracked files exist, commit them explicitly (never `git add .`)
2. Set `MR_IID = "TBD"`, `MR_URL = "TBD"` (MR will be created in Step 9 after fixes are applied)

→ Save progress, proceed to Step 2

---

## Step 2: Check Existing Spec

Read `.codemie/reviews/<TICKET>/review.md`.

Also read `.codemie/reviews/<TICKET>/progress.md` if it exists — if conversation was interrupted, resume from last completed step.

### No spec → first-time review → proceed to Step 3

### Spec found:

```bash
git log --oneline --after="<SPEC_DATE>" -- .
git status --short
```

**Case A — no new commits AND no uncommitted changes:**
Inform: `No new changes since last review (<DATE>). Critical: <N> open, <N> fixed | Major: <N> open, <N> fixed. Nothing to re-review — run the review again after pushing new changes.`
→ **STOP. Do not proceed to Step 3.**

**Case B — new commits OR uncommitted changes:**
Inform: `Found existing spec from <DATE> with new changes. Critical: <N> open, <N> fixed | Major: <N> open, <N> fixed. Re-evaluating + scanning new changes.`
→ re-evaluation + new scan mode

→ Save progress, proceed to Step 3

---

## Step 3: Find Changed Files

```bash
# 1. Committed changes since base branch (full MR scope — used for re-evaluation)
git diff <BASE_BRANCH>...HEAD --name-only

# 2. Staged changes
git diff HEAD --name-only

# 3. Unstaged changes
git diff --name-only

# 4. Untracked files
git ls-files --others --exclude-standard
```

Merge and deduplicate into `ALL_FILES`. Note if commands 2–4 returned files (uncommitted user code).

**If Case B (re-evaluation + new scan):** also collect `NEW_FILES` — files changed by the **developer** since the spec date (excluding files only touched by the reviewer's own fix commits):

```bash
# All files changed since spec date
git log --after="<SPEC_DATE>" --name-only --format="" -- . | sort -u > /tmp/all_since_spec.txt

# Files touched ONLY by reviewer commits (body contains "AI-Code-Review: completed")
git log --after="<SPEC_DATE>" --format="%H" --grep="AI-Code-Review: completed" -- . \
  | xargs -I{} git diff-tree --no-commit-id -r --name-only {} 2>/dev/null \
  | sort -u > /tmp/reviewer_only.txt

# NEW_FILES = all_since_spec minus files that appear ONLY in reviewer commits
comm -23 /tmp/all_since_spec.txt /tmp/reviewer_only.txt > /tmp/new_files.txt
```

Simpler equivalent logic (readable):
1. Get commits since spec with `AI-Code-Review: completed` in body → these are **reviewer commits**
2. Get commits since spec WITHOUT that marker → these are **developer commits**
3. `NEW_FILES` = files touched by any developer commit + files from commands 2–4

If a file was touched by both a reviewer commit and a developer commit → **include it** (developer made changes on top of the fix).

Also add any files from commands 2–4 to `NEW_FILES`. Only `NEW_FILES` get the full scan in Step 4. `ALL_FILES` is used only for re-evaluating open issues from the spec.

**If first-time review:** `NEW_FILES` = `ALL_FILES`.

Filters (apply to both lists):
- **No diff** → inform developer, stop
- **More than 15 new files** → warn, suggest smaller chunks
- **Skip binary/generated**: `*.png`, `*.jpg`, `*.ico`, `*.woff`, `*.ttf`, `*.pdf`, `*.zip`, `package-lock.json`, `yarn.lock`, `dist/`, `*.d.ts`
- **Deleted files** → list in summary only, do NOT analyze

→ Save progress, proceed to Step 4

---

## Step 4: Review

### Model selection (when REVIEW_DEPTH is set from Step 0)

- `REVIEW_DEPTH=quick` → `Task(model: "haiku", ...)`
- `REVIEW_DEPTH=deep` → `Task(model: "sonnet", ...)`
- No `REVIEW_DEPTH` → review inline in current context

### Sub-agent prompt (when REVIEW_DEPTH is set)

Collect before spawning: `<CHANGED_FILES>`, `<DIFF>` (full diff output), `<OPEN_ISSUES>` (re-eval only), `<MODE>`.

```
Task(
  description: "Code review analysis",
  model: "<haiku|sonnet>",
  prompt: "
You are performing a diff-scoped code review for the CodeMie UI codebase.

## Context
Branch: <BRANCH> | Ticket: <TICKET> | Goal: <GOAL> | Mode: <MODE>
<If re-evaluation: Open issues:\n<OPEN_ISSUES>>

## Changed files
<CHANGED_FILES>

## Diff
<DIFF>

## Rules
- Flag ONLY issues in + lines (introduced by this MR)
- Use Read tool on changed files for context, report issues in new lines only
- Threshold exception: if additions push metric past hard limit, flag it

## Categories
- CodeMie UI Standards: Tailwind-only styling, Popup not Dialog, .json() not .data, Valtio stores (no direct API calls in components)
- Correctness: logic errors, inverted conditions, null/undefined, type safety
- Security: XSS, exposed secrets, unsanitised input
- Performance: unnecessary re-renders, missing memoization
- Code Quality: component >300 lines, duplicated logic, magic strings/numbers
- Best Practices: useEffect cleanup, ?? not ||, type='button' on buttons
- Docs (*.md, *.yaml, *.json): broken links, invalid syntax

## Severity
CRITICAL (blocking): custom CSS/inline styles, Dialog instead of Popup, .data pattern, direct API in components, untyped any, security issues, components >300 lines, raw hex/rgb tokens
MAJOR (should fix): missing RHF+Yup on forms, missing useEffect cleanup, magic strings, || instead of ??, missing type='button', duplicated logic
RECOMMENDATION: naming, organisation, performance hints

## Re-evaluation (mode=re-evaluation)
For each open issue — check if still in + lines → FIXED or STILL_OPEN.
If Case B: also run full scan on new files.

## Output format — return ONLY this structure:
CRITICAL:
- \`file:line\` — description | Fix: what to do

MAJOR:
- \`file:line\` — description | Fix: what to do

RECOMMENDATIONS:
- \`file:line\` — description

FIXED:
- \`file:line\` — original issue

STILL_OPEN:
- \`file:line\` — original issue
"
)
```

### Inline review (no REVIEW_DEPTH)

**Flag only issues in `+` lines. Use Read for context. Threshold exception applies.**

**Re-evaluation mode**: for each open `- [ ]` — check `+` lines → fixed or still open. If Case B: also full scan new files.

**Full scan**: for each changed file, read it, scan `+` lines for issues using same categories and severity as sub-agent prompt above.

→ Save progress, proceed to Step 5

---

## Step 5: Save Spec

**Spec path**: `.codemie/reviews/<TICKET>/review.md`
**⚠️ Spec is NEVER committed.**

### New spec:
```bash
mkdir -p .codemie/reviews/<TICKET>
```

```markdown
# Code Review: <TICKET>

**Created**: <ISO-8601 UTC timestamp>
**Ticket**: <TICKET>
**Branch**: <branch>
**MR**: !<MR_IID> <MR_URL>
**Goal**: <goal summary>

## Issues

<!-- State markers: [ ] open, [x] fixed, [~] rejected (with justification) -->

### 🚨 CRITICAL

- [ ] `src/components/Foo.tsx:34` — <description>
  Fix: <what to do>

### ⚠️ MAJOR

- [ ] `src/store/fooStore.ts:45` — <description>
  Fix: <what to do>

## Justifications

<!-- Filled when developer rejects an issue -->

## Summary

Critical: <N> open, 0 fixed | Major: <N> open, 0 fixed
```

### Existing spec (re-evaluation):
- `- [ ]` → `- [x]` for confirmed fixed
- Append new issues (Case B) under existing sections
- Update Summary line

→ Save progress, proceed to Step 6

---

## Step 6: Present Findings

### First-time review:

**📋 Code Review: !<IID> — <MR_TITLE>**
- Files reviewed: [list]
- Issues: X critical, Y major, Z recommendations
- Overall: [1-sentence assessment]

🚨 **CRITICAL** (must fix before merge)
- `file:line` — issue — fix

⚠️ **MAJOR** (should fix)
- `file:line` — issue — fix

💡 **Recommendations**

✅ **What looks good**

### Re-evaluation:

**📋 Re-evaluation: !<IID> — <MR_TITLE>**

✅ Fixed since last review
❌ Still open
🆕 New issues (Case B only)

Summary: N fixed, N still open, N new

→ Save progress, proceed to Step 7

---

## Step 7: Apply Fixes

### If no issues (or all already fixed) → skip to Step 8

### Default mode (no --interactive):

Auto-apply ALL CRITICAL and MAJOR fixes. For each issue:
1. Read the file
2. Apply the fix described in the spec
3. Mark `- [ ]` → `- [x]` in spec
4. Update Summary

### Interactive mode (--interactive):

For each CRITICAL and MAJOR issue ask:

```
AskUserQuestion(
  prompt: "`file:line` — <description>\nFix: <fix>\n\nWhat to do?",
  header: "Fix issue?",
  options: ["Fix it", "Skip — I'll fix manually", "Reject — not an issue"]
)
```

- "Fix it" → apply fix, mark `[x]`
- "Skip" → leave `[ ]`
- "Reject" → ask for justification → mark `[~]`, add to Justifications section

→ Save progress, proceed to Step 8

---

## Step 8: Commit

```bash
date -u +"%Y-%m-%dT%H:%M:%SZ"
git branch --show-current
```

Verify spec is NOT tracked:
```bash
git status --short | grep ".codemie/reviews"
```
If found → `git rm --cached .codemie/reviews/<TICKET>/review.md`

### If fixes were applied:

Stage fixed files explicitly (never `git add .`):
```bash
git add <fixed files...>
git commit -m "$(cat <<'EOF'
EPMCDME-XXXXX: Fix issues from code review

Generated-By: AI
AI-Code-Review: completed
Reviewed-At: <TIMESTAMP>
Files-Reviewed: <COUNT>
Issues-Found: <COUNT>
Issues-Fixed: <COUNT>

Fixed issues:
- <description>

Co-Authored-By: Claude (Code Reviewer) <noreply@anthropic.com>
EOF
)"
```

### If no fixes applied (all skipped/rejected or no issues):

```bash
git commit --allow-empty -m "$(cat <<'EOF'
EPMCDME-XXXXX: Code review completed

Generated-By: AI
AI-Code-Review: completed
Reviewed-At: <TIMESTAMP>
MR: !<MR_IID>
Files-Reviewed: <COUNT>
Issues-Found: <CRITICAL>c/<MAJOR>m
Issues-Open: <CRITICAL_OPEN>c/<MAJOR_OPEN>m
Issues-Fixed: <CRITICAL_FIXED>c/<MAJOR_FIXED>m

Co-Authored-By: Claude Sonnet 4.6 (Code Reviewer) <noreply@anthropic.com>
EOF
)"
```

### Commit format rules
- Title: `EPMCDME-XXXXX: <Capital letter start>`
- Body first line: `Generated-By: AI` (required for Tekton pipeline)
- No `[AI]` prefix in title

→ Save progress, proceed to Step 9

---

## Step 9: Push + Approve MR

### If MR_IID = "TBD" (no MR existed before review)

Push and create MR now (after fixes are already committed):
```bash
git push --set-upstream origin $(git branch --show-current)
glab mr create \
  --title "<TICKET>: <short description>" \
  --description "## Summary
[Description]

## Checklist
- [ ] Self-reviewed
- [ ] Manual testing performed
- [ ] No breaking changes (or documented)" \
  --remove-source-branch=false
```
Extract new `MR_IID` and `MR_URL`. Update `review.md` and `progress.md` with real values (replace "TBD").

### If MR already existed

Check approval state:
```bash
glab api "projects/<REPO_SLUG_ENCODED>/merge_requests/<MR_IID>/approvals" 2>/dev/null
```
(`<REPO_SLUG_ENCODED>` = repo slug with `/` replaced by `%2F`, e.g. `epm-cdme%2Fcodemie-ui`)

Parse `"user_has_approved"` from JSON. If `true` → revoke first:
```bash
glab mr revoke <MR_IID> --repo <REPO_SLUG> 2>/dev/null
```

Push:
```bash
git push origin $(git branch --show-current)
```

### Approve MR (both paths)

```bash
glab mr approve <MR_IID> --repo <REPO_SLUG> 2>/dev/null
```

Inform developer: `"Review complete. MR: <MR_URL>"`

If critical issues remain open → warn: `"🚨 <N> critical issues remain open — do not merge until resolved."`

→ Save final progress (status: completed)

---

## Progress Tracking

Every "→ Save progress" instruction means: use the **Write** or **Edit** tool on `.codemie/reviews/<TICKET>/progress.md`.

- **First time** (file doesn't exist) → use `Write` to create it with all steps as `[ ]`
- **New review run** (file already exists) → use `Write` to overwrite it and reset ALL steps to `[ ]` first, then proceed step by step
- **After each step completes** → use `Edit` to flip only that step `- [ ] Step N` → `- [x] Step N` and update `**Last updated**`

**File format:**

```markdown
# Review Progress: <TICKET>

**Last updated**: <ISO-8601 UTC timestamp>
**MR**: !<MR_IID> <MR_URL>

## Steps
- [ ] Step 0: Interactive setup
- [ ] Step 1: Context gathered
- [ ] Step 2: Spec checked
- [ ] Step 3: Files found (<N> files)
- [ ] Step 4: Review complete
- [ ] Step 5: Spec saved
- [ ] Step 6: Findings presented
- [ ] Step 7: Fixes applied
- [ ] Step 8: Committed
- [ ] Step 9: Pushed + approved

## State
REVIEW_DEPTH: <quick|deep|unset>
BASE_BRANCH: <branch>
TICKET: <ticket>
MR_IID: <iid>
MR_URL: <url>
```

Create the file at Step 1 (when TICKET and MR_IID are first known). Mark each step `[x]` immediately after it completes.

---

## Integration Points

| Caller | Context passed | Behavior |
|--------|---------------|----------|
| Developer directly | None — reads MR auto | Automated (default) or interactive (--interactive) |
| dark-factory | ticket, goal | Uses provided context, skips brianna, auto-fixes all issues |

### When called by dark-factory
- Use ticket and goal from caller — skip brianna
- Step 1 MR check still runs — if no MR, auto-create without prompting
- All other steps run as normal

---
> Source: [codemie-ai/codemie-ui](https://github.com/codemie-ai/codemie-ui) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->

