---
name: code-review
description: Review a GitHub pull request against the project's engineering doctrine and post the review as a PR comment. Use when the user says "review this PR", "code review", "review pull request", or provides a GitHub PR URL for review.
title: code-review
canonical_url: https://skilld.dev/gh/bity-labs/tstack/code-review
last_updated: 2026-09-21T10:30:47.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install bity-labs/tstack/code-review`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/code-review`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/bity-labs/tstack/code-review) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/code-review`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/code-review --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/code-review --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Code Review

Review a GitHub pull request for correctness, maintainability, tests, domain fit, and operational risk. Always publish the review as a PR comment.

## Read These First

1. `docs/engineering/code-review.md` — review principles and checklist
2. `docs/coding-standards.md` — repo conventions
3. `docs/context.md` — domain language and project model
4. Relevant `docs/adr/` files for the area being touched
5. Other scoped engineering docs when risk requires it, such as security, data modeling, debugging, boundaries, legacy code, or testing

## Workflow

### 1. Identify the PR

If no PR URL is provided, ask the user for one.

Parse the URL into:

- repository owner/name
- PR number
- base branch
- head branch

Use GitHub CLI when available:

```bash
gh pr view <PR_URL> --json title,body,author,baseRefName,headRefName,files,commits,reviews
```

### 2. Load Doctrine Before the Diff

Read the review doctrine before judging the change.

Use the TStack lowercase docs paths:

- `docs/engineering/code-review.md`
- `docs/coding-standards.md`
- `docs/context.md`
- `docs/adr/`

Do not review from generic taste. Review against the project's stated rules, vocabulary, and decisions.

### 3. Understand Intent

Before reading deeply, understand what the PR claims to do:

- PR title and body
- linked issue, PRD, or task if present
- stated acceptance criteria if present
- changed files and rough scope

Check whether the PR includes unrelated work. Unrelated scope is review risk.

### 4. Inspect the Change

Review the diff and surrounding code as needed.

Focus on:

- observable behavior and edge cases
- failure paths and data integrity
- test quality and missing coverage
- interface shape and module boundaries
- domain language consistency
- architectural decisions and ADR alignment
- operational, security, or migration risk
- unnecessary complexity or speculative abstraction

For large PRs, prioritize the highest-risk files first and mention any area you could not inspect confidently.

### 5. Write Findings

Each finding should be concrete and actionable.

For every issue, include:

- severity emoji: `🚫` blocker, `⚠️` important, or `💡` suggestion
- where it appears
- why it matters
- what should change

Do not block on personal preference. Distinguish required fixes from optional improvements.

### 6. Format the Review

Use this format:

```md
## Summary
<short assessment of what the PR does and whether it is close to mergeable>

## Blockers
- 🚫 <issue, impact, and required fix>

## Important Improvements
- ⚠️ <issue, impact, and recommended fix>

## Suggestions
- 💡 <non-blocking improvement>

## Tests / Coverage
<what is covered, what is missing, and whether coverage is acceptable>

## What Works Well
<call out strong choices briefly>
```

If a section has no items, write `None`.

### 7. Choose PR Status

GitHub labels are shared between issues and PRs, but these labels represent PR review state only. Keep only one active on the PR:

- `changes-requested` — use when the review has any blocker or required important improvement before merge
- `ready-to-merge` — use only when the review accepts the PR as merge-ready

Remove `needs-review` after reviewing either way.

Ensure labels exist before applying them:

```bash
gh label create needs-review --repo <owner/repo> --description "PR status: ready and waiting for review" --color 5319E7 2>/dev/null || true
gh label create changes-requested --repo <owner/repo> --description "PR status: reviewed and requires changes before merge" --color D73A4A 2>/dev/null || true
gh label create ready-to-merge --repo <owner/repo> --description "PR status: reviewed and ready to merge" --color 0E8A16 2>/dev/null || true
```

### 8. Publish the Review

Always post the review as a PR comment. Do not only print it locally.

```bash
gh pr comment <PR_URL> --body-file <review-file>
```

Then update the PR status label.

If changes are requested:

```bash
gh pr edit <PR_URL> --remove-label needs-review --remove-label ready-to-merge --add-label changes-requested
```

If ready to merge:

```bash
gh pr edit <PR_URL> --remove-label needs-review --remove-label changes-requested --add-label ready-to-merge
```

### 9. Report Back

Tell the user:

- review was posted
- status label applied
- short summary of the highest-risk finding, if any

## Guardrails

- Always read doctrine before reviewing the diff.
- Always publish the review as a PR comment.
- Do not invent project rules that are not in the docs.
- Do not block on style preference unless it violates documented conventions or creates real risk.
- If doctrine is missing, say what is missing and proceed with clearly labeled generic review criteria.
- For large PRs, state any areas not reviewed deeply.
