ProSkillsLibraryFreePassScan
Code Review

Code Review · agent skill

Debug Detective

Root cause, not a patch. Regression test included.

What it does

Loads when it is needed

Your agent loads it when the user has a failing test, an error or a bug that regressed. It carries 5 rules and reads a profile.md with your details before it starts, so the output matches your brand and project.

Same prompt, with and without

Daily report off by a day

Prompt · The Sydney tenant says yesterday's order count in the daily report is too low and the day before looks too high. UTC tenants look fine. It started last week. Find the root cause.

src/reports/daily.ts
12 export function bucketByDay(orders: Order[], tz: string) {
13   const out: Record<string, number> = {};
14   for (const o of orders) {
15     const day = o.createdAt.toISOString().slice(0, 10);
16     out[day] = (out[day] ?? 0) + 1;
17   }
18   return out;
19 }

git log --oneline -3 src/reports/daily.ts
c41d9e2 refactor: simplify day bucketing (drop Intl formatter)
8b02f7a feat: per-tenant timezone in daily report
3d19b55 feat: daily report

git show c41d9e2 (excerpt)
-    const day = new Intl.DateTimeFormat("en-CA", { timeZone: tz }).format(o.createdAt);
+    const day = o.createdAt.toISOString().slice(0, 10);

Profile used: Project: order analytics for multi-tenant shop platform; Stack: TypeScript, Node, vitest; Strictness: Standard; Conventions: tests beside source, fix: commit prefix

Without the skill
Root cause: commit c41d9e2 ("simplify day bucketing") replaced the timezone-aware `Intl.DateTimeFormat("en-CA", { timeZone: tz })` with `o.createdAt.toISOString().slice(0, 10)`. That always yields the UTC date, and the `tz` parameter is now unused. UTC tenants are unaffected, which matches your symptoms. For Sydney (UTC+10/+11), local midnight is 13:00-14:00 UTC the previous day. Orders placed in the Sydney morning (before about 10-11am local) land in the previous UTC day, so "yesterday" is undercounted and the day before is overcounted. "Started last week" lines up with that refactor being deployed. Fix: restore the formatter. ```ts const fmt = new Intl.DateTimeFormat("en-CA", { timeZone: tz }); for (const o of orders) { const day = fmt.format(o.createdAt); out[day] = (out[day] ?? 0) + 1; } ``` Creating the formatter once outside the loop is also faster. Add a vitest test beside the source: an order at 2025-03-10T20:00:00Z with tz "Australia/Sydney" should bucket to 2025-03-11, while UTC gives 2025-03-10. Suggested commit: `fix: bucket daily report by tenant timezone`. Reports generated since the refactor may need regenerating for non-UTC tenants.
With the skill
Symptom. Expected: orders counted on the tenant's local date. Actual: Sydney orders from 00:00-11:00 local land on the previous date. Scope: far-from-UTC tenants; since last week. Repro (orders at 22:30Z, 02:00Z, 13:00Z, tz Australia/Sydney, run just now): current {2026-10-15: 1, 2026-10-16: 2} before {2026-10-16: 2, 2026-10-17: 1} H1 (high, 1 min): c41d9e2 dropped the tz conversion. Test: run both lines on the repro. H2 (med): Sydney's DST change broke an offset. Disproved if UTC bucketing is wrong anyway. H3 (low): bad createdAt values for this tenant. H1 confirmed: the old line gives the expected buckets; the new one is always UTC and `tz` is unused. H2, H3 not needed; `git log` names the culprit, so no bisect. Root cause: src/reports/daily.ts:15 buckets by UTC date, not the tenant's local date. Fix: restore the Intl formatter with `tz`. Regression test in daily.test.ts: the three orders in Sydney must give {16: 2, 17: 1}; fails now, passes on the fix. Same pattern: grep `toISOString().slice(0, 10)` in reports and exports (not done; only this file was provided). Postmortem What happened: since the refactor, non-UTC tenants' daily counts are shifted. Root cause: tz parameter ignored after c41d9e2. Why missed: no test with a non-UTC tenant. Fix: restore tz formatting, regression test above. Prevention: add Sydney and Los Angeles cases to the report tests.

Both answers from the same model (Claude sonnet), 2026-10-16. The one without the skill was written in a separate session that never saw it. Shortened where marked with …

Install

One command, in your project

It detects your agent; add --agent all for every agent.

npx proskills-cli add debug-detective --order <order id from your receipt>

Or copy the skill folder (the one holding SKILL.md) into the directory your agent reads, then restart it or start a new session.

AgentThis projectEvery project
Claude Code.claude/skills/~/.claude/skills/
Cursor.agents/skills/ (or .cursor/skills/)~/.cursor/skills/
Codex.agents/skills/~/.agents/skills/
Gemini CLI.agents/skills/ (or .gemini/skills/)~/.gemini/skills/

Changelog

What changed

  • v1.0.0 · 2026-10-16
    • First versioned release: Root cause, not a patch. Regression test included.
    • Scanned 100/100 before release.

Keep it current with npx proskills-cli update; your profile.md is never touched. Everyone who bought it gets the update free and an email when it lands.

Same collection

More from Code Review

The scan checks spec compliance, token cost, clarity and security patterns. A clean scan is not a guarantee: static scanners can be evaded. Scan any skill yourself.