grasp-knowledge
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "grasp-knowledge" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-893649d7b6f3f5bf77076d2ebeeb258aba18da71103f7d440916cac7b29af388. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
A GRASP principles knowledge base for PHP 8.4. Provides a quick reference for nine responsibility-assignment patterns: Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, and Protected Variations, for use in architecture audits and design decisions.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- GRASP principles knowledge base for PHP 8.4 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.
- Testing
- Not tested
Browse files
Frontmatter
name: grasp-knowledge
description: GRASP principles knowledge base for PHP 8.4 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.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
# 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
# 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
# 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
# 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
# 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.4 Examples
Information Expert
// 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
// 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
// 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 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 violations
Assets
assets/report-template.md— GRASP audit report format
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 GRASP 原则的完整知识库,涵盖 9 种职责分配模式
- 包含 PHP 8.4 代码示例和检测模式,实用性强
- 集成 DDD 应用场景,提升架构设计价值
Areas to improve
-
Description in the wrong location Reported severity: Minor
frontmatter 中有 description,但缺少 when_to_use 字段,用户难以明确触发条件
Recommendation: 在 frontmatter 中添加 when_to_use 字段,或在 skill_body 顶部添加 When to Use 章节
Highlights
- description 内容清晰,明确说明适用于 PHP 8.4 项目的 GRASP 原则
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
文档结构完整但缺少 When to Use 章节,影响用户快速理解使用场景
Recommendation: 在 Overview 后添加 When to Use 章节,说明适用场景和触发条件
Highlights
- 文档结构清晰,包含多个实用章节和代码示例
- frontmatter 完整,表格和代码块格式规范
Areas to improve
-
Missing referenced files Reported severity: Major
skill_body 中引用了 references/*.md 和 assets/report-template.md 文件,但未提供这些文件
Recommendation: 补充所有被引用的文件,或移除引用说明
Highlights
- 知识库内容完整,无需外部依赖即可使用
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.