find-boundary-issues

Detects boundary issues in PHP code. Finds array index out of bounds, empty collection access, off-by-one errors, integer overflow, string length issues.

59 stars

Best use case

find-boundary-issues is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Detects boundary issues in PHP code. Finds array index out of bounds, empty collection access, off-by-one errors, integer overflow, string length issues.

Teams using find-boundary-issues should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/find-boundary-issues/SKILL.md --create-dirs "https://raw.githubusercontent.com/dykyi-roman/awesome-claude-code/main/skills/find-boundary-issues/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/find-boundary-issues/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How find-boundary-issues Compares

Feature / Agentfind-boundary-issuesStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Detects boundary issues in PHP code. Finds array index out of bounds, empty collection access, off-by-one errors, integer overflow, string length issues.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Boundary Issue Detection

Analyze PHP code for boundary and range violations.

## Detection Patterns

### 1. Array Index Out of Bounds

```php
// BUG: No bounds check
$items = [1, 2, 3];
$last = $items[count($items)]; // Off by one, should be count - 1

// BUG: Hardcoded index
$third = $data[2]; // May not have 3 elements

// BUG: Negative index
$item = $array[$index]; // $index could be negative
```

### 2. Empty Collection Access

```php
// BUG: first() on empty
$users = $repository->findBy(['status' => 'vip']);
$topUser = $users[0]; // May be empty

// BUG: array_pop on empty
$items = [];
$last = array_pop($items); // Returns null

// BUG: reset() on empty
$first = reset($emptyArray); // Returns false
```

### 3. Off-by-One Errors

```php
// BUG: Loop boundary
for ($i = 0; $i <= count($items); $i++) { // Should be <
    process($items[$i]); // Last iteration fails
}

// BUG: Substring
$sub = substr($string, 0, strlen($string) + 1); // Off by one

// BUG: Slice
$slice = array_slice($array, 0, count($array) + 1);
```

### 4. Integer Overflow/Underflow

```php
// BUG: No overflow check
$total = $price * $quantity; // May overflow

// BUG: Negative result
$remaining = $stock - $ordered; // May go negative

// BUG: Division truncation
$average = $total / $count; // Integer division loses precision
```

### 5. String Length Issues

```php
// BUG: Empty string access
$first = $string[0]; // Undefined if empty

// BUG: Multibyte issues
$length = strlen($utf8String); // Wrong for multibyte
$char = $string[5]; // May split multibyte char

// BUG: No length check
$sub = substr($name, 0, 10); // May be shorter than 10
```

### 6. Range Validation

```php
// BUG: Unchecked range
$page = $request->get('page'); // Could be 0, negative, or huge
$items = $repository->findPage($page); // Invalid page

// BUG: Missing min/max
$age = (int) $input; // Could be negative or 1000
```

### 7. Date/Time Boundaries

```php
// BUG: Invalid month/day
$date = new DateTime("2024-13-45"); // Invalid date

// BUG: Leap year
$date = new DateTime("2023-02-29"); // Not a leap year
```

## Grep Patterns

```bash
# Direct array index access
Grep: "\$\w+\[\d+\]" --glob "**/*.php"

# count() in loop condition
Grep: "for\s*\([^;]+;\s*\$\w+\s*<=\s*count" --glob "**/*.php"

# Array access after find
Grep: "findBy[^;]+;\s*\n\s*\$\w+\[0\]" --glob "**/*.php"

# Hardcoded string index
Grep: '\$\w+\["\w+"\]\[\d+\]' --glob "**/*.php"
```

## Severity Classification

| Pattern | Severity |
|---------|----------|
| Unchecked array index | 🟠 Major |
| Off-by-one in loop | 🟠 Major |
| Empty collection access | 🟠 Major |
| Integer overflow | 🟡 Minor |
| Multibyte string issue | 🟡 Minor |

## Output Format

```markdown
### Boundary Issue: [Description]

**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Array Bounds|Off-by-One|Empty Access|Overflow|...]

**Issue:**
[Description of the boundary violation]

**Code:**
```php
// Problematic code
```

**Fix:**
```php
// With bounds check
```
```

Related Skills

find-type-issues

59
from dykyi-roman/awesome-claude-code

Detects type issues in PHP code. Finds implicit type coercion, mixed types in comparisons, unsafe casting, type mismatches in returns.

find-resource-leaks

59
from dykyi-roman/awesome-claude-code

Detects resource leaks in PHP code. Finds unclosed file handles, database connections not released, streams not freed, missing finally blocks, temporary files not cleaned.

find-race-conditions

59
from dykyi-roman/awesome-claude-code

Detects race conditions in PHP code. Finds shared mutable state, check-then-act patterns, TOCTOU vulnerabilities, concurrent modification issues.

find-null-pointer-issues

59
from dykyi-roman/awesome-claude-code

Detects null pointer issues in PHP code. Finds property/method access on null, missing null checks, nullable returns without handling, optional chaining gaps.

find-logic-errors

59
from dykyi-roman/awesome-claude-code

Detects logic errors in PHP code. Finds incorrect conditions, wrong operators, missing switch cases, inverted logic, short-circuit evaluation issues.

find-infinite-loops

59
from dykyi-roman/awesome-claude-code

Detects infinite loop risks in PHP code. Finds missing break conditions, incorrect loop variables, unbounded recursion, circular references.

find-exception-issues

59
from dykyi-roman/awesome-claude-code

Detects exception handling issues in PHP code. Finds swallowed exceptions, generic catches, missing exception handling, re-throwing without context, exception in finally.

bug-root-cause-finder

59
from dykyi-roman/awesome-claude-code

Root cause analysis methods for PHP bugs. Provides 5 Whys technique, fault tree analysis, git bisect guidance, and stack trace parsing.

yii-knowledge

59
from dykyi-roman/awesome-claude-code

Yii framework knowledge base. Provides Yii3 modular architecture, DDD integration, PSR-7/PSR-15 compliance, persistence, DI, security (RBAC, auth), event system (PSR-14), queue/jobs, infrastructure components (cache, rate limiter, HTTP client), testing, and antipatterns for Yii PHP projects.

troubleshooting-template

59
from dykyi-roman/awesome-claude-code

Generates troubleshooting guides and FAQ sections for PHP projects. Creates problem-solution documentation.

trace-request-lifecycle

59
from dykyi-roman/awesome-claude-code

Traces full request lifecycle from Router through Middleware, Controller, UseCase, Repository to Response. Documents HTTP methods, routes, middleware stack, response codes, and error handling paths.

trace-data-transformation

59
from dykyi-roman/awesome-claude-code

Maps data transformation chains — Request DTO to Command to Entity to Response DTO. Identifies mappers, serializers, type conversions, and data loss points across layer boundaries.