/acc:check-abstract-factoryfrom acc
Audits Abstract Factory pattern implementations in PHP code, checking family consistency, product hierarchy, factory method completeness, and cross-family compatibility.
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 Abstract Factory pattern compliance — ensuring consistent object families and proper product hierarchies.
// ANTIPATTERN: Creating related objects without factory
class NotificationService
{
public function send(string $type, string $message): void
{
if ($type === 'email') {
$transport = new SmtpTransport(); // Family: Email
$formatter = new HtmlFormatter(); // Family: Email
$tracker = new EmailOpenTracker(); // Family: Email
} elseif ($type === 'sms') {
$transport = new TwilioTransport(); // Family: SMS
$formatter = new PlainTextFormatter(); // Family: SMS
$tracker = new SmsDeliveryTracker(); // Family: SMS
}
}
}
// CORRECT: Abstract Factory ensures family consistency
interface NotificationFactory
{
public function createTransport(): TransportInterface;
public function createFormatter(): FormatterInterface;
public function createTracker(): TrackerInterface;
}
// ANTIPATTERN: Factory missing products
final readonly class EmailNotificationFactory implements NotificationFactory
{
public function createTransport(): TransportInterface
{
return new SmtpTransport();
}
public function createFormatter(): FormatterInterface
{
return new HtmlFormatter();
}
// MISSING: createTracker() — incomplete family!
}
// ANTIPATTERN: Products from different families mixed
final readonly class PushNotificationFactory implements NotificationFactory
{
public function createTransport(): TransportInterface
{
return new FirebaseTransport(); // Push family
}
public function createFormatter(): FormatterInterface
{
return new HtmlFormatter(); // Email family! Wrong!
}
}
// ANTIPATTERN: Factory returns concrete types
class DatabaseFactory
{
public function createConnection(): MySqlConnection // Concrete!
{
return new MySqlConnection();
}
public function createQueryBuilder(): MySqlQueryBuilder // Concrete!
{
return new MySqlQueryBuilder();
}
}
// CORRECT: Returns interfaces
interface DatabaseFactory
{
public function createConnection(): ConnectionInterface;
public function createQueryBuilder(): QueryBuilderInterface;
}
// ANTIPATTERN: Concrete factory without abstraction
class PaymentGatewayFactory
{
public function createProcessor(): StripeProcessor { }
public function createRefunder(): StripeRefunder { }
}
// Cannot swap to PayPal family!
// CORRECT: Abstract factory interface
interface PaymentGatewayFactory
{
public function createProcessor(): PaymentProcessorInterface;
public function createRefunder(): RefundProcessorInterface;
}
final readonly class StripeGatewayFactory implements PaymentGatewayFactory { }
final readonly class PayPalGatewayFactory implements PaymentGatewayFactory { }
# Abstract Factory detection
Grep: "interface.*Factory" --glob "**/*.php"
Grep: "AbstractFactory|FactoryInterface" --glob "**/*.php"
# Multiple create methods in one class (potential Abstract Factory)
Grep: "function create[A-Z]" --glob "**/*Factory.php"
# Family instantiation without factory
Grep: "if.*===.*new.*\n.*new.*\n.*new" --glob "**/*.php"
# Type switch creating object families
Grep: "switch.*type|switch.*strategy|switch.*provider" --glob "**/*.php"
# Factory returning concrete types
Grep: "function create.*: [A-Z][a-zA-Z]+[^I](?!nterface)" --glob "**/*Factory.php"
| Check | Severity | Description |
|---|---|---|
| Factory interface exists | 🔴 Critical | Each family must have abstract factory |
| All products defined | 🔴 Critical | Every family creates all required products |
| Interface return types | 🟠 Major | Factory methods return interfaces |
| No cross-family mixing | 🟠 Major | Products belong to same family |
| Family consistency | 🟠 Major | All factories create compatible products |
| Single Responsibility | 🟡 Minor | Factory only creates, no business logic |
// Product interfaces
interface ButtonInterface
{
public function render(): string;
}
interface CheckboxInterface
{
public function render(): string;
}
// Abstract Factory
interface UIComponentFactory
{
public function createButton(): ButtonInterface;
public function createCheckbox(): CheckboxInterface;
}
// Concrete Families
final readonly class MaterialUIFactory implements UIComponentFactory
{
public function createButton(): ButtonInterface
{
return new MaterialButton();
}
public function createCheckbox(): CheckboxInterface
{
return new MaterialCheckbox();
}
}
final readonly class BootstrapUIFactory implements UIComponentFactory
{
public function createButton(): ButtonInterface
{
return new BootstrapButton();
}
public function createCheckbox(): CheckboxInterface
{
return new BootstrapCheckbox();
}
}
### Abstract Factory: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Issue:**
[Description of the Abstract Factory violation]
**Impact:**
- Cross-family incompatibility possible
- Cannot swap implementations cleanly
- Violates Open/Closed Principle
**Code:**
```php
// Current code
Fix:
// Abstract Factory refactored
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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