acc-create-object-pool

Generates Object Pool pattern for PHP 8.5. Creates reusable object containers for expensive resources like connections. Includes unit tests.

16 stars

Best use case

acc-create-object-pool is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generates Object Pool pattern for PHP 8.5. Creates reusable object containers for expensive resources like connections. Includes unit tests.

Teams using acc-create-object-pool 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/acc-create-object-pool/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/data-ai/acc-create-object-pool/SKILL.md"

Manual Installation

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

How acc-create-object-pool Compares

Feature / Agentacc-create-object-poolStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generates Object Pool pattern for PHP 8.5. Creates reusable object containers for expensive resources like connections. Includes unit tests.

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

# Object Pool Pattern Generator

Creates Object Pool pattern infrastructure for managing reusable expensive objects.

## When to Use

| Scenario | Example |
|----------|---------|
| Expensive creation | Database connections |
| Limited resources | HTTP client handles |
| Connection reuse | Socket connections |
| Memory management | Large object caching |

## Component Characteristics

### PoolInterface
- Acquire/release semantics
- Pool lifecycle management
- Capacity configuration

### Pool Implementation
- Manages available objects
- Creates on demand
- Recycles returned objects

### Poolable Objects
- Resettable state
- Validate before reuse
- Track usage metrics

---

## Generation Process

### Step 1: Generate Core Pool Components

**Path:** `src/Infrastructure/Pool/`

1. `PoolInterface.php` — Generic pool contract with acquire/release
2. `PoolConfig.php` — Configuration value object (min/max size, timeouts)
3. `PoolableInterface.php` — Contract for poolable objects (reset, isValid, close)
4. `ObjectPool.php` — Generic pool implementation
5. `PooledObject.php` — Wrapper tracking usage metrics
6. `PoolExhaustedException.php` — Exception for exhausted pool
7. `InvalidPoolObjectException.php` — Exception for invalid objects

### Step 2: Generate Specialized Pool (if needed)

**Path:** `src/Infrastructure/{Domain}/`

1. `{Type}Pool.php` — Specialized pool (ConnectionPool, HttpClientPool)
2. `Poolable{Type}.php` — Poolable implementation for specific resource

### Step 3: Generate Tests

**Path:** `tests/Unit/Infrastructure/Pool/`

1. `ObjectPoolTest.php` — Core pool functionality tests
2. `{Type}PoolTest.php` — Specialized pool tests

---

## File Placement

| Component | Path |
|-----------|------|
| Pool Interface | `src/Infrastructure/Pool/` |
| Pool Implementation | `src/Infrastructure/Pool/` |
| Specialized Pools | `src/Infrastructure/{Domain}/` |
| Unit Tests | `tests/Unit/Infrastructure/Pool/` |

---

## Naming Conventions

| Component | Pattern | Example |
|-----------|---------|---------|
| Interface | `PoolInterface` | `PoolInterface` |
| Implementation | `ObjectPool` | `ObjectPool` |
| Poolable Interface | `PoolableInterface` | `PoolableInterface` |
| Config | `PoolConfig` | `PoolConfig` |
| Wrapper | `PooledObject` | `PooledObject` |
| Specialized Pool | `{Type}Pool` | `ConnectionPool` |
| Test | `{ClassName}Test` | `ObjectPoolTest` |

---

## Quick Template Reference

### PoolInterface

```php
/**
 * @template T
 */
interface PoolInterface
{
    /** @return T */
    public function acquire(): mixed;
    /** @param T $object */
    public function release(mixed $object): void;
    public function getAvailableCount(): int;
    public function getActiveCount(): int;
    public function getMaxSize(): int;
    public function clear(): void;
}
```

### PoolableInterface

```php
interface PoolableInterface
{
    public function reset(): void;
    public function isValid(): bool;
    public function close(): void;
}
```

### PoolConfig

```php
final readonly class PoolConfig
{
    public function __construct(
        public int $minSize = 0,
        public int $maxSize = 10,
        public int $maxWaitTimeMs = 5000,
        public int $idleTimeoutSeconds = 300,
        public bool $validateOnAcquire = true,
        public bool $validateOnRelease = false
    );

    public static function default(): self;
    public static function forDatabase(): self;
    public static function forHttpClients(): self;
}
```

---

## Usage Example

```php
// Create pool
$pool = new ObjectPool(
    name: 'database',
    factory: fn() => $connectionFactory->create(),
    config: PoolConfig::forDatabase(),
    logger: $logger
);

// Acquire and release
$connection = $pool->acquire();
try {
    $result = $connection->query('SELECT ...');
} finally {
    $pool->release($connection);
}

// Or use helper
$result = $connectionPool->execute(fn($conn) => $conn->query('SELECT ...'));
```

---

## Anti-patterns to Avoid

| Anti-pattern | Problem | Solution |
|--------------|---------|----------|
| No Validation | Returning broken objects | Validate on acquire |
| No Reset | State leaks between uses | Call reset() on release |
| No Timeout | Infinite wait | Set maxWaitTime |
| Unbounded Pool | Memory exhaustion | Set maxSize |
| Not Releasing | Pool exhaustion | Use try/finally |
| Wrong Scope | Per-request pools | Use singleton/shared pool |

---

## References

For complete PHP templates and examples, see:
- `references/templates.md` — All component templates
- `references/examples.md` — ConnectionPool, HttpClientPool examples and tests

Related Skills

mcp-create-declarative-agent

16
from diegosouzapw/awesome-omni-skill

Skill converted from mcp-create-declarative-agent.prompt.md

kitt-create-slash-commands

16
from diegosouzapw/awesome-omni-skill

Expert guidance for creating slash commands. Use when working with slash commands, creating custom commands, understanding command structure, or learning YAML configuration.

kitt-create-plans

16
from diegosouzapw/awesome-omni-skill

Create hierarchical project plans optimized for solo agentic development. Use when planning projects, phases, or tasks that the AI agent will execute. Produces agent-executable plans with verification criteria, not enterprise documentation. Handles briefs, roadmaps, phase plans, and context handoffs.

create-workflow

16
from diegosouzapw/awesome-omni-skill

Create Jazz workflow automation files (WORKFLOW.md). Use this for scheduling Jazz agents to run recurring tasks. For OS-level scripts/commands, use create-system-routine.

create-rule

16
from diegosouzapw/awesome-omni-skill

Create persistent AI agent rules and instructions. Use when you want to create a rule, add coding standards, set up project conventions, configure file-specific patterns, or create AGENTS.md/GEMINI.md rule files across Cursor, Gemini CLI, or Codex.

create-prompt

16
from diegosouzapw/awesome-omni-skill

Expert prompt engineering for creating effective prompts for Claude, GPT, and other LLMs. Use when writing system prompts, user prompts, few-shot examples, or optimizing existing prompts for better performance.

create-expert-skill

16
from diegosouzapw/awesome-omni-skill

Create production-ready skills from expert knowledge. Extracts domain expertise and system ontologies, uses scripts for deterministic work, loads knowledge progressively. Use when building skills that must work reliably in production.

create-event-handlers

16
from diegosouzapw/awesome-omni-skill

Sets up RabbitMQ event publishers and consumers following ModuleImplementationGuide.md Section 9. RabbitMQ only (no Azure Service Bus). Creates publishers with DomainEvent (tenantId preferred), consumers with handlers, naming {domain}.{entity}.{action}, required fields (id, type, version, timestamp, tenantId, source, data). Use when adding event-driven communication, async workflows, or integrating via events.

create-custom-prompt

16
from diegosouzapw/awesome-omni-skill

Prompt for creating custom prompt files

create-assistant

16
from diegosouzapw/awesome-omni-skill

Create and configure Vapi voice AI assistants with models, voices, transcribers, tools, hooks, and advanced settings. Use when building voice agents, phone bots, customer support assistants, or any conversational AI that handles phone or web calls.

create-agents-md

16
from diegosouzapw/awesome-omni-skill

Create or rewrite AGENTS.md files for Open Mercato packages and modules. Use this skill when adding a new package, creating a new module, or when an existing AGENTS.md needs to be created or refactored. Ensures prescriptive tone, MUST rules, checklists, and consistent structure across all agent guidelines.

create-agent-with-sanity-context

16
from diegosouzapw/awesome-omni-skill

Build AI agents with structured access to Sanity content via Context MCP. Covers Studio setup, agent implementation, and advanced patterns like client-side tools and custom rendering.