Skip to content

Commit a7a0d97

Browse files
committed
add sectional instruction files for code review
1 parent 6fde1a2 commit a7a0d97

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

.github/copilot-instructions.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Nectar repository-wide Copilot instructions
2+
3+
## Primary objective
4+
Act as a senior reviewer for a Next.js + TypeScript application. Prioritize **correctness, security, regression risk, and operability** over stylistic suggestions.
5+
6+
## Review output style
7+
- Start with a short risk summary.
8+
- Report findings in priority order: `blocker`, `high`, `medium`, `low`.
9+
- For each finding include:
10+
- impact (what can break and for whom),
11+
- precise location(s),
12+
- minimal fix recommendation,
13+
- confidence level (`high`/`medium`/`low`).
14+
- If no issues are found, state what was reviewed and what remains unverified.
15+
16+
## Project-specific baselines
17+
- Stack: Next.js, React, TypeScript, Chakra UI, Vitest, MSW.
18+
- Package manager: **pnpm only**.
19+
- Typical local checks:
20+
1. `pnpm lint`
21+
2. `pnpm test:ci`
22+
3. `pnpm build` (or `pnpm build:local` when requested)
23+
- Dev server defaults to port `8000`.
24+
25+
## What to scrutinize first
26+
1. API contract changes across `src/api`, `src/pages/api`, and consumers.
27+
2. Rendering/data-fetching behavior in `src/pages` and shared components.
28+
3. State/query/cache correctness in `src/lib`, `src/store`, and hooks.
29+
4. Test coverage for behavioral changes (`*.test.ts(x)`, `src/mocks`).
30+
31+
## Security and reliability guardrails
32+
- Flag potential secrets exposure, unsafe env handling, or permissive logging.
33+
- Validate sanitization/escaping for user-controlled content.
34+
- Check error paths and loading/empty states, not only happy paths.
35+
- Highlight breaking API shape changes and migration needs.
36+
37+
## Non-goals
38+
- Avoid nitpicks already enforced by formatter/linter unless they hide real defects.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
applyTo: "src/api/**/*.ts,src/pages/api/**/*.ts,src/lib/**/*.ts,src/store/**/*.ts,src/middleware/**/*.ts,src/middlewares/**/*.ts"
3+
---
4+
5+
# API, data, and server-side review instructions
6+
7+
## Contract and schema integrity
8+
- Detect response/request shape changes and verify all callers are updated.
9+
- Prefer explicit typing for external data boundaries; flag `any` at API edges.
10+
- Ensure query parameter parsing and defaults are deterministic.
11+
12+
## Error handling and observability
13+
- Ensure failures return actionable status codes/messages without leaking internals.
14+
- Verify retries/timeouts/caching behavior do not cause stale or duplicated data.
15+
- Confirm logging captures useful diagnostics while avoiding sensitive payloads.
16+
17+
## State and cache correctness
18+
- Check for race conditions in async flows and stale closure issues.
19+
- Validate cache invalidation and key stability for React Query/store selectors.
20+
- Flag mutation flows that do not reconcile local state with server truth.
21+
22+
## Security checks
23+
- Validate auth/authorization assumptions on route handlers and middleware.
24+
- Flag open redirect, injection, and unsafe header/cookie usage patterns.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
applyTo: "src/components/**/*.ts,src/components/**/*.tsx,src/pages/**/*.ts,src/pages/**/*.tsx,src/styles/**/*.css"
3+
---
4+
5+
# Frontend review instructions (React/Next.js)
6+
7+
## Focus areas
8+
- Verify SSR/CSR behavior is intentional (no browser-only APIs during SSR without guards).
9+
- Confirm route-level pages maintain expected metadata, loading, and error behavior.
10+
- Check Chakra UI usage for accessibility regressions: semantic controls, labels, keyboard navigation, focus visibility.
11+
- Validate conditional rendering to avoid layout flicker and hydration mismatches.
12+
13+
## Performance checks
14+
- Flag unnecessary rerenders from unstable props/callbacks in hot paths.
15+
- Watch for expensive client-side transforms that should be memoized or moved server-side.
16+
- Ensure large dependencies are not added to shared/page-critical bundles without justification.
17+
18+
## UX regression checklist
19+
- Empty, loading, and error states are explicit and user-friendly.
20+
- Interactive controls have disabled and busy states when async operations run.
21+
- New text is concise and consistent with existing naming/terminology.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
applyTo: "**/*.test.ts,**/*.test.tsx,src/mocks/**/*.ts"
3+
---
4+
5+
# Testing and mocking review instructions
6+
7+
## Test quality expectations
8+
- Tests should assert behavior, not implementation details.
9+
- New logic paths should include at least one success path and one failure/edge path.
10+
- Prefer deterministic tests (no real network/time randomness unless controlled).
11+
12+
## Vitest and Testing Library guidance
13+
- Verify async UI tests wait for user-visible outcomes.
14+
- Ensure queries prefer accessible roles/labels over brittle selectors.
15+
- Flag snapshots that replace meaningful assertions.
16+
17+
## MSW/mocks guidance
18+
- Mocks should reflect realistic API contracts and error payloads.
19+
- When changing endpoint behavior, update handlers and impacted tests together.
20+
- Avoid over-mocking internal modules when an integration-style test is feasible.

0 commit comments

Comments
 (0)