@mohammadhprp/system-prompt 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/framework/commands/README.md +1 -1
- package/framework/commands/review.md +1 -1
- package/framework/mcps/README.md +0 -1
- package/framework/plugins/ponytail/README.md +0 -1
- package/framework/plugins/ponytail/capabilities.md +1 -1
- package/framework/references/standards/api.md +0 -1
- package/framework/references/standards/architecture.md +0 -1
- package/framework/references/standards/database.md +0 -1
- package/framework/references/standards/debugging.md +0 -1
- package/framework/references/standards/documentation.md +0 -1
- package/framework/references/standards/logging.md +0 -1
- package/framework/references/standards/naming.md +0 -1
- package/framework/references/standards/observability.md +0 -1
- package/framework/references/standards/performance.md +0 -1
- package/framework/references/standards/pull-requests.md +0 -1
- package/framework/references/standards/security.md +0 -1
- package/framework/references/standards/testing.md +0 -1
- package/framework/skills/README.md +1 -12
- package/framework/skills/improve/SKILL.md +1 -3
- package/framework/skills/improve/examples.md +1 -1
- package/framework/skills/laravel-best-practices/SKILL.md +56 -216
- package/framework/skills/laravel-best-practices/references/architecture.md +1 -1
- package/framework/skills/laravel-best-practices/references/checklist.md +139 -0
- package/framework/skills/laravel-best-practices/references/eloquent.md +4 -2
- package/framework/skills/laravel-best-practices/references/infer-conventions.md +97 -0
- package/framework/skills/laravel-best-practices/references/pest-testing.md +47 -18
- package/framework/skills/laravel-best-practices/references/security.md +1 -1
- package/framework/skills/laravel-best-practices/references/style.md +1 -1
- package/framework/skills/laravel-best-practices/references/tailwindcss.md +0 -1
- package/package.json +1 -1
- package/src/catalog.js +1 -13
- package/framework/mcps/notion-mcp/README.md +0 -57
- package/framework/mcps/notion-mcp/capabilities.md +0 -118
- package/framework/mcps/notion-mcp/configs/opencode.json +0 -9
- package/framework/mcps/notion-mcp/install.md +0 -70
- package/framework/mcps/notion-mcp/troubleshooting.md +0 -95
- package/framework/skills/brainstorming/SKILL.md +0 -159
- package/framework/skills/brainstorming/examples.md +0 -49
- package/framework/skills/brainstorming/scripts/frame-template.html +0 -213
- package/framework/skills/brainstorming/scripts/helper.js +0 -167
- package/framework/skills/brainstorming/scripts/server.cjs +0 -723
- package/framework/skills/brainstorming/scripts/start-server.sh +0 -209
- package/framework/skills/brainstorming/scripts/stop-server.sh +0 -120
- package/framework/skills/brainstorming/visual-companion.md +0 -291
- package/framework/skills/code-review/SKILL.md +0 -72
- package/framework/skills/code-review/examples.md +0 -31
- package/framework/skills/codenavi/SKILL.md +0 -306
- package/framework/skills/codenavi/examples.md +0 -33
- package/framework/skills/codenavi/references/coding-principles.md +0 -143
- package/framework/skills/codenavi/references/notebook-spec.md +0 -171
- package/framework/skills/create-adr/SKILL.md +0 -429
- package/framework/skills/create-adr/examples.md +0 -35
- package/framework/skills/design/SKILL.md +0 -399
- package/framework/skills/design/examples.md +0 -34
- package/framework/skills/great-interface/SKILL.md +0 -43
- package/framework/skills/great-interface/references/animations.md +0 -205
- package/framework/skills/great-interface/references/better-accessibility.md +0 -106
- package/framework/skills/great-interface/references/better-colors.md +0 -100
- package/framework/skills/great-interface/references/better-interface.md +0 -132
- package/framework/skills/great-interface/references/better-layout.md +0 -76
- package/framework/skills/great-interface/references/better-typography.md +0 -157
- package/framework/skills/great-interface/references/better-ui.md +0 -107
- package/framework/skills/great-interface/references/better-writing.md +0 -109
- package/framework/skills/great-interface/references/choosing-fonts.md +0 -64
- package/framework/skills/great-interface/references/color-formats.md +0 -90
- package/framework/skills/great-interface/references/color-usage.md +0 -118
- package/framework/skills/great-interface/references/contrast.md +0 -79
- package/framework/skills/great-interface/references/css-cheat-sheet.md +0 -65
- package/framework/skills/great-interface/references/details-and-accessibility.md +0 -119
- package/framework/skills/great-interface/references/enter-exit.md +0 -147
- package/framework/skills/great-interface/references/explain-interface.md +0 -126
- package/framework/skills/great-interface/references/find-the-effect.md +0 -94
- package/framework/skills/great-interface/references/focus-and-keyboard.md +0 -131
- package/framework/skills/great-interface/references/forms.md +0 -84
- package/framework/skills/great-interface/references/from-an-image.md +0 -55
- package/framework/skills/great-interface/references/grouping-and-alignment.md +0 -123
- package/framework/skills/great-interface/references/hit-areas.md +0 -94
- package/framework/skills/great-interface/references/icon-transitions.md +0 -102
- package/framework/skills/great-interface/references/icons.md +0 -110
- package/framework/skills/great-interface/references/interface-review.md +0 -148
- package/framework/skills/great-interface/references/motion-and-zoom.md +0 -79
- package/framework/skills/great-interface/references/no-browser.md +0 -73
- package/framework/skills/great-interface/references/palette-generation.md +0 -104
- package/framework/skills/great-interface/references/palette-structure.md +0 -76
- package/framework/skills/great-interface/references/performance.md +0 -88
- package/framework/skills/great-interface/references/picker.md +0 -76
- package/framework/skills/great-interface/references/read-the-system.md +0 -178
- package/framework/skills/great-interface/references/removed-signals.md +0 -38
- package/framework/skills/great-interface/references/review-format.md +0 -46
- package/framework/skills/great-interface/references/scope-resolution.md +0 -88
- package/framework/skills/great-interface/references/screen-readers.md +0 -101
- package/framework/skills/great-interface/references/semantics-and-aria.md +0 -84
- package/framework/skills/great-interface/references/spacing-and-adaptivity.md +0 -159
- package/framework/skills/great-interface/references/spacing-and-sizing.md +0 -121
- package/framework/skills/great-interface/references/surfaces.md +0 -219
- package/framework/skills/great-interface/references/token-naming.md +0 -97
- package/framework/skills/great-interface/references/variable-fonts-and-opentype.md +0 -105
- package/framework/skills/great-interface/references/variant.md +0 -104
- package/framework/skills/great-interface/references/wrapping-and-punctuation.md +0 -55
- package/framework/skills/learning-opportunities/SKILL.md +0 -140
- package/framework/skills/learning-opportunities/examples.md +0 -34
- package/framework/skills/learning-opportunities/references/PRINCIPLES.md +0 -42
- package/framework/skills/notion-mcp/SKILL.md +0 -57
- package/framework/skills/notion-mcp/examples.md +0 -31
- package/framework/skills/notion-mcp/references/comments.md +0 -112
- package/framework/skills/notion-mcp/references/databases.md +0 -193
- package/framework/skills/notion-mcp/references/pages.md +0 -235
- package/framework/skills/spec-driven-eval/SKILL.md +0 -341
- package/framework/skills/spec-driven-eval/examples.md +0 -35
- package/framework/skills/spec-driven-eval/references/quickstart.md +0 -118
- package/framework/skills/spec-driven-eval/references/reference.md +0 -295
- package/framework/skills/technical-design-doc-creator/README.md +0 -411
- package/framework/skills/technical-design-doc-creator/SKILL.md +0 -1484
- package/framework/skills/technical-design-doc-creator/examples.md +0 -35
- package/framework/skills/web-design-guidelines/SKILL.md +0 -65
- package/framework/skills/web-design-guidelines/examples.md +0 -32
- package/framework/skills/web-design-guidelines/references/guideline.md +0 -174
|
@@ -14,7 +14,7 @@ Commands define repeatable workflows that agents execute on demand, triggered by
|
|
|
14
14
|
| [`/pr`](./pr.md) | Create a GitHub PR for the current branch. | pull-requests standard |
|
|
15
15
|
| [`/mr`](./mr.md) | Create a GitLab MR for the current branch. | pull-requests standard |
|
|
16
16
|
| [`/release`](./release.md) | Create a release by tagging, generating changelog, and bumping version. | — |
|
|
17
|
-
| [`/review`](./review.md) | Perform comprehensive code quality review. |
|
|
17
|
+
| [`/review`](./review.md) | Perform comprehensive code quality review. | naming/testing/security/performance standards |
|
|
18
18
|
| [`/summarize-changes`](./summarize-changes.md) | Summarize uncommitted changes and flag risky patterns. | — |
|
|
19
19
|
|
|
20
20
|
## Command Entry Structure
|
|
@@ -9,7 +9,7 @@ Perform comprehensive code quality review.
|
|
|
9
9
|
|
|
10
10
|
## Process
|
|
11
11
|
|
|
12
|
-
1. **Review conversation and diff** - Read conversation history, run `git diff` for staged/unstaged changes, identify the problem being solved and the behavior being modified.
|
|
12
|
+
1. **Review conversation and diff** - Read conversation history, run `git diff` for staged/unstaged changes, identify the problem being solved and the behavior being modified. Read related standards: [`references/standards/naming.md`](../references/standards/naming.md), [`references/standards/testing.md`](../references/standards/testing.md), [`references/standards/security.md`](../references/standards/security.md), [`references/standards/performance.md`](../references/standards/performance.md).
|
|
13
13
|
|
|
14
14
|
2. **Check correctness** - Edge cases, concurrency, error handling, state transitions, backward compatibility. Read contracts and interfaces before implementation.
|
|
15
15
|
|
package/framework/mcps/README.md
CHANGED
|
@@ -11,7 +11,6 @@ This catalog is framework-agnostic: each entry documents what the server does, w
|
|
|
11
11
|
| [Excalidraw MCP](./excalidraw/README.md) | Stream hand-drawn Excalidraw diagrams with interactive fullscreen editing — architecture diagrams, flowcharts, wireframes. | Any project that benefits from visual diagrams, architecture visualization, or design sketching. |
|
|
12
12
|
| [Figma MCP Go](./figma-mcp-go/README.md) | Full read/write access to Figma designs via plugin bridge — no API token or rate limits. | Any project that works with Figma designs. |
|
|
13
13
|
| [Laravel Boost](./laravel-boost/README.md) | Gives AI agents Laravel application context, Laravel ecosystem documentation search, and safe local inspection tools. | Laravel applications. |
|
|
14
|
-
| [Notion MCP](./notion-mcp/README.md) | Search, read, and write content in a Notion workspace — pages, databases, views, comments, and more via remote HTTP MCP. | Any project that uses Notion for documentation, tracking, or collaboration. |
|
|
15
14
|
| [Playwright MCP](./playwright-mcp/README.md) | Cross-browser automation via accessibility snapshots — navigate, click, type, screenshot, evaluate, network control, storage management. | Any project needing browser automation or end-to-end testing. |
|
|
16
15
|
| [Supabase MCP](./supabase-mcp/README.md) | Manage Supabase projects, query databases, design schema, run migrations, deploy Edge Functions, manage Auth/Storage/Realtime, and search docs. | Any project using Supabase as backend. |
|
|
17
16
|
|
|
@@ -39,6 +39,5 @@ Avoid when the task explicitly needs complex scaffolding, heavy abstractions, or
|
|
|
39
39
|
|
|
40
40
|
Relevant skills in this repository:
|
|
41
41
|
|
|
42
|
-
- [`code-review`](../../skills/code-review/SKILL.md): review backend changes for correctness and maintainability, complementary to ponytail's over-engineering focus.
|
|
43
42
|
- [`backend-best-practices`](../../skills/backend-best-practices/SKILL.md): backend best practices for refactoring and behavior-preserving cleanup.
|
|
44
43
|
- [`pr`](../../commands/pr.md): prepare small, reviewable changes aligned with ponytail's minimal-diff philosophy.
|
|
@@ -90,7 +90,7 @@ Or in `~/.config/ponytail/config.json` (`%APPDATA%\ponytail\config.json` on Wind
|
|
|
90
90
|
- Use `/ponytail-review` after a coding session to catch over-engineering the agent missed.
|
|
91
91
|
- Mark intentional shortcuts with `ponytail:` comments naming the ceiling and upgrade path.
|
|
92
92
|
- Review `/ponytail-debt` regularly to track deferred improvements.
|
|
93
|
-
- Pair with
|
|
93
|
+
- Pair with the `/pr` command for a complete quality workflow.
|
|
94
94
|
|
|
95
95
|
## Common Workflows
|
|
96
96
|
|
|
@@ -10,34 +10,23 @@ This catalog is framework-agnostic: each skill defines when to activate, a step-
|
|
|
10
10
|
| --- | --- | --- |
|
|
11
11
|
| [agent-browser](./agent-browser/SKILL.md) | Automate browser and Electron workflows for navigation, testing, screenshots, and data extraction. | Website interaction, browser automation, exploratory testing, QA, and Electron desktop app workflows. |
|
|
12
12
|
| [backend-best-practices](./backend-best-practices/SKILL.md) | Consolidated backend engineering practices for API design, architecture, data, security, testing, observability, performance, debugging, and refactoring. | Any backend task that benefits from structured domain guidance across multiple backend disciplines. |
|
|
13
|
-
| [brainstorming](./brainstorming/SKILL.md) | Turn ideas into fully formed designs and specs through collaborative dialogue before any implementation. | Starting a new feature, component, or project; any work that benefits from design before code. |
|
|
14
|
-
| [code-review](./code-review/SKILL.md) | Review backend changes for correctness, readability, maintainability, tests, performance, and security. | Reviewing pull requests, evaluating code quality, or mentoring. |
|
|
15
|
-
| [codenavi](./codenavi/SKILL.md) | Investigate unfamiliar codebases with precision, implement surgically, and keep a `.notebook/` knowledge base that grows across sessions. | Fixing bugs, implementing features, refactoring, or investigating flows in unfamiliar territory. |
|
|
16
|
-
| [create-adr](./create-adr/SKILL.md) | Create Architecture Decision Records (ADRs) that capture the context, decision, and consequences of significant architectural choices. | Documenting a finalized technical decision, or recording why a choice was made for future team members. |
|
|
17
|
-
| [design-like-damien](./design/SKILL.md) | Apply premium, editorial-quality UI design philosophy and Lovable prompting system to produce interfaces that never look “AI-generated.” | Building apps, landing pages, or dashboards in Lovable; UI/UX design for premium SaaS, dark mode, typography, and scroll animations. |
|
|
18
13
|
| [diagram-design](./diagram-design/SKILL.md) | Create technical and product diagrams as standalone HTML files with inline SVG and an opinionated editorial design system. | Architecture, data, process, and other diagrams that communicate more clearly than prose or tables. |
|
|
19
14
|
| [docs-writer](./docs-writer/SKILL.md) | Write, review, and edit documentation files with consistent structure, tone, and technical accuracy. | Creating docs, reviewing markdown files, writing READMEs, or updating `/docs` directories. |
|
|
20
15
|
| [effective-html](./effective-html/SKILL.md) | Create self-contained HTML artifacts with routed guidance for design, wireframes, prototypes, plans, and diagrams. | Standalone HTML reports, explainers, interfaces, wireframes, prototypes, plans, and diagrams. |
|
|
21
16
|
| [find-skills](./find-skills/SKILL.md) | Discover, evaluate, and install skills from the open agent skills ecosystem. | Finding an installable skill for a specialized task or extending an agent's capabilities. |
|
|
22
17
|
| [frontend-design](./frontend-design/SKILL.md) | Distinctive, intentional visual design for new UI or reshaping existing UI — aesthetic direction, typography, and choices that don't read as templated defaults. | Building new interfaces, reshaping existing UI, or escaping generic AI-generated design looks. |
|
|
23
18
|
| [glab](./glab/SKILL.md) | Use the GitLab CLI (glab) to manage merge requests, issues, pipelines, and repositories from the command line. | Any project hosted on GitLab (SaaS or self-hosted). |
|
|
24
|
-
| [great-interface](./great-interface/SKILL.md) | Build, explain, review, and refine product interfaces across accessibility, layout, writing, typography, color, and UI polish. | Creating frontend interfaces, reviewing interface quality, explaining interface behavior, or comparing UI directions. |
|
|
25
19
|
| [humanizer](./humanizer/SKILL.md) | Remove signs of AI-generated writing from text — inflated importance, promotional language, em dash overuse, rule of three, AI vocabulary, and filler phrases. | Editing or reviewing prose to make it sound more natural and human-written. |
|
|
26
20
|
| [improve](./improve/SKILL.md) | Audit repositories as a read-only senior advisor and produce prioritized implementation plans for another agent. | Repository-wide audits, improvement roadmaps, and implementation handoffs. |
|
|
27
21
|
| [jira-cli](./jira-cli/SKILL.md) | Use the Jira CLI (jira) to manage issues, sprints, epics, comments, transitions, and worklogs from the command line. | Any project using Jira (Cloud or self-hosted) for issue tracking. |
|
|
28
22
|
| [laravel-best-practices](./laravel-best-practices/SKILL.md) | Apply Laravel PHP patterns for Eloquent, validation, security, testing, caching, and architecture. | Writing, reviewing, or refactoring Laravel PHP code. |
|
|
29
|
-
| [learning-opportunities](./learning-opportunities/SKILL.md) | Facilitate deliberate skill development during AI-assisted coding with short, optional interactive exercises. | After architectural work, schema changes, refactors, or when the user asks to understand code better. |
|
|
30
|
-
| [notion-mcp](./notion-mcp/SKILL.md) | Work with the Notion MCP server tools for pages, databases, comments, search, and workspace management. | Any project that uses Notion for documentation, tracking, or collaboration. |
|
|
31
23
|
| [perf-web-optimization](./perf-web-optimization/SKILL.md) | Optimize web performance: bundle size, images, caching, lazy loading, and overall page speed. | A slow site, large bundles, layout shifts, poor Time to Interactive, or low Lighthouse scores. |
|
|
32
24
|
| [security-best-practices](./security-best-practices/SKILL.md) | Perform language- and framework-specific security best-practice reviews and suggest improvements, with support for Python, JavaScript/TypeScript, and Go. | Explicit security reviews or reports, secure-by-default coding, or auditing existing code for major vulnerabilities. |
|
|
33
25
|
| [sentry](./sentry/SKILL.md) | Inspect Sentry issues, summarize production errors, and pull health data via the Sentry API (read-only). | Checking production errors, summarizing recent crashes, or pulling a production error report. |
|
|
34
26
|
| [show-me](./show-me/SKILL.md) | Help the user understand the current topic visually with concise diagrams, code-shape sketches, and focused HTML artifacts. | Explaining logic, control flow, UI structure, file responsibility, or data flow with the smallest useful visual. |
|
|
35
27
|
| [skill-creator](./skill-creator/SKILL.md) | Create new skills, modify and improve existing skills, and measure skill performance. | Designing new skills, optimizing existing skills, or running evals. |
|
|
36
|
-
| [spec-driven-eval](./spec-driven-eval/SKILL.md) | Score how completely an implementation fulfills a PRD/spec, case by case, producing a single comparable final grade. | Benchmarking spec-driven implementations, grading acceptance criteria, or auditing implementation and test coverage against a spec. |
|
|
37
|
-
| [technical-design-doc-creator](./technical-design-doc-creator/SKILL.md) | Create comprehensive Technical Design Documents (TDDs) with mandatory and optional sections through interactive discovery, in the user's language. | Writing a design doc, TDD, technical spec, or architecture document before implementing a significant change. |
|
|
38
28
|
| [tlc-spec-driven](./tlc-spec-driven/SKILL.md) | Feature planning and implementation with adaptive phases, EARS testable requirements, atomic Conventional Commits, and independent verification. | Planning features, implementing with verification and atomic commits, or validating an implementation against a spec. |
|
|
39
29
|
| [taste](./taste/SKILL.md) | Unified design-quality skill spanning anti-slop frontend design, image generation and image-to-code, brand kits, minimalist and industrial UI, redesigns, and Google Stitch design systems. | Landing pages, portfolios, redesigns, website/mobile/brand imagery, or any UI that must not look AI-generated. |
|
|
40
|
-
| [web-design-guidelines](./web-design-guidelines/SKILL.md) | Review UI code for Web Interface Guidelines compliance — accessibility, focus, forms, animation, typography, and interaction patterns. | Reviewing UI, checking accessibility, auditing design or UX, or checking a site against best practices. |
|
|
41
30
|
|
|
42
31
|
## How Skills Are Organized
|
|
43
32
|
|
|
@@ -60,7 +49,7 @@ Use the skill table above to find the entry closest to the task at hand. Skills
|
|
|
60
49
|
Before activating a skill, check:
|
|
61
50
|
|
|
62
51
|
- **Fit**: does the skill's purpose match the current task?
|
|
63
|
-
- **Scope**: some skills are general
|
|
52
|
+
- **Scope**: some skills are general, others are narrow (Laravel Best Practices).
|
|
64
53
|
- **Combination**: complex tasks may need multiple skills (e.g., API Design + Security + Testing).
|
|
65
54
|
- **Sequence**: some skills are best used in order (e.g., Architecture Review before Database Design).
|
|
66
55
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: improve
|
|
3
|
-
description: Audit an entire repository as a read-only senior advisor, identify evidence-backed bugs, security risks, performance issues, test gaps, technical debt, DX/docs problems, and grounded roadmap opportunities, then produce prioritized handoff plans for another agent. Use for repository-wide audits, improvement roadmaps, and implementation planning from existing code. Do not use for reviewing a specific diff or pull request
|
|
3
|
+
description: Audit an entire repository as a read-only senior advisor, identify evidence-backed bugs, security risks, performance issues, test gaps, technical debt, DX/docs problems, and grounded roadmap opportunities, then produce prioritized handoff plans for another agent. Use for repository-wide audits, improvement roadmaps, and implementation planning from existing code. Do not use for reviewing a specific diff or pull request, security-only audits (use security-best-practices), documentation-only edits (use docs-writer), greenfield feature design or implementation (use tlc-spec-driven), or creating and evaluating agent skills (use skill-creator).
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
author: shadcn
|
|
@@ -28,10 +28,8 @@ The economics of this skill: an expensive, high-ceiling model does the part wher
|
|
|
28
28
|
|
|
29
29
|
Use this skill when the user wants a broad assessment of an existing repository or wants possible improvements prioritized across multiple engineering concerns. Keep the audit advisory and read-only; implementation belongs to a separate executor or to the skill that owns the narrower task.
|
|
30
30
|
|
|
31
|
-
- Review a specific diff, branch, or pull request with `code-review`.
|
|
32
31
|
- Perform a security-only assessment with `security-best-practices`.
|
|
33
32
|
- Edit or restructure documentation with `docs-writer`.
|
|
34
|
-
- Explore an unresolved product or UI direction with `brainstorming`.
|
|
35
33
|
- Specify or implement an approved feature with `tlc-spec-driven`.
|
|
36
34
|
- Create, evaluate, or optimize an agent skill with `skill-creator`.
|
|
37
35
|
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
|
|
17
17
|
**User:** Review the changes in my pull request for authorization bugs and missing tests.
|
|
18
18
|
|
|
19
|
-
**Expected behavior:** Do not use `improve` for this narrow diff review.
|
|
19
|
+
**Expected behavior:** Do not use `improve` for this narrow diff review. Decline the broad audit and review the pull request directly, combining it with `security-best-practices` when a security-only review is explicitly requested.
|
|
@@ -1,229 +1,69 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: laravel-best-practices
|
|
3
|
-
description: "Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code."
|
|
4
|
-
|
|
3
|
+
description: "Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns."
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: laravel
|
|
5
7
|
---
|
|
6
8
|
|
|
7
9
|
# Laravel Best Practices
|
|
8
10
|
|
|
9
|
-
Best practices for Laravel,
|
|
11
|
+
Best practices for Laravel, organized as an index of reference files. Each reference file teaches what to do and why. For exact API syntax, verify with `search-docs`.
|
|
10
12
|
|
|
11
13
|
## Consistency First
|
|
12
14
|
|
|
13
|
-
Before applying any
|
|
15
|
+
Before applying any reference, check what the application already does. Laravel offers multiple valid approaches, and the best choice is the one the codebase already uses, even if another pattern would be theoretically better. Inconsistency is worse than a suboptimal pattern.
|
|
14
16
|
|
|
15
|
-
Check sibling files, related controllers, models, or tests for established patterns. If one exists, follow it
|
|
16
|
-
|
|
17
|
-
## Quick Reference
|
|
18
|
-
|
|
19
|
-
### 1. Database Performance → `references/db-performance.md`
|
|
20
|
-
|
|
21
|
-
- Eager load with `with()` to prevent N+1 queries
|
|
22
|
-
- Enable `Model::preventLazyLoading()` in development
|
|
23
|
-
- Select only needed columns, avoid `SELECT *`
|
|
24
|
-
- `chunk()` / `chunkById()` for large datasets
|
|
25
|
-
- Index columns used in `WHERE`, `ORDER BY`, `JOIN`
|
|
26
|
-
- `withCount()` instead of loading relations to count
|
|
27
|
-
- `cursor()` for memory-efficient read-only iteration
|
|
28
|
-
- Never query in Blade templates
|
|
29
|
-
|
|
30
|
-
### 2. Advanced Query Patterns → `references/advanced-queries.md`
|
|
31
|
-
|
|
32
|
-
- `addSelect()` subqueries over eager-loading entire has-many for a single value
|
|
33
|
-
- Dynamic relationships via subquery FK + `belongsTo`
|
|
34
|
-
- Conditional aggregates (`CASE WHEN` in `selectRaw`) over multiple count queries
|
|
35
|
-
- `setRelation()` to prevent circular N+1 queries
|
|
36
|
-
- `whereIn` + `pluck()` over `whereHas` for better index usage
|
|
37
|
-
- Two simple queries can beat one complex query
|
|
38
|
-
- Compound indexes matching `orderBy` column order
|
|
39
|
-
- Correlated subqueries in `orderBy` for has-many sorting (avoid joins)
|
|
40
|
-
|
|
41
|
-
### 3. Security → `references/security.md`, `references/passport.md`, `references/spatie-laravel-permission.md`
|
|
42
|
-
|
|
43
|
-
- Define `$fillable` or `$guarded` on every model, authorize every action via policies or gates
|
|
44
|
-
- No raw SQL with user input — use Eloquent or query builder
|
|
45
|
-
- `{{ }}` for output escaping, `@csrf` on all POST/PUT/DELETE forms, `throttle` on auth and API routes
|
|
46
|
-
- Validate MIME type, extension, and size for file uploads
|
|
47
|
-
- Never commit `.env`, use `config()` for secrets, `encrypted` cast for sensitive DB fields
|
|
48
|
-
|
|
49
|
-
### 4. Caching → `references/caching.md`
|
|
50
|
-
|
|
51
|
-
- `Cache::remember()` over manual get/put
|
|
52
|
-
- `Cache::flexible()` for stale-while-revalidate on high-traffic data
|
|
53
|
-
- `Cache::memo()` to avoid redundant cache hits within a request
|
|
54
|
-
- Cache tags to invalidate related groups
|
|
55
|
-
- `Cache::add()` for atomic conditional writes
|
|
56
|
-
- `once()` to memoize per-request or per-object lifetime
|
|
57
|
-
- `Cache::lock()` / `lockForUpdate()` for race conditions
|
|
58
|
-
- Failover cache stores in production
|
|
59
|
-
|
|
60
|
-
### 5. Eloquent Patterns → `references/eloquent.md`
|
|
61
|
-
|
|
62
|
-
- Correct relationship types with return type hints
|
|
63
|
-
- Local scopes for reusable query constraints
|
|
64
|
-
- Global scopes sparingly — document their existence
|
|
65
|
-
- Attribute casts in the `casts()` method
|
|
66
|
-
- Cast date columns, use Carbon instances in templates
|
|
67
|
-
- `whereBelongsTo($model)` for cleaner queries
|
|
68
|
-
- Never hardcode table names — use `(new Model)->getTable()` or Eloquent queries
|
|
69
|
-
|
|
70
|
-
### 6. Validation & Forms → `references/validation.md`
|
|
71
|
-
|
|
72
|
-
- Form Request classes, not inline validation
|
|
73
|
-
- Array notation `['required', 'email']` for new code; follow existing convention
|
|
74
|
-
- `$request->validated()` only — never `$request->all()`
|
|
75
|
-
- `Rule::when()` for conditional validation
|
|
76
|
-
- `after()` instead of `withValidator()`
|
|
77
|
-
|
|
78
|
-
### 7. Configuration → `references/config.md`
|
|
79
|
-
|
|
80
|
-
- `env()` only inside config files
|
|
81
|
-
- `App::environment()` or `app()->isProduction()`
|
|
82
|
-
- Config, lang files, and constants over hardcoded text
|
|
83
|
-
|
|
84
|
-
### 8. Testing Patterns → `references/testing.md`, `references/pest-testing.md`
|
|
85
|
-
|
|
86
|
-
- `LazilyRefreshDatabase` over `RefreshDatabase` for speed
|
|
87
|
-
- `assertModelExists()` over raw `assertDatabaseHas()`
|
|
88
|
-
- Factory states and sequences over manual overrides
|
|
89
|
-
- Use fakes (`Event::fake()`, `Exceptions::fake()`, etc.) — but always after factory setup, not before
|
|
90
|
-
- `recycle()` to share relationship instances across factories
|
|
91
|
-
|
|
92
|
-
### 9. Queue & Job Patterns → `references/queue-jobs.md`
|
|
93
|
-
|
|
94
|
-
- `retry_after` must exceed job `timeout`; use exponential backoff `[1, 5, 10]`
|
|
95
|
-
- `ShouldBeUnique` to prevent duplicates; `ShouldBeUniqueUntilProcessing` for early lock release
|
|
96
|
-
- Always implement `failed()`; with `retryUntil()`, set `$tries = 0`
|
|
97
|
-
- `RateLimited` middleware for external API calls; `Bus::batch()` for related jobs
|
|
98
|
-
- Horizon for complex multi-queue scenarios
|
|
99
|
-
|
|
100
|
-
### 10. Routing & Controllers → `references/routing.md`
|
|
101
|
-
|
|
102
|
-
- Implicit route model binding
|
|
103
|
-
- Scoped bindings for nested resources
|
|
104
|
-
- `Route::resource()` or `apiResource()`
|
|
105
|
-
- Methods under 10 lines — extract to actions/services
|
|
106
|
-
- Type-hint Form Requests for auto-validation
|
|
107
|
-
|
|
108
|
-
### 11. HTTP Client → `references/http-client.md`
|
|
109
|
-
|
|
110
|
-
- Explicit `timeout` and `connectTimeout` on every request
|
|
111
|
-
- `retry()` with exponential backoff for external APIs
|
|
112
|
-
- Check response status or use `throw()`
|
|
113
|
-
- `Http::pool()` for concurrent independent requests
|
|
114
|
-
- `Http::fake()` and `preventStrayRequests()` in tests
|
|
115
|
-
|
|
116
|
-
### 12. Events, Notifications & Mail → `references/events-notifications.md`, `references/mail.md`
|
|
117
|
-
|
|
118
|
-
- Event discovery over manual registration; `event:cache` in production
|
|
119
|
-
- `ShouldDispatchAfterCommit` / `afterCommit()` inside transactions
|
|
120
|
-
- Queue notifications and mailables with `ShouldQueue`
|
|
121
|
-
- On-demand notifications for non-user recipients
|
|
122
|
-
- `HasLocalePreference` on notifiable models
|
|
123
|
-
- `assertQueued()` not `assertSent()` for queued mailables
|
|
124
|
-
- Markdown mailables for transactional emails
|
|
125
|
-
|
|
126
|
-
### 13. Error Handling → `references/error-handling.md`
|
|
127
|
-
|
|
128
|
-
- `report()`/`render()` on exception classes or in `bootstrap/app.php` — follow existing pattern
|
|
129
|
-
- `ShouldntReport` for exceptions that should never log
|
|
130
|
-
- Throttle high-volume exceptions to protect log sinks
|
|
131
|
-
- `dontReportDuplicates()` for multi-catch scenarios
|
|
132
|
-
- Force JSON rendering for API routes
|
|
133
|
-
- Structured context via `context()` on exception classes
|
|
134
|
-
|
|
135
|
-
### 14. Task Scheduling → `references/scheduling.md`
|
|
136
|
-
|
|
137
|
-
- `withoutOverlapping()` on variable-duration tasks
|
|
138
|
-
- `onOneServer()` on multi-server deployments
|
|
139
|
-
- `runInBackground()` for concurrent long tasks
|
|
140
|
-
- `environments()` to restrict to appropriate environments
|
|
141
|
-
- `takeUntilTimeout()` for time-bounded processing
|
|
142
|
-
- Schedule groups for shared configuration
|
|
143
|
-
|
|
144
|
-
### 15. Architecture → `references/architecture.md`
|
|
145
|
-
|
|
146
|
-
- Single-purpose Action classes; dependency injection over `app()` helper
|
|
147
|
-
- Prefer official Laravel packages and follow conventions, don't override defaults
|
|
148
|
-
- Default to `ORDER BY id DESC` or `created_at DESC`; `mb_*` for UTF-8 safety
|
|
149
|
-
- `defer()` for post-response work; `Context` for request-scoped data; `Concurrency::run()` for parallel execution
|
|
150
|
-
|
|
151
|
-
### 16. Migrations → `references/migrations.md`
|
|
152
|
-
|
|
153
|
-
- Generate migrations with `php artisan make:migration`
|
|
154
|
-
- `constrained()` for foreign keys
|
|
155
|
-
- Never modify migrations that have run in production
|
|
156
|
-
- Add indexes in the migration, not as an afterthought
|
|
157
|
-
- Mirror column defaults in model `$attributes`
|
|
158
|
-
- Reversible `down()` by default; forward-fix migrations for intentionally irreversible changes
|
|
159
|
-
- One concern per migration — never mix DDL and DML
|
|
160
|
-
|
|
161
|
-
### 17. Collections → `references/collections.md`
|
|
162
|
-
|
|
163
|
-
- Higher-order messages for simple collection operations
|
|
164
|
-
- `cursor()` vs. `lazy()` — choose based on relationship needs
|
|
165
|
-
- `lazyById()` when updating records while iterating
|
|
166
|
-
- `toQuery()` for bulk operations on collections
|
|
167
|
-
|
|
168
|
-
### 18. Blade & Views → `references/blade-views.md`, `references/tailwindcss.md`
|
|
169
|
-
|
|
170
|
-
- `$attributes->merge()` in component templates
|
|
171
|
-
- Blade components over `@include`; `@pushOnce` for per-component scripts
|
|
172
|
-
- View Composers for shared view data
|
|
173
|
-
- `@aware` for deeply nested component props
|
|
174
|
-
|
|
175
|
-
### 19. Conventions & Style → `references/style.md`
|
|
176
|
-
|
|
177
|
-
- Follow Laravel naming conventions for all entities
|
|
178
|
-
- Prefer Laravel helpers (`Str`, `Arr`, `Number`, `Uri`, `Str::of()`, `$request->string()`) over raw PHP functions
|
|
179
|
-
- No JS/CSS in Blade, no HTML in PHP classes
|
|
180
|
-
- Code should be readable; comments only for config files
|
|
181
|
-
|
|
182
|
-
### 20. Feature Flags → `references/pennant.md`
|
|
183
|
-
|
|
184
|
-
- `Feature::define()` to define features with resolver callbacks
|
|
185
|
-
- `Feature::active()` / `@feature` Blade directive to check features
|
|
186
|
-
- Scope features to specific users/entities with `Feature::for()`
|
|
187
|
-
- `Feature::activate()` / `deactivate()` for runtime control
|
|
188
|
-
|
|
189
|
-
### 21. Monitoring → `references/pulse.md`
|
|
190
|
-
|
|
191
|
-
- Gate-protect the dashboard with `viewPulse` gate
|
|
192
|
-
- Configure built-in recorders in `config/pulse.php` (SlowQueries, SlowRequests, Exceptions, Queues, etc.)
|
|
193
|
-
- Redis ingest for production performance; run `pulse:work` to drain the stream
|
|
194
|
-
- Custom cards via Livewire components extending `Pulse\Card`
|
|
195
|
-
- `Pulse::filter()` to exclude entries; `Pulse::resolveAuthenticatedUserId()` for multi-model apps
|
|
196
|
-
- `pulse:check` daemon required for Servers card
|
|
197
|
-
|
|
198
|
-
### 22. Full-Text Search → `references/scout.md`
|
|
199
|
-
|
|
200
|
-
- Add `Searchable` trait to models for automatic index sync
|
|
201
|
-
- Choose engine: Database, Collection, Algolia, Meilisearch, Typesense
|
|
202
|
-
- `toSearchableArray()` to control indexed data; `searchableAs()` for custom index names
|
|
203
|
-
- `Model::search('query')->where(...)->paginate()` for search queries
|
|
204
|
-
- `scout:import` / `scout:flush` for index management; `scout:sync-index-settings` for engine config
|
|
205
|
-
- `Model::withoutSyncingToSearch()` / `SCOUT_DRIVER=null` for testing
|
|
206
|
-
|
|
207
|
-
### 23. Backup → `references/spatie-laravel-backup.md`
|
|
208
|
-
|
|
209
|
-
- Schedule `backup:run`, `backup:clean`, `backup:monitor` in console kernel
|
|
210
|
-
- Configure sources, destinations, notifications in `config/backup.php`
|
|
211
|
-
- Custom cleanup strategies extending `CleanupStrategy`
|
|
212
|
-
- Custom health checks extending `HealthCheck`
|
|
213
|
-
- Enable encryption and Gzip compression via config
|
|
214
|
-
|
|
215
|
-
### 24. Media Library → `references/spatie-medialibrary.md`
|
|
216
|
-
|
|
217
|
-
- Implement `HasMedia` interface + `InteractsWithMedia` trait on models
|
|
218
|
-
- `addMedia()` / `addMediaFromRequest()` for file uploads
|
|
219
|
-
- Media collections to organize related files per model
|
|
220
|
-
- Conversions for image processing (thumbnails, crops, etc.)
|
|
221
|
-
- Responsive images via conversion `withResponsiveImages()`
|
|
17
|
+
Check sibling files, related controllers, models, or tests for established patterns. If one exists, follow it. Don't introduce a second way. These references are defaults for when no pattern exists yet, not overrides.
|
|
222
18
|
|
|
223
19
|
## How to Apply
|
|
224
20
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
21
|
+
1. Check the changed files, nearby code, project configuration, and relevant tests for established patterns. Deviate only for a correctness or security defect, and call the deviation out.
|
|
22
|
+
2. Map every affected concern to the reference index below. Read each mapped reference file before editing. Skip unrelated reference files.
|
|
23
|
+
3. Make the smallest coherent change. Keep the application's architecture and naming instead of introducing a second pattern for the same job.
|
|
24
|
+
4. Verify version-sensitive Laravel APIs for the installed version with `search-docs`, or inspect the installed framework when it is unavailable.
|
|
25
|
+
5. Run the narrowest relevant tests first, then the project's formatting and static-analysis checks when the change warrants them.
|
|
26
|
+
6. Re-read the diff against every mapped reference before finishing.
|
|
27
|
+
|
|
28
|
+
## References Index
|
|
29
|
+
|
|
30
|
+
Cross-cutting changes often need more than one reference file.
|
|
31
|
+
|
|
32
|
+
| Concern | Read |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| Query count, eager loading, indexes, large datasets | [`references/db-performance.md`](references/db-performance.md) |
|
|
35
|
+
| Production monitoring, slow queries, exception dashboards | [`references/pulse.md`](references/pulse.md) |
|
|
36
|
+
| Subqueries, aggregates, complex ordering and query plans | [`references/advanced-queries.md`](references/advanced-queries.md) |
|
|
37
|
+
| Models, relationships, scopes, casts | [`references/eloquent.md`](references/eloquent.md) |
|
|
38
|
+
| Full-text search, indexing, searchable models | [`references/scout.md`](references/scout.md) |
|
|
39
|
+
| Authentication, authorization, input safety, secrets, uploads | [`references/security.md`](references/security.md) |
|
|
40
|
+
| OAuth2 servers, clients, token authentication | [`references/passport.md`](references/passport.md) |
|
|
41
|
+
| Roles and permissions with spatie/laravel-permission | [`references/spatie-laravel-permission.md`](references/spatie-laravel-permission.md) |
|
|
42
|
+
| Model media uploads, conversions, responsive images | [`references/spatie-medialibrary.md`](references/spatie-medialibrary.md) |
|
|
43
|
+
| Form Requests and validation references | [`references/validation.md`](references/validation.md) |
|
|
44
|
+
| Controllers, route binding, resources, middleware | [`references/routing.md`](references/routing.md) |
|
|
45
|
+
| Schema changes, columns, foreign keys, indexes | [`references/migrations.md`](references/migrations.md) |
|
|
46
|
+
| Jobs, retries, uniqueness, batches, Horizon | [`references/queue-jobs.md`](references/queue-jobs.md) |
|
|
47
|
+
| Cache lifetime, invalidation, locks, memoization | [`references/caching.md`](references/caching.md) |
|
|
48
|
+
| Outbound requests, retries, timeouts, fakes | [`references/http-client.md`](references/http-client.md) |
|
|
49
|
+
| Exceptions, reporting, rendering, log context | [`references/error-handling.md`](references/error-handling.md) |
|
|
50
|
+
| Events and notifications | [`references/events-notifications.md`](references/events-notifications.md) |
|
|
51
|
+
| Mailables and mail assertions | [`references/mail.md`](references/mail.md) |
|
|
52
|
+
| Scheduled tasks and overlap protection | [`references/scheduling.md`](references/scheduling.md) |
|
|
53
|
+
| Database backups, cleanup, monitoring, notifications | [`references/spatie-laravel-backup.md`](references/spatie-laravel-backup.md) |
|
|
54
|
+
| Collections, lazy iteration, bulk operations | [`references/collections.md`](references/collections.md) |
|
|
55
|
+
| Blade components, attributes, composers | [`references/blade-views.md`](references/blade-views.md) |
|
|
56
|
+
| Tailwind CSS classes, v4 configuration, extraction | [`references/tailwindcss.md`](references/tailwindcss.md) |
|
|
57
|
+
| Environment values and application configuration | [`references/config.md`](references/config.md) |
|
|
58
|
+
| Feature flags and per-user feature checks | [`references/pennant.md`](references/pennant.md) |
|
|
59
|
+
| Pest/PHPUnit patterns, factories, fakes | [`references/testing.md`](references/testing.md) |
|
|
60
|
+
| Pest 4 syntax, datasets, browser and architecture tests | [`references/pest-testing.md`](references/pest-testing.md) |
|
|
61
|
+
| Naming, helpers, file boundaries, PHP style | [`references/style.md`](references/style.md) |
|
|
62
|
+
| Actions, services, dependencies, application structure | [`references/architecture.md`](references/architecture.md) |
|
|
63
|
+
| Detecting and recording this app's conventions as rules | [`references/infer-conventions.md`](references/infer-conventions.md) |
|
|
64
|
+
|
|
65
|
+
## Decision rule
|
|
66
|
+
|
|
67
|
+
- Prefer framework features and existing application abstractions over new helpers or dependencies.
|
|
68
|
+
- Avoid speculative abstractions. Extract code when it creates a clear domain boundary, removes meaningful duplication, or makes behavior independently testable.
|
|
69
|
+
- Keep database access out of Blade views and prevent hidden N+1 queries across controllers, resources, jobs, and serialization.
|
|
@@ -9,7 +9,7 @@ class CreateOrderAction
|
|
|
9
9
|
{
|
|
10
10
|
public function __construct(private InventoryService $inventory) {}
|
|
11
11
|
|
|
12
|
-
public function
|
|
12
|
+
public function handle(array $data): Order
|
|
13
13
|
{
|
|
14
14
|
$order = Order::create($data);
|
|
15
15
|
$this->inventory->reserve($order);
|