Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Copilot Api Code Review?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/caozhiyuan-copilot-api-code-review)
---
name: copilot-api-code-review
description: Review pull requests, commits, or working-tree changes in the copilot-api repository using its project checklist and structured review summary.
---
# copilot-api Code Review Guidelines
This skill is the project-specific code review standard for the copilot-api repository (a Bun/TypeScript API gateway providing OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages compatibility over GitHub Copilot and third-party providers).
MUST NOT review using only `git diff`. Always combine the diff with surrounding code, related tests, configs, and project context.
## Goal
Ship changes that are correct, safe, maintainable, and releasable with minimal overhead.
## Scope and Baseline
Record the reviewed change set, baseline, and selection rationale in `Context Checked`. Use the user's comparison when provided. Otherwise, choose the baseline that matches the review scope.
- For an open PR, compare its head with the merge base of the actual target branch and PR head. Check the target branch's current behavior when it affects a finding.
- For a merged PR, compare the target before and after the integration. Use `git diff <merge>^1 <merge>` for a merge commit. For squash or rebase merges, compare the actual landed commit or range with its preceding target commit.
- For a single commit, compare against its parent. Use the first parent for a merge commit and the empty tree for an initial commit. For a committed branch without a merge target, use a verified development starting point.
- For an uncommitted review, use `HEAD` and inspect staged, unstaged, and relevant untracked files in scope. Use the empty tree for a working tree with no commits.
If the baseline cannot be confirmed, record the limitation. A verified failure of an explicit acceptance criterion can still be a finding when it is attributable to the requested change. Verify the prior behavior for any regression claim.
## Anti-Hallucination Standard
Treat review findings as evidence-backed claims, not guesses.
- A finding must be based on inspected repository evidence: changed code, nearby implementation, callers/callees, tests, configs, schema, docs, or explicitly checked dependency behavior.
- Do not claim a file, symbol, test, config, command result, or dependency behavior was checked unless it was actually inspected or run.
- Record missing context, unchecked behavior, and open questions as limitations in `Context Checked`, `Test Notes`, or `Release Risk`.
- Verified findings must include all four parts: evidence, impact path, affected scenario, and concrete fix.
- A review can return zero findings.
## Required Context
Before judging a change, gather the minimum relevant context:
- For working-tree reviews, check `git status --short --untracked-files=all`, `git --no-pager diff`, `git --no-pager diff --cached`, and the contents of relevant untracked files. For committed changes, inspect the selected range and related commits as needed.
- Local code context: changed files plus nearby callers, callees, tests, config, schema, and related modules.
- Project docs: `AGENTS.md`, `README.md`, `docs/`, and `package.json` scripts.
- Protocol contract types under `src/lib/types/` (OpenAI Chat Completions, OpenAI Responses, Anthropic Messages) whenever a change touches request/response translation; verify every claimed field against these types instead of assuming it exists.
If a context file does not exist, continue. Missing optional docs should not block the review.
Minimum context protocol:
- Read the relevant full function, class, or module around every changed hunk before judging it.
- Search for changed public symbols, exported APIs, commands, config keys, schemas, and routes to find callers and dependents.
- Read related tests in the affected package before claiming behavior is untested. Record any limits on test inspection in `Test Notes`.
- Read related configuration, schema, migration, or API docs before claiming compatibility or release risk.
- If a command fails or a file cannot be read, record the limitation and avoid conclusions that depend on that missing context.
## Evidence Standard
Every counted finding must be attributable to the requested change and supported by a scenario established from inspected evidence.
- Compare behavior under equivalent conditions. Show how the change introduces a defect, widens its impact, breaks a contract, or fails an explicit acceptance criterion. An unchanged helper can anchor a finding when a changed caller, input, or configuration creates the impact.
- Trace the scenario from a supported entry point through the relevant inputs, configuration, and state. For retries, out-of-order events, concurrency, and partial failures, establish the prerequisites and timing from inspected code, contracts, configuration, or tests. If a test calls a handler directly or forces a failure, verify how upstream callers can produce those conditions.
- Use `location` for the exact file and line at the clearest anchor. Use `occurrences` for the number of code locations where the behavior was verified. Use `1` for a single location.
- Use `reason` to connect the evidence, verified trigger, and user or operational impact. Include the baseline behavior for a regression.
- Use `fix` for a concrete action that addresses the verified issue.
- Do not assert runtime behavior of third-party libraries, frameworks, CLIs, upstream provider APIs (GitHub Copilot, OpenAI, Anthropic, etc.), or services unless it was verified from installed code, official docs, tests, or existing project usage.
## Severity Levels
- **CRITICAL (must fix)** applies to verified release-blocking impact such as outages, credential leakage, data loss, or broken core flows such as auth, provider resolution, translation, or streaming.
- **HIGH_PRIORITY (should fix before merge)** applies to verified defects with material user or operational impact, contract breaks, or a confirmed gap in verification required for acceptance.
- **SUGGESTION (non-blocking)** applies to verified, low-impact findings within the requested change.
## Suggestions
Use the optional `Suggestions` section after `CODE_REVIEW_SUMMARY` for actionable follow-ups such as improvements to unchanged behavior, hardening ideas, or credible risks whose triggers still need verification. Describe the observed behavior, the conditions where it matters, a concrete next step, and any premise still to verify.
## Project Checklist
Use the checks relevant to the change and assign severity based on verified impact.
1. **Correctness**
- Meets requirements; no obvious logic gaps.
- Edge cases and failure paths handled (null/empty, retries, timeouts, partial failures).
2. **Protocol & Translation Fidelity**
- Translation between OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages matches the contract types under `src/lib/types/`; no invented or mistyped fields.
- Request/response/entity/DTO fields are modeled from the actual source types; no `any`, no guessed optional fields.
- Both directions of a translation change are checked (request in, response out), including non-stream vs stream parity.
3. **Streaming & Realtime**
- SSE and websocket paths (`src/services/responses-websocket*.ts`, `fetch-event-stream` usage) keep correct event ordering, emit completion/termination events, propagate mid-stream errors, and handle client abort/cancellation without leaked or unterminated streams.
- Rate-limit and token-usage accounting (`src/lib/providers/copilot-rate-limit.ts`, `src/lib/providers/codex-rate-limit.ts`, `src/lib/token-usage/`) stays correct when a stream aborts partway.
4. **Auth, Credentials & Tokens**
- Check authentication, authorization, token refresh and expiry, redaction, and atomic persistence in `src/auth.ts`, `src/lib/auth/`, and `src/services/github/` as applicable.
- No tokens, secrets, or PII in logs, error messages, telemetry, client code, or committed config.
5. **Proxy, TLS & Networking**
- Check `src/lib/http/proxy.ts`, `src/lib/http/tls.ts`, and `src/lib/http/electron-fetch.ts` for compatibility with corporate proxies and `NODE_USE_SYSTEM_CA`.
- Check that request timeouts and cancellation use the established dispatcher (`src/lib/http/timeout-dispatcher.ts`) where applicable.
6. **Config & State Compatibility**
- Check backward compatibility, safe migrations, and defaults for existing installs in `src/lib/config/`, `src/lib/storage/sqlite.ts`, and `src/lib/storage/atomic-file.ts`.
- Public route and API contract changes under `src/routes/` are backward compatible or carry an explicit migration note.
7. **Reliability**
- No obvious races, resource leaks, unbounded loops, or brittle dependencies.
- Proper error handling; meaningful errors for callers that match existing route error patterns.
8. **Maintainability & Project Conventions**
- ES modules and strict TypeScript; `~/*` imports for files under `src/`; camelCase variables/functions, PascalCase types/classes, descriptive filenames.
- Check formatting with the affected package's ESLint configuration. The gateway embeds Prettier settings, including `semi: false`.
- Clear naming; single-responsibility functions; complex logic explained or decomposed; respects the existing `src/lib` vs `src/services` vs `src/routes` boundaries.
9. **Tests**
- Check Bun `*.test.ts` coverage in `tests/`, `desktop/tests/`, or `plugin/` as applicable.
- Verify at least 80% unit test coverage on changed code and include relevant request translation, provider, auth, config, and streaming edge cases.
- Tests are deterministic; no flaky timing or network assumptions.
10. **Cross-Surface Impact**
- The Electron desktop app under `desktop/` is isolated with its own package files; shared changes must not break `bun run build:desktop` or the desktop typecheck.
- `plugin/` scripts are excluded from the root ESLint config and `pages/` holds static assets; do not apply root src assumptions to them.
11. **Observability**
- Useful logs for critical behavior via the existing logger (`src/lib/logger.ts`); logs are actionable, not noisy, and contain no sensitive data.
## Additional Checks
- **Performance**: avoid obvious repeated I/O, unnecessary re-parsing/tokenization, or unbounded buffering of streams; consider caching or batching.
- **Consistency**: matches existing patterns in neighboring modules.
- **Dependencies**: avoid adding heavy or unvetted dependencies to `package.json`; check version, security, and license implications.
- **Documentation**: update `README.md`, `README.zh-CN.md`, `docs/`, or comments when behavior or usage changes.
## Verification Commands
For documentation-only changes, inspect the diff and verify referenced paths and commands. For code changes, use the checks in `AGENTS.md` for the affected packages. Redirect test output to a temporary log and record commands, results, coverage, and any verification limits in `Test Notes`.
- Run the affected packages' lint and typecheck commands. Use `bun run lint:all` and `bun run typecheck:all` for gateway and desktop checks together.
- Use `bun test --isolate <test-files>` for targeted runs or `bun run test:changed` for uncommitted changes. Select explicit test files when change detection finds no tests, or when tests read changed files at runtime or launch them as subprocesses. Use `bun run test:full` for the full gateway, desktop, and plugin suite.
- Use `bun test --isolate --coverage <test-files>` to measure unit test coverage. Inspect coverage for the changed executable lines to verify the 80% requirement.
- Use `bun run build` to verify the gateway build. Add `bun run build:desktop` when desktop or shared changes affect its server bundle.
CI (`.github/workflows/ci.yml`) runs `bun run lint:all`, gateway and desktop typechecks, `bun run test:full`, and `bun run build`.
## Review Summaries
Provide these short summaries so the review output can be consumed by automation, follow-up workflows, or pasted into a pull request:
- `CHANGESET_SUMMARY`: about what changed and why, within roughly 100 words.
- `CODE_REVIEW_SUMMARY`: output the exact structured block below instead of free-form prose.
`CODE_REVIEW_SUMMARY` format:
```text
Review Decision: BLOCKING | NON_BLOCKING
Findings Total: <N> (CRITICAL=<n1>, HIGH_PRIORITY=<n2>, SUGGESTION=<n3>)
[CRITICAL]
1. reason=<reason>; location=<file>:<line>; fix=<action>; occurrences=<count>
[HIGH_PRIORITY]
1. reason=<reason>; location=<file>:<line>; fix=<action>; occurrences=<count>
[SUGGESTION]
1. reason=<reason>; location=<file>:<line>; fix=<action>; occurrences=<count>
```
Formatting rules for this block:
- Always emit all three sections in this order: `CRITICAL`, `HIGH_PRIORITY`, `SUGGESTION`.
- If a section has no entries, write `None` on the next line.
- `Review Decision` is `BLOCKING` when `CRITICAL > 0` or `HIGH_PRIORITY > 0`; otherwise use `NON_BLOCKING`.
- `Findings Total` must equal the sum of the verified findings in `CRITICAL`, `HIGH_PRIORITY`, and `SUGGESTION`.
- Keep the structured field names unchanged. Put evidence inside `reason` and the exact anchor inside `location`; do not add new fields to the structured block.
Keep both summaries concise and avoid unnecessary special characters outside the required structured fields.
## Output Language
All review output is written in English, regardless of reviewer locale or timezone. The structured field names (`Review Decision`, `Findings Total`, `CRITICAL`, `HIGH_PRIORITY`, `SUGGESTION`, `reason`, `location`, `fix`, `occurrences`) must remain exactly as defined for automation compatibility.
## Reviewer Output Template
Use this structure and keep it short and specific:
- **Summary**: <what changed / intent>
- **Context Checked** records what was reviewed, the baseline and selection rationale, evidence consulted, and material limitations.
- **CHANGESET_SUMMARY**: <within ~100 words>
- **CODE_REVIEW_SUMMARY** follows the format and rules in "Review Summaries".
- **Suggestions** follows the structured block when there are actionable follow-ups.
- **Test Notes** records what ran, what was inspected, changed-code coverage for code changes, and verification limits.
- **Release Risk** gives a low, medium, or high rating with the evidence and any remaining uncertainty.
For pull requests, prepare the full output for the `Code Review` section in `.github/PULL_REQUEST_TEMPLATE.md`. Edit the PR body only with explicit user authorization.