/acc:find-race-conditionsfrom acc
Detects race conditions in PHP code including TOCTOU, shared mutable state, and concurrent modification issues across files, databases, and sessions.
Ships in acc. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Analyze PHP code for concurrency issues and race conditions.
// BUG: Time-of-check to time-of-use
if (file_exists($path)) {
$content = file_get_contents($path); // File may be deleted
}
// BUG: Check then modify
if (!$user->hasOrder()) {
$order = new Order();
$user->addOrder($order); // Another request may add order
}
// BUG: Inventory check-then-act
if ($product->getStock() >= $quantity) {
$product->decreaseStock($quantity); // Race with other orders
}
// BUG: Static mutable property
class Counter {
private static int $count = 0;
public function increment(): void {
self::$count++; // Not atomic
}
}
// BUG: Shared cache without locking
class Cache {
private array $data = [];
public function getOrSet(string $key, callable $factory): mixed {
if (!isset($this->data[$key])) {
$this->data[$key] = $factory(); // May compute twice
}
return $this->data[$key];
}
}
// BUG: Non-atomic increment
$counter = $redis->get('counter');
$redis->set('counter', $counter + 1); // Lost update
// BUG: Balance update
$balance = $account->getBalance();
$account->setBalance($balance - $amount); // Race condition
// FIXED: Use atomic operations
$redis->incr('counter');
// BUG: Directory creation race
if (!is_dir($path)) {
mkdir($path); // Another process may create it
}
// BUG: File write race
$data = json_decode(file_get_contents($file));
$data['count']++;
file_put_contents($file, json_encode($data)); // Lost update
// BUG: No optimistic locking
$entity = $repository->find($id);
$entity->setStatus('processed');
$entityManager->flush(); // Another process may have changed it
// BUG: Unique constraint race
if (!$repository->findByEmail($email)) {
$user = new User($email);
$entityManager->persist($user); // Duplicate may be created
}
// BUG: Session data race
$cart = $_SESSION['cart'];
$cart[] = $newItem;
$_SESSION['cart'] = $cart; // Lost update with concurrent requests
# Check-then-act patterns
Grep: "if\s*\(file_exists\([^)]+\)\)\s*\{[^}]*file_get_contents" --glob "**/*.php"
# Static mutable properties
Grep: "private static\s+(?!readonly)" --glob "**/*.php"
# Read-modify-write on Redis
Grep: "->get\([^)]+\)[^;]*\+[^;]*->set" --glob "**/*.php"
# Non-atomic increment
Grep: "\+\+|\-\-|self::\$\w+\s*\+=" --glob "**/*.php"
| Pattern | Severity |
|---|---|
| Financial data race | 🔴 Critical |
| Inventory TOCTOU | 🔴 Critical |
| Unique constraint race | 🟠 Major |
| File system race | 🟠 Major |
| Cache stampede | 🟡 Minor |
| Counter race | 🟡 Minor |
// Database lock
$connection->beginTransaction();
$entity = $repository->find($id, LockMode::PESSIMISTIC_WRITE);
$entity->process();
$connection->commit();
// Redis atomic increment
$redis->incr('counter');
// Database atomic update
$connection->executeStatement(
'UPDATE products SET stock = stock - ? WHERE id = ? AND stock >= ?',
[$quantity, $productId, $quantity]
);
#[Version]
private int $version;
// Will throw OptimisticLockException on conflict
### Race Condition: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [TOCTOU|Shared State|Read-Modify-Write|...]
**Issue:**
[Description of the race condition]
**Code:**
```php
// Problematic code
Fix:
// Thread-safe version
What SKILL.md sets; muted values are Claude Code's defaults
283 skills in this plugin
/access-control-knowledgeAccess Control knowledge base. Provides ACL, RBAC, ABAC, ReBAC models, multi-tenancy patterns, and PHP implementations (Symfony Voters, Laravel Gates) for security audits and generation./adr-knowledgeAction-Domain-Responder pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for ADR (web-specific MVC alternative) audits./adr-templateGenerates Architecture Decision Records (ADR) for PHP projects. Creates structured decision documentation with context, decision, and consequences./analyze-ci-configAnalyzes existing CI/CD configurations. Detects issues in GitHub Actions and GitLab CI files, checks for best practices, caching efficiency, and security concerns./analyze-ci-logsAnalyzes CI/CD pipeline logs to identify failure causes. Parses error messages, detects common failure patterns, and provides fix recommendations./analyze-coupling-cohesionAnalyzes coupling and cohesion metrics in PHP codebases. Calculates Afferent/Efferent coupling (Ca/Ce), LCOM metrics, instability index, and abstractness. Identifies highly coupled modules and low cohesion classes.npx claudepluginhub dykyi-roman/awesome-claude-code --plugin accOther plugins' skills for the same job