core-pattern-finder
Core Pattern Finder
Search Drupal core for implementation patterns and return file references.
Activation
Activate when you detect:
- "How does core do X?"
- "Find core example of X"
- "Show me core's implementation of X"
- Need a reference implementation for a Drupal pattern
Quick Reference
Check these common patterns first before searching:
Forms
| Pattern | Path |
|---|---|
| ConfigFormBase | core/modules/system/src/Form/SiteInformationForm.php |
| FormBase | core/modules/node/src/Form/NodeForm.php |
| ConfirmFormBase | core/modules/node/src/Form/NodeDeleteForm.php |
| EntityForm | core/modules/user/src/ProfileForm.php |
Entities
| Pattern | Path |
|---|---|
| Content Entity | core/modules/node/src/Entity/Node.php |
| Config Entity | core/modules/field/src/Entity/FieldConfig.php |
| Entity List Builder | core/modules/node/src/NodeListBuilder.php |
Services
| Pattern | Path |
|---|---|
| Entity Type Manager | core/lib/Drupal/Core/Entity/EntityTypeManager.php |
| Plugin Manager | core/lib/Drupal/Core/Block/BlockManager.php |
| Event Subscriber | core/modules/system/src/EventSubscriber/ConfigCacheTag.php |
Plugins
| Pattern | Path |
|---|---|
| Block Plugin | core/modules/system/src/Plugin/Block/SystemBrandingBlock.php |
| Field Formatter | core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php |
| Field Widget | core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php |
| Condition Plugin | core/modules/system/src/Plugin/Condition/RequestPath.php |
Controllers
| Pattern | Path |
|---|---|
| ControllerBase | core/modules/system/src/Controller/SystemController.php |
| Entity Controller | core/modules/node/src/Controller/NodeController.php |
Workflow
1. Check Quick Reference
If pattern matches table above, return that path immediately.
2. Search Core
If not in quick reference, search using these strategies:
For class/interface patterns:
Use Grep with pattern: "class {PatternName}" or "interface {PatternName}"
Path: core/
For specific implementations:
Use Grep with pattern: "extends {BaseClass}" or "implements {Interface}"
Path: core/modules/
For service patterns:
Use Glob with pattern: core/modules/*/src/*Manager.php
or: core/lib/Drupal/Core/*/*.php
3. Read and Extract Key Sections
Once file found, use Read tool and identify:
- Key methods to study
- Relevant line numbers
- Dependencies injected
4. Return Structured Response
Format your response as:
## Core Pattern: {Pattern Name}
### Primary Example
`{file_path}`
**Key methods:**
- `{method1}()` (line {X}): {what it does}
- `{method2}()` (line {Y}): {what it does}
**Dependencies:**
- {service_name}: {purpose}
### Additional Examples
- `{path2}` - {variation description}
- `{path3}` - {variation description}
### Usage Notes
{Any gotchas or important considerations}
Stop Points
STOP and ask user:
- If pattern is ambiguous (multiple interpretations)
- If no matching pattern found in core
- Before reading more than 3 files (ask which to prioritize)
More from camoa/claude-skills
html-generator
Use when generating branded HTML pages and components from a design system. Creates standalone HTML components and composes them into full pages with embedded CSS, responsive design, and brand integration.
43memory-manager
Use after completing any phase activity - updates project_state.md, project registry, ensures files are in correct locations, maintains lean memory
39diagram-generator
Use when visualizing architecture - generates Mermaid diagrams for data flow, service relationships, or entity structures. Trigger: 'draw diagram', 'visualize', 'show relationships', 'mermaid chart'.
31code-quality-audit
Use when checking code quality, running security audits, testing coverage, finding SOLID/DRY violations, or setting up quality tools. Use when user says "audit this code", "check security", "run PHPStan", "code quality", "find violations", "SOLID check", "DRY check", "test coverage", "lint this", "security review", "is this production ready", "check for vulnerabilities", "code review", "grade this code". Supports Drupal (PHPStan, PHPMD, Psalm, Semgrep, Trivy, Gitleaks via DDEV) and Next.js (ESLint, Jest, Semgrep, Trivy, Gitleaks). Use proactively before deployment or after significant code changes.
20requirements-gatherer
Use when gathering project requirements - asks structured questions about project type, scope, integrations, and constraints to populate project_state.md
17generating-infographics
Use when creating infographics, data visualizations, process diagrams, timelines, or comparisons - generates branded infographics using @antv/infographic with 114 templates across 7 categories. Triggers on "create infographic", "make infographic", "visualize data", "timeline", "process diagram".
17