acc-grasp-knowledge

GRASP principles knowledge base for PHP 8.5 projects. Provides quick reference for 9 responsibility assignment patterns (Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, Protected Variations). Use for architecture audits and design decisions.

16 stars

Best use case

acc-grasp-knowledge is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

GRASP principles knowledge base for PHP 8.5 projects. Provides quick reference for 9 responsibility assignment patterns (Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, Protected Variations). Use for architecture audits and design decisions.

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

Manual Installation

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

How acc-grasp-knowledge Compares

Feature / Agentacc-grasp-knowledgeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

GRASP principles knowledge base for PHP 8.5 projects. Provides quick reference for 9 responsibility assignment patterns (Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, Protected Variations). Use for architecture audits and design decisions.

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

# GRASP Principles Knowledge Base

## Overview

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 |

## Quick Detection Patterns

### Information Expert Violations

```bash
# 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.

### Creator Violations

```bash
# Random creation locations
Grep: "new\s\+[A-Z][a-z]*[A-Z]" --glob "**/*.php"
```

**Signs:** Objects created in unexpected places, no clear creation ownership.

### Controller Violations

```bash
# 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.

### Low Coupling Violations

```bash
# 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.

### High Cohesion Violations

```bash
# 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.

## Quick PHP 8.5 Examples

### Information Expert

```php
// 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(),
        );
    }
}
```

### Low Coupling

```php
// 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,
    ) {}
}
```

### High Cohesion

```php
// 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 Integration

| 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 |

## References

For detailed patterns and examples, see `references/`:
- `information-expert.md` — Tell Don't Ask, calculations in owner
- `creator.md` — Factory patterns, aggregation rules
- `controller.md` — Use case handlers, thin controllers
- `low-coupling.md` — Dependency injection, abstractions
- `high-cohesion.md` — Focused responsibilities
- `polymorphism.md` — Strategy pattern, type variations
- `pure-fabrication.md` — Repositories, specifications
- `indirection.md` — Adapters, mediators
- `protected-variations.md` — Stable interfaces
- `antipatterns.md` — Common GRASP violations

## Assets

- `assets/report-template.md` — GRASP audit report format

Related Skills

acc-psr-autoloading-knowledge

16
from diegosouzapw/awesome-omni-skill

PSR-4 autoloading standard knowledge base for PHP 8.5 projects. Provides quick reference for namespace-to-path mapping, composer.json configuration, directory structure, and common mistakes. Use for autoloading audits and project structure reviews.

acc-layer-arch-knowledge

16
from diegosouzapw/awesome-omni-skill

Layered Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for traditional N-tier/Layered Architecture audits.

acc-clean-arch-knowledge

16
from diegosouzapw/awesome-omni-skill

Clean Architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Clean Architecture and Hexagonal Architecture audits.

acc-claude-code-knowledge

16
from diegosouzapw/awesome-omni-skill

Knowledge base for Claude Code formats and patterns. Use when creating or improving commands, agents, skills, or hooks.

acc-adr-knowledge

16
from diegosouzapw/awesome-omni-skill

Action-Domain-Responder pattern knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for ADR (web-specific MVC alternative) audits.

ant-design-knowledge-base

16
from diegosouzapw/awesome-omni-skill

Provides comprehensive answers about Ant Design components, documentation, and semantic descriptions using local knowledge base files. Use when asked about Ant Design, React UI components, design system, component semantics, or specific component usage.

acc-ddd-knowledge

16
from diegosouzapw/awesome-omni-skill

DDD architecture knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Domain-Driven Design audits.

openai-knowledge

16
from diegosouzapw/awesome-omni-skill

Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.

acc-diagram-knowledge

16
from diegosouzapw/awesome-omni-skill

Diagram knowledge base. Provides Mermaid syntax, C4 model, diagram types, and best practices for technical diagrams.

ac-knowledge-graph

16
from diegosouzapw/awesome-omni-skill

Manage knowledge graph for autonomous coding. Use when storing relationships, querying connected knowledge, building project understanding, or maintaining semantic memory.

adr-knowledge-base

16
from diegosouzapw/awesome-omni-skill

ADR知見の体系的参照・適用。主要ADR抜粋(ADR_010, 013, 016, 019, 020, 021)・ADR検索・参照方法・技術決定パターン集・ADR作成判断基準。Phase C以降の技術決定時に使用。

Knowledge

16
from diegosouzapw/awesome-omni-skill

Personal knowledge management using Graphiti knowledge graph with Neo4j/FalkorDB, supporting remote MCP access with connection profiles and TLS, OSINT/CTI ontology, and investigative search. USE WHEN 'store this', 'remember this', 'add to knowledge', 'search my knowledge', 'what do I know about', 'find in knowledge base', 'save to memory', 'graphiti', 'knowledge graph', 'entity extraction', 'relationship mapping', 'semantic search', 'episode', 'install knowledge', 'setup knowledge system', 'configure knowledge graph', 'remote knowledge server', 'connect to knowledge', 'knowledge profile', knowledge capture, retrieval, synthesis, memory decay, decay scoring, lifecycle state, importance classification, stability classification, health metrics, run maintenance, permanent memory, soft-delete, 'investigate entity', 'find connections', 'graph traversal', 'threat hunting', 'list ontology', 'custom entity types', 'CTI entities', 'OSINT entities', 'import STIX', 'STIX bundle', 'threat intel import'.