Catches off-by-one errors in loops, slices, and ranges by naming the interval convention and testing endpoints. Use when a loop misses the first or last element or reads past the end.
The bug lives at the edge, never the center. A loop that processes the middle correctly can still miss the first element, double the last, or read one slot past the array. These errors survive because tests exercise the happy middle and skip the endpoints where the mistake actually is. Pin the convention on paper, then attack the boundaries.
[start, end), start included, end excluded. range(0, n)
yields 0..n-1; a[2:5] gives indices 2, 3, 4. Write which end is
inclusive before you reason about the count. Mixing a half-open slice
with an inclusive comparison is the classic source.[start, end)
the count is end - start, no plus-one. For a fully inclusive range
[lo, hi] the count is hi - lo + 1. If your length formula needs a
+1 next to a half-open slice, one of them is wrong.for x in items, for (const x of items), or items.forEach cannot be off by one because there is no
bound to miscount. Reach for a raw for (i = 0; i < n; i++) only when you
truly need the index, and then guard < versus <= deliberately.n, n-1, and n+1 around any limit are
where the defect hides, so assert on those, not on n/2.BETWEEN in SQL,
substring end arguments, circular-buffer wraparound with % size,
pagination offsets (page * size versus (page-1) * size), and binary
search lo <= hi versus lo < hi. Each has a canonical off-by-one.+1?Follow the language's native convention rather than imposing your own: Python and C are zero-based half-open, but some SQL, Lua, and business rules are one-based and inclusive. The skill is making the convention explicit, not standardizing it across a codebase that has reasons to differ.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
fencepost-errors, boundary-testing, loop-debugging, off-by-one
Not loaded · from ai-skills-commands
Claude Code won't load this skill
It ships in ai-skills-commands at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
npx claudepluginhub amey-thakur/ai-skills --plugin ai-skills-commands1,000 skills in this plugin
/ab-test-designDesign product experiments with real hypotheses, honest sample-size math, guardrails, and peeking discipline. Use when validating a change by experiment or reviewing a test before believing its result./accessibility-reviewAudit a UI for real accessibility, keyboard-first, with concrete failures and fixes rather than checkbox compliance. Use when reviewing or building any user interface./accessibility-specialist-roleOperate as an accessibility specialist who audits against WCAG, trains teams to stop shipping the same defects, and owns the compliance sign-off. Use when a product needs to be usable with a keyboard, a screen reader, or magnification and someone must certify it before launch.Other plugins' skills for the same job