From acc
Provides GRASP principles reference for PHP 8.4 projects with violation detection greps, bash commands, and examples for OO architecture audits and design decisions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:grasp-knowledgeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
GRASP (General Responsibility Assignment Software Patterns) provides guidelines for assigning responsibilities to classes and objects in object-oriented design.
GRASP (General Responsibility Assignment Software Patterns) provides guidelines for assigning responsibilities to classes and objects in object-oriented design.
| Principle | Core Question | Goal |
|---|---|---|
| Information Expert | Who has the data? | Assign to class with information |
| Creator | Who creates objects? | Assign creation responsibility |
| Controller | Who handles system events? | Coordinate use case flow |
| Low Coupling | How to reduce dependencies? | Minimize interconnections |
| High Cohesion | How to focus responsibilities? | Keep related things together |
| Polymorphism | How to handle type variations? | Use polymorphic operations |
| Pure Fabrication | What if no domain class fits? | Create artificial class |
| Indirection | How to decouple? | Add intermediate object |
| Protected Variations | How to handle change? | Hide variation points |
# Feature Envy: Class uses other class's data more
Grep: "->get.*->get.*->get" --glob "**/*.php"
# Train wreck calls
Grep: "->.*()->.*()->.*()->" --glob "**/*.php"
Signs: Method accesses other object's data extensively, data and behavior separated.
# Random creation locations
Grep: "new\s\+[A-Z][a-z]*[A-Z]" --glob "**/*.php"
Signs: Objects created in unexpected places, no clear creation ownership.
# Fat controllers (>100 lines)
find . -path "*/Controller/*.php" -exec wc -l {} \; | awk '$1 > 100'
# Business logic in controllers
Grep: "if.*&&.*||" --glob "*Controller.php"
Signs: Controller has >100 lines, business logic in controller.
# High dependency count (>7)
Grep: "__construct" --glob "**/*.php" -A 15
# Concrete type dependencies
Grep: "function.*([A-Z][a-z]*[A-Z]" --glob "**/*.php"
Signs: Class has >7 dependencies, depends on concrete classes.
# Unrelated method names
Grep: "public function" --glob "**/*.php" | grep -E "And[A-Z]|Or[A-Z]"
# Multiple responsibilities in class name
Grep: "class.*Manager|class.*Handler|class.*Processor" --glob "**/*.php"
Signs: Methods don't relate to each other, class does many unrelated things.
// BAD: Logic outside of object with data
final class OrderService
{
public function calculateTotal(Order $order): Money
{
$total = Money::zero();
foreach ($order->getLines() as $line) {
$total = $total->add($line->getProduct()->getPrice()->multiply($line->getQuantity()));
}
return $total;
}
}
// GOOD: Logic in class that has the data
final class Order
{
public function total(): Money
{
return array_reduce(
$this->lines,
fn(Money $sum, OrderLine $line) => $sum->add($line->total()),
Money::zero(),
);
}
}
// BAD: Depends on concrete classes
final class ReportGenerator
{
public function __construct(
private DoctrineOrderRepository $orders,
private SymfonyMailer $mailer,
) {}
}
// GOOD: Depends on abstractions
final readonly class ReportGenerator
{
public function __construct(
private OrderReader $orders,
private Mailer $mailer,
) {}
}
// BAD: Low cohesion - unrelated responsibilities
final class UserManager
{
public function register(array $data): User { }
public function sendEmail(User $user): void { }
public function generateReport(): string { }
}
// GOOD: High cohesion - focused responsibilities
final readonly class UserRegistrationService
{
public function register(RegistrationData $data): User { }
public function confirmEmail(Token $token): void { }
}
| GRASP | DDD Application |
|---|---|
| Information Expert | Entities contain their behavior |
| Creator | Aggregates create their entities |
| Controller | Application Services / Use Cases |
| Low Coupling | Bounded Context boundaries |
| High Cohesion | Aggregate consistency boundary |
| Polymorphism | Domain Services, Strategies |
| Pure Fabrication | Repositories, Factories, Specifications |
| Indirection | Anti-Corruption Layer, Adapters |
| Protected Variations | Ports & Adapters, Domain Events |
For detailed patterns and examples, see references/:
information-expert.md — Tell Don't Ask, calculations in ownercreator.md — Factory patterns, aggregation rulescontroller.md — Use case handlers, thin controllerslow-coupling.md — Dependency injection, abstractionshigh-cohesion.md — Focused responsibilitiespolymorphism.md — Strategy pattern, type variationspure-fabrication.md — Repositories, specificationsindirection.md — Adapters, mediatorsprotected-variations.md — Stable interfacesantipatterns.md — Common GRASP violationsassets/report-template.md — GRASP audit report formatnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accProvides SOLID principles (SRP, OCP, LSP, ISP, DIP) reference for PHP 8.4 with bash detection patterns, examples, and violation signs for audits and reviews.
Reviews and refactors object-oriented code for SOLID compliance across PHP, Java, Python, TypeScript, and C++. Detects violations, suggests fixes, and explains trade-offs.
Detects anti-patterns and architectural debt in codebases, proposes patterns like GoF SOLID DDD CQRS Microservices Cloud, generates boilerplate code. For Next.js FastAPI NestJS Django Express Go.