/acc:create-distributed-lockfrom acc
Generates distributed locking infrastructure for PHP 8.4: LockInterface, LockFactory, RedisLockAdapter with TTL, and database lock adapter. Includes unit tests.
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.
Read when SKILL.md points to them.
Creates distributed locking infrastructure for concurrency control and mutual exclusion.
| Scenario | Example |
|---|---|
| Resource contention | Prevent concurrent writes to same entity |
| Scheduled tasks | Ensure cron job runs on single node |
| Inventory management | Prevent overselling with stock locks |
| Distributed coordination | Leader election, singleton processes |
Path: src/Infrastructure/Lock/
LockInterface.php — Lock contractLockConfig.php — Configuration value objectLockException.php — Lock acquisition exceptionPath: src/Infrastructure/Lock/
RedisLockAdapter.php — Redis SETNX + TTL lock implementationPath: src/Infrastructure/Lock/
LockFactory.php — Creates configured lock instancesLockConfigTest.php — Configuration validation testsRedisLockAdapterTest.php — Lock behavior tests| Component | Path |
|---|---|
| All Classes | src/Infrastructure/Lock/ |
| Unit Tests | tests/Unit/Infrastructure/Lock/ |
| Component | Pattern | Example |
|---|---|---|
| Interface | LockInterface | LockInterface |
| Config VO | LockConfig | LockConfig |
| Redis Adapter | RedisLockAdapter | RedisLockAdapter |
| Factory | LockFactory | LockFactory |
| Exception | LockException | LockException |
| Test | {ClassName}Test | RedisLockAdapterTest |
interface LockInterface
{
public function acquire(string $resource): bool;
public function release(string $resource): void;
public function isAcquired(string $resource): bool;
public function refresh(string $resource): bool;
}
final readonly class LockConfig
{
public function __construct(
public int $ttlSeconds = 30,
public bool $autoRelease = true,
public int $retryCount = 3,
public int $retryDelayMs = 200
) {}
}
final class RedisLockAdapter implements LockInterface
{
public function acquire(string $resource): bool;
public function release(string $resource): void;
public function isAcquired(string $resource): bool;
public function refresh(string $resource): bool;
}
$lock = $lockFactory->create('order-processing');
try {
if (!$lock->acquire('order:12345')) {
throw LockException::cannotAcquire('order:12345');
}
$order->process();
} finally {
$lock->release('order:12345');
}
acquire() ──→ SET resource token NX EX ttl
│
Success? ──→ Lock held (token stored)
│ │
NO refresh() ──→ Extend TTL
│ │
Retry? ──→ Sleep → retry release() ──→ Compare token → DEL
│
LockException
| Anti-pattern | Problem | Solution |
|---|---|---|
| No TTL | Dead locks on crash | Always set TTL |
| DEL without token check | Release others' locks | Use Lua compare-and-delete |
| Spin lock without delay | CPU waste on contention | Use retry delay |
| No auto-release | Lock leak on exception | Use try/finally or auto-release |
| Single Redis node | No fault tolerance | Consider Redlock for HA |
| Infinite retry | Thread stuck forever | Set max retry count |
For complete PHP templates and examples, see:
references/templates.md — LockInterface, LockConfig, RedisLockAdapter, LockFactory templatesreferences/examples.md — Usage examples and testsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dykyi-roman/awesome-claude-code --plugin acc283 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.Other plugins' skills for the same job