--- name: branch-review-read-code description: "Read the current branch diff, surrounding code, and pyproject.toml before review. Use when: reviewing a branch, understanding current diff, preparing code review context, reading changed files with config awareness, чтение diff ветки, собрать контекст ревью, прочитать pyproject перед ревью." argument-hint: "Base branch or review scope (e.g. origin/main, main, src/)" --- # Branch Review: Read Code This skill gathers the exact context needed for a branch review before any recommendations are made. ## Goals - identify the review base - collect changed files and diff hunks - read surrounding code, not only modified lines - read `pyproject.toml` first when it exists - extract effective versions, modes, and tool settings that constrain the review ## Procedure ### Step 1 — Resolve Review Base Determine the base branch in this order: 1. user-provided base branch 2. `origin/main` 3. `origin/master` 4. `main` 5. `master` Use git to find the merge-base and review `merge-base...HEAD`. If none of these refs exist, review the staged and unstaged diff in the current branch and say that the base branch could not be resolved. ### Step 2 — Read pyproject.toml First Before reviewing Python code, read `pyproject.toml` from the repository root when present. Extract at minimum: - `[project]` → `requires-python` - `[tool.ruff]` and `[tool.ruff.lint]` - `[tool.mypy]` - `[tool.pytest.ini_options]` - formatter and import settings if present: `black`, `isort`, `ruff format` - any custom sections that affect code generation, linting, typing, tests, or packaging Record the effective constraints, especially: - target Python version - strictness modes - enabled and ignored lint rules - test paths and addopts - line length and formatting rules If `pyproject.toml` is missing, state that explicitly and continue with conservative assumptions. ### Step 3 — Collect the Branch Delta Gather: - changed file list - diff hunks for each changed text file - file status: added, modified, renamed, deleted Ignore generated or low-signal files unless they are central to the change: - lockfiles - build artifacts - minified bundles - vendored code - binary assets ### Step 4 — Read Surrounding Context For each changed source file, read enough surrounding code to understand: - function and class boundaries - data flow into and out of the changed lines - nearby tests and fixtures - text strings or comments changed by the branch If there are many files, prioritize by risk: 1. production source code 2. tests for changed source 3. config files 4. docs and text content ### Step 5 — Produce the Review Packet Output a concise packet for the next stage: ```md ## Review Packet Base branch: Changed files: - path (status) ### pyproject.toml - found: yes/no - requires-python: ... - ruff: ... - mypy: ... - pytest: ... ### Priority Areas - file: why it is risky ### Notes - anything unusual in the diff or repo state ``` Do not propose fixes yet. This skill only gathers context.