@mohammadhprp/system-prompt 0.10.1
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/LICENSE +21 -0
- package/README.md +35 -0
- package/bin/system-prompt.js +8 -0
- package/framework/README.md +163 -0
- package/framework/agents/README.md +49 -0
- package/framework/agents/backend-architect.md +146 -0
- package/framework/agents/researcher.md +79 -0
- package/framework/agents/reviewer.md +183 -0
- package/framework/agents/security-auditor.md +131 -0
- package/framework/commands/README.md +43 -0
- package/framework/commands/changelog.md +44 -0
- package/framework/commands/commit.md +31 -0
- package/framework/commands/learn.md +24 -0
- package/framework/commands/mr.md +46 -0
- package/framework/commands/pr.md +39 -0
- package/framework/commands/release.md +34 -0
- package/framework/commands/review.md +24 -0
- package/framework/commands/summarize-changes.md +49 -0
- package/framework/mcps/README.md +78 -0
- package/framework/mcps/excalidraw/README.md +37 -0
- package/framework/mcps/excalidraw/capabilities.md +54 -0
- package/framework/mcps/excalidraw/configs/opencode.json +8 -0
- package/framework/mcps/excalidraw/install.md +92 -0
- package/framework/mcps/excalidraw/troubleshooting.md +67 -0
- package/framework/mcps/figma-mcp-go/README.md +51 -0
- package/framework/mcps/figma-mcp-go/capabilities.md +190 -0
- package/framework/mcps/figma-mcp-go/configs/opencode.json +9 -0
- package/framework/mcps/figma-mcp-go/install.md +74 -0
- package/framework/mcps/figma-mcp-go/troubleshooting.md +99 -0
- package/framework/mcps/github-mcp/README.md +51 -0
- package/framework/mcps/github-mcp/capabilities.md +83 -0
- package/framework/mcps/github-mcp/configs/.env.example +1 -0
- package/framework/mcps/github-mcp/configs/opencode.json +13 -0
- package/framework/mcps/github-mcp/install.md +60 -0
- package/framework/mcps/github-mcp/troubleshooting.md +79 -0
- package/framework/mcps/gitlab-mcp/README.md +54 -0
- package/framework/mcps/gitlab-mcp/capabilities.md +216 -0
- package/framework/mcps/gitlab-mcp/configs/.env.example +2 -0
- package/framework/mcps/gitlab-mcp/configs/opencode.json +13 -0
- package/framework/mcps/gitlab-mcp/install.md +99 -0
- package/framework/mcps/gitlab-mcp/troubleshooting.md +116 -0
- package/framework/mcps/jira-mcp/README.md +53 -0
- package/framework/mcps/jira-mcp/capabilities.md +79 -0
- package/framework/mcps/jira-mcp/configs/.env.example +2 -0
- package/framework/mcps/jira-mcp/configs/opencode.json +13 -0
- package/framework/mcps/jira-mcp/install.md +94 -0
- package/framework/mcps/jira-mcp/troubleshooting.md +113 -0
- package/framework/mcps/laravel-boost/README.md +53 -0
- package/framework/mcps/laravel-boost/capabilities.md +92 -0
- package/framework/mcps/laravel-boost/configs/opencode.json +9 -0
- package/framework/mcps/laravel-boost/install.md +106 -0
- package/framework/mcps/laravel-boost/troubleshooting.md +119 -0
- package/framework/mcps/notion-mcp/README.md +58 -0
- package/framework/mcps/notion-mcp/capabilities.md +118 -0
- package/framework/mcps/notion-mcp/configs/opencode.json +9 -0
- package/framework/mcps/notion-mcp/install.md +70 -0
- package/framework/mcps/notion-mcp/troubleshooting.md +95 -0
- package/framework/mcps/playwright-mcp/README.md +50 -0
- package/framework/mcps/playwright-mcp/capabilities.md +149 -0
- package/framework/mcps/playwright-mcp/configs/opencode.json +9 -0
- package/framework/mcps/playwright-mcp/install.md +136 -0
- package/framework/mcps/playwright-mcp/troubleshooting.md +154 -0
- package/framework/mcps/supabase-mcp/README.md +66 -0
- package/framework/mcps/supabase-mcp/capabilities.md +127 -0
- package/framework/mcps/supabase-mcp/configs/opencode.json +9 -0
- package/framework/mcps/supabase-mcp/install.md +85 -0
- package/framework/mcps/supabase-mcp/troubleshooting.md +113 -0
- package/framework/memory/README.md +17 -0
- package/framework/memory/codebase-insights.md +6 -0
- package/framework/memory/user-preferences.md +5 -0
- package/framework/modes/README.md +52 -0
- package/framework/modes/audit.md +88 -0
- package/framework/plugins/README.md +65 -0
- package/framework/plugins/opencode-goal-plugin/README.md +45 -0
- package/framework/plugins/opencode-goal-plugin/capabilities.md +127 -0
- package/framework/plugins/opencode-goal-plugin/install.md +71 -0
- package/framework/plugins/opencode-goal-plugin/troubleshooting.md +112 -0
- package/framework/plugins/ponytail/README.md +44 -0
- package/framework/plugins/ponytail/capabilities.md +112 -0
- package/framework/plugins/ponytail/install.md +77 -0
- package/framework/plugins/ponytail/troubleshooting.md +116 -0
- package/framework/references/standards/api.md +44 -0
- package/framework/references/standards/architecture.md +43 -0
- package/framework/references/standards/database.md +43 -0
- package/framework/references/standards/debugging.md +44 -0
- package/framework/references/standards/documentation.md +43 -0
- package/framework/references/standards/logging.md +43 -0
- package/framework/references/standards/naming.md +43 -0
- package/framework/references/standards/observability.md +43 -0
- package/framework/references/standards/performance.md +43 -0
- package/framework/references/standards/pull-requests.md +43 -0
- package/framework/references/standards/security.md +43 -0
- package/framework/references/standards/testing.md +43 -0
- package/framework/references/templates/adr.md +28 -0
- package/framework/references/templates/api-spec.md +56 -0
- package/framework/references/templates/design-document.md +39 -0
- package/framework/references/templates/incident-report.md +38 -0
- package/framework/references/templates/postmortem.md +41 -0
- package/framework/references/templates/pull-request.md +34 -0
- package/framework/references/templates/runbook.md +48 -0
- package/framework/references/templates/task.md +27 -0
- package/framework/skills/README.md +68 -0
- package/framework/skills/agent-browser/SKILL.md +51 -0
- package/framework/skills/backend-best-practices/SKILL.md +136 -0
- package/framework/skills/backend-best-practices/examples.md +31 -0
- package/framework/skills/backend-best-practices/references/api-design.md +79 -0
- package/framework/skills/backend-best-practices/references/architecture-review.md +77 -0
- package/framework/skills/backend-best-practices/references/database-design.md +78 -0
- package/framework/skills/backend-best-practices/references/debugging.md +76 -0
- package/framework/skills/backend-best-practices/references/observability.md +78 -0
- package/framework/skills/backend-best-practices/references/performance.md +78 -0
- package/framework/skills/backend-best-practices/references/refactoring.md +77 -0
- package/framework/skills/backend-best-practices/references/security.md +80 -0
- package/framework/skills/backend-best-practices/references/testing.md +77 -0
- package/framework/skills/backend-engineer/SKILL.md +76 -0
- package/framework/skills/backend-engineer/examples.md +31 -0
- package/framework/skills/brainstorming/SKILL.md +159 -0
- package/framework/skills/brainstorming/examples.md +49 -0
- package/framework/skills/brainstorming/scripts/frame-template.html +213 -0
- package/framework/skills/brainstorming/scripts/helper.js +167 -0
- package/framework/skills/brainstorming/scripts/server.cjs +723 -0
- package/framework/skills/brainstorming/scripts/start-server.sh +209 -0
- package/framework/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/framework/skills/brainstorming/visual-companion.md +291 -0
- package/framework/skills/brand-guidelines/LICENSE.txt +202 -0
- package/framework/skills/brand-guidelines/SKILL.md +73 -0
- package/framework/skills/code-review/SKILL.md +72 -0
- package/framework/skills/code-review/examples.md +31 -0
- package/framework/skills/design/SKILL.md +399 -0
- package/framework/skills/design/examples.md +34 -0
- package/framework/skills/diagram-design/SKILL.md +485 -0
- package/framework/skills/diagram-design/assets/example-architecture-dark.html +180 -0
- package/framework/skills/diagram-design/assets/example-architecture-full.html +192 -0
- package/framework/skills/diagram-design/assets/example-architecture.html +181 -0
- package/framework/skills/diagram-design/assets/example-bar-dark.html +127 -0
- package/framework/skills/diagram-design/assets/example-bar-full.html +103 -0
- package/framework/skills/diagram-design/assets/example-bar.html +127 -0
- package/framework/skills/diagram-design/assets/example-data-flow-dark.html +143 -0
- package/framework/skills/diagram-design/assets/example-data-flow-full.html +185 -0
- package/framework/skills/diagram-design/assets/example-data-flow.html +143 -0
- package/framework/skills/diagram-design/assets/example-datalake-dark.html +241 -0
- package/framework/skills/diagram-design/assets/example-datalake-full.html +246 -0
- package/framework/skills/diagram-design/assets/example-datalake.html +267 -0
- package/framework/skills/diagram-design/assets/example-dp-integration-dark.html +78 -0
- package/framework/skills/diagram-design/assets/example-dp-integration-full.html +88 -0
- package/framework/skills/diagram-design/assets/example-dp-integration.html +78 -0
- package/framework/skills/diagram-design/assets/example-dp-security-matrix-dark.html +31 -0
- package/framework/skills/diagram-design/assets/example-dp-security-matrix-full.html +32 -0
- package/framework/skills/diagram-design/assets/example-dp-security-matrix.html +88 -0
- package/framework/skills/diagram-design/assets/example-er-dark.html +200 -0
- package/framework/skills/diagram-design/assets/example-er-full.html +203 -0
- package/framework/skills/diagram-design/assets/example-er.html +200 -0
- package/framework/skills/diagram-design/assets/example-flowchart-dark.html +154 -0
- package/framework/skills/diagram-design/assets/example-flowchart-full.html +157 -0
- package/framework/skills/diagram-design/assets/example-flowchart.html +154 -0
- package/framework/skills/diagram-design/assets/example-gantt-dark.html +135 -0
- package/framework/skills/diagram-design/assets/example-gantt-full.html +125 -0
- package/framework/skills/diagram-design/assets/example-gantt.html +135 -0
- package/framework/skills/diagram-design/assets/example-high-level-dark.html +249 -0
- package/framework/skills/diagram-design/assets/example-high-level-full.html +245 -0
- package/framework/skills/diagram-design/assets/example-high-level-vertical-dark.html +272 -0
- package/framework/skills/diagram-design/assets/example-high-level-vertical-full.html +250 -0
- package/framework/skills/diagram-design/assets/example-high-level-vertical.html +323 -0
- package/framework/skills/diagram-design/assets/example-high-level.html +299 -0
- package/framework/skills/diagram-design/assets/example-it-state-dark.html +90 -0
- package/framework/skills/diagram-design/assets/example-it-state-full.html +69 -0
- package/framework/skills/diagram-design/assets/example-it-state.html +128 -0
- package/framework/skills/diagram-design/assets/example-layers-dark.html +121 -0
- package/framework/skills/diagram-design/assets/example-layers-full.html +124 -0
- package/framework/skills/diagram-design/assets/example-layers.html +121 -0
- package/framework/skills/diagram-design/assets/example-line-dark.html +109 -0
- package/framework/skills/diagram-design/assets/example-line-full.html +103 -0
- package/framework/skills/diagram-design/assets/example-line.html +109 -0
- package/framework/skills/diagram-design/assets/example-loop-dark.html +100 -0
- package/framework/skills/diagram-design/assets/example-loop-full.html +137 -0
- package/framework/skills/diagram-design/assets/example-loop-terminal.html +347 -0
- package/framework/skills/diagram-design/assets/example-loop.html +100 -0
- package/framework/skills/diagram-design/assets/example-medallion-dark.html +159 -0
- package/framework/skills/diagram-design/assets/example-medallion-full.html +201 -0
- package/framework/skills/diagram-design/assets/example-medallion.html +159 -0
- package/framework/skills/diagram-design/assets/example-nested-dark.html +130 -0
- package/framework/skills/diagram-design/assets/example-nested-full.html +133 -0
- package/framework/skills/diagram-design/assets/example-nested.html +134 -0
- package/framework/skills/diagram-design/assets/example-org-chart-dark.html +45 -0
- package/framework/skills/diagram-design/assets/example-org-chart-full.html +45 -0
- package/framework/skills/diagram-design/assets/example-org-chart.html +45 -0
- package/framework/skills/diagram-design/assets/example-process-dark.html +62 -0
- package/framework/skills/diagram-design/assets/example-process-full.html +72 -0
- package/framework/skills/diagram-design/assets/example-process.html +62 -0
- package/framework/skills/diagram-design/assets/example-pyramid-dark.html +117 -0
- package/framework/skills/diagram-design/assets/example-pyramid-full.html +120 -0
- package/framework/skills/diagram-design/assets/example-pyramid.html +117 -0
- package/framework/skills/diagram-design/assets/example-quadrant-consultant.html +164 -0
- package/framework/skills/diagram-design/assets/example-quadrant-dark.html +133 -0
- package/framework/skills/diagram-design/assets/example-quadrant-full.html +136 -0
- package/framework/skills/diagram-design/assets/example-quadrant.html +133 -0
- package/framework/skills/diagram-design/assets/example-radar-dark.html +137 -0
- package/framework/skills/diagram-design/assets/example-radar-full.html +133 -0
- package/framework/skills/diagram-design/assets/example-radar.html +137 -0
- package/framework/skills/diagram-design/assets/example-scatter-dark.html +139 -0
- package/framework/skills/diagram-design/assets/example-scatter-full.html +114 -0
- package/framework/skills/diagram-design/assets/example-scatter.html +139 -0
- package/framework/skills/diagram-design/assets/example-sequence-dark.html +220 -0
- package/framework/skills/diagram-design/assets/example-sequence-full.html +386 -0
- package/framework/skills/diagram-design/assets/example-sequence.html +220 -0
- package/framework/skills/diagram-design/assets/example-state-dark.html +145 -0
- package/framework/skills/diagram-design/assets/example-state-full.html +148 -0
- package/framework/skills/diagram-design/assets/example-state.html +145 -0
- package/framework/skills/diagram-design/assets/example-swimlane-dark.html +170 -0
- package/framework/skills/diagram-design/assets/example-swimlane-full.html +173 -0
- package/framework/skills/diagram-design/assets/example-swimlane.html +170 -0
- package/framework/skills/diagram-design/assets/example-timeline-dark.html +133 -0
- package/framework/skills/diagram-design/assets/example-timeline-full.html +136 -0
- package/framework/skills/diagram-design/assets/example-timeline.html +133 -0
- package/framework/skills/diagram-design/assets/example-tree-dark.html +171 -0
- package/framework/skills/diagram-design/assets/example-tree-full.html +174 -0
- package/framework/skills/diagram-design/assets/example-tree.html +171 -0
- package/framework/skills/diagram-design/assets/example-venn-dark.html +130 -0
- package/framework/skills/diagram-design/assets/example-venn-full.html +133 -0
- package/framework/skills/diagram-design/assets/example-venn.html +108 -0
- package/framework/skills/diagram-design/assets/icons.html +230 -0
- package/framework/skills/diagram-design/assets/index.html +333 -0
- package/framework/skills/diagram-design/assets/template-dark.html +82 -0
- package/framework/skills/diagram-design/assets/template-full.html +410 -0
- package/framework/skills/diagram-design/assets/template-terminal.html +170 -0
- package/framework/skills/diagram-design/assets/template.html +83 -0
- package/framework/skills/diagram-design/references/export.md +107 -0
- package/framework/skills/diagram-design/references/onboarding.md +268 -0
- package/framework/skills/diagram-design/references/primitive-annotation.md +36 -0
- package/framework/skills/diagram-design/references/primitive-icons.md +821 -0
- package/framework/skills/diagram-design/references/primitive-sketchy.md +43 -0
- package/framework/skills/diagram-design/references/primitive-terminal.md +76 -0
- package/framework/skills/diagram-design/references/style-guide.md +139 -0
- package/framework/skills/diagram-design/references/type-architecture.md +78 -0
- package/framework/skills/diagram-design/references/type-bar.md +48 -0
- package/framework/skills/diagram-design/references/type-data-flow.md +374 -0
- package/framework/skills/diagram-design/references/type-dp-integration.md +410 -0
- package/framework/skills/diagram-design/references/type-dp-security-matrix.md +379 -0
- package/framework/skills/diagram-design/references/type-er.md +23 -0
- package/framework/skills/diagram-design/references/type-flowchart.md +23 -0
- package/framework/skills/diagram-design/references/type-gantt.md +45 -0
- package/framework/skills/diagram-design/references/type-high-level.md +458 -0
- package/framework/skills/diagram-design/references/type-it-state.md +470 -0
- package/framework/skills/diagram-design/references/type-layers.md +26 -0
- package/framework/skills/diagram-design/references/type-line.md +44 -0
- package/framework/skills/diagram-design/references/type-loop.md +223 -0
- package/framework/skills/diagram-design/references/type-medallion.md +356 -0
- package/framework/skills/diagram-design/references/type-nested.md +22 -0
- package/framework/skills/diagram-design/references/type-org-chart.md +44 -0
- package/framework/skills/diagram-design/references/type-process.md +495 -0
- package/framework/skills/diagram-design/references/type-pyramid.md +33 -0
- package/framework/skills/diagram-design/references/type-quadrant.md +81 -0
- package/framework/skills/diagram-design/references/type-radar.md +80 -0
- package/framework/skills/diagram-design/references/type-scatter.md +39 -0
- package/framework/skills/diagram-design/references/type-sequence.md +35 -0
- package/framework/skills/diagram-design/references/type-state.md +21 -0
- package/framework/skills/diagram-design/references/type-swimlane.md +20 -0
- package/framework/skills/diagram-design/references/type-timeline.md +20 -0
- package/framework/skills/diagram-design/references/type-tree.md +24 -0
- package/framework/skills/diagram-design/references/type-venn.md +26 -0
- package/framework/skills/documentation/SKILL.md +74 -0
- package/framework/skills/documentation/examples.md +31 -0
- package/framework/skills/find-skills/SKILL.md +141 -0
- package/framework/skills/find-skills/examples.md +35 -0
- package/framework/skills/gitlab-mcp/SKILL.md +83 -0
- package/framework/skills/gitlab-mcp/examples.md +31 -0
- package/framework/skills/gitlab-mcp/references/code-review.md +110 -0
- package/framework/skills/gitlab-mcp/references/issues.md +141 -0
- package/framework/skills/gitlab-mcp/references/merge-requests.md +120 -0
- package/framework/skills/gitlab-mcp/references/pipelines.md +67 -0
- package/framework/skills/gitlab-mcp/references/search.md +17 -0
- package/framework/skills/gitlab-mcp/references/webhooks.md +32 -0
- package/framework/skills/gitlab-mcp/references/work-items.md +50 -0
- package/framework/skills/jira-mcp/SKILL.md +57 -0
- package/framework/skills/jira-mcp/examples.md +31 -0
- package/framework/skills/jira-mcp/references/comments.md +27 -0
- package/framework/skills/jira-mcp/references/issues.md +97 -0
- package/framework/skills/jira-mcp/references/projects.md +39 -0
- package/framework/skills/laravel-best-practices/SKILL.md +229 -0
- package/framework/skills/laravel-best-practices/examples.md +31 -0
- package/framework/skills/laravel-best-practices/references/advanced-queries.md +106 -0
- package/framework/skills/laravel-best-practices/references/architecture.md +202 -0
- package/framework/skills/laravel-best-practices/references/blade-views.md +36 -0
- package/framework/skills/laravel-best-practices/references/caching.md +70 -0
- package/framework/skills/laravel-best-practices/references/collections.md +44 -0
- package/framework/skills/laravel-best-practices/references/config.md +73 -0
- package/framework/skills/laravel-best-practices/references/db-performance.md +192 -0
- package/framework/skills/laravel-best-practices/references/eloquent.md +148 -0
- package/framework/skills/laravel-best-practices/references/error-handling.md +72 -0
- package/framework/skills/laravel-best-practices/references/events-notifications.md +52 -0
- package/framework/skills/laravel-best-practices/references/http-client.md +160 -0
- package/framework/skills/laravel-best-practices/references/mail.md +27 -0
- package/framework/skills/laravel-best-practices/references/migrations.md +121 -0
- package/framework/skills/laravel-best-practices/references/passport.md +197 -0
- package/framework/skills/laravel-best-practices/references/pennant.md +61 -0
- package/framework/skills/laravel-best-practices/references/pest-testing.md +166 -0
- package/framework/skills/laravel-best-practices/references/pulse.md +196 -0
- package/framework/skills/laravel-best-practices/references/queue-jobs.md +144 -0
- package/framework/skills/laravel-best-practices/references/routing.md +99 -0
- package/framework/skills/laravel-best-practices/references/scheduling.md +39 -0
- package/framework/skills/laravel-best-practices/references/scout.md +176 -0
- package/framework/skills/laravel-best-practices/references/security.md +198 -0
- package/framework/skills/laravel-best-practices/references/spatie-laravel-backup.md +222 -0
- package/framework/skills/laravel-best-practices/references/spatie-laravel-permission.md +272 -0
- package/framework/skills/laravel-best-practices/references/spatie-medialibrary.md +672 -0
- package/framework/skills/laravel-best-practices/references/style.md +125 -0
- package/framework/skills/laravel-best-practices/references/tailwindcss.md +112 -0
- package/framework/skills/laravel-best-practices/references/testing.md +43 -0
- package/framework/skills/laravel-best-practices/references/validation.md +75 -0
- package/framework/skills/lavish/SKILL.md +67 -0
- package/framework/skills/lavish/examples.md +31 -0
- package/framework/skills/notion-mcp/SKILL.md +57 -0
- package/framework/skills/notion-mcp/examples.md +31 -0
- package/framework/skills/notion-mcp/references/comments.md +112 -0
- package/framework/skills/notion-mcp/references/databases.md +193 -0
- package/framework/skills/notion-mcp/references/pages.md +235 -0
- package/framework/skills/skill-creator/LICENSE.txt +202 -0
- package/framework/skills/skill-creator/SKILL.md +485 -0
- package/framework/skills/skill-creator/agents/analyzer.md +274 -0
- package/framework/skills/skill-creator/agents/comparator.md +202 -0
- package/framework/skills/skill-creator/agents/grader.md +223 -0
- package/framework/skills/skill-creator/assets/eval_review.html +146 -0
- package/framework/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/framework/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/framework/skills/skill-creator/examples.md +31 -0
- package/framework/skills/skill-creator/references/schemas.md +430 -0
- package/framework/skills/skill-creator/scripts/__init__.py +0 -0
- package/framework/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/framework/skills/skill-creator/scripts/generate_report.py +326 -0
- package/framework/skills/skill-creator/scripts/improve_description.py +247 -0
- package/framework/skills/skill-creator/scripts/package_skill.py +136 -0
- package/framework/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/framework/skills/skill-creator/scripts/run_eval.py +310 -0
- package/framework/skills/skill-creator/scripts/run_loop.py +328 -0
- package/framework/skills/skill-creator/scripts/utils.py +47 -0
- package/framework/styles/README.md +35 -0
- package/framework/styles/linear/DESIGN.md +478 -0
- package/framework/styles/linear/README.md +36 -0
- package/framework/styles/linear/assets/preview.jpg +0 -0
- package/framework/styles/raycast/DESIGN.md +495 -0
- package/framework/styles/raycast/README.md +35 -0
- package/framework/styles/raycast/assets/preview.jpg +0 -0
- package/package.json +33 -0
- package/src/agent-configs.js +96 -0
- package/src/catalog.js +145 -0
- package/src/cli.js +254 -0
- package/src/installer.js +303 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Laravel Backup
|
|
2
|
+
|
|
3
|
+
## When to Apply
|
|
4
|
+
|
|
5
|
+
Activate this skill when:
|
|
6
|
+
|
|
7
|
+
- Configuring backup sources, destinations, or notifications
|
|
8
|
+
- Scheduling backup, cleanup, or monitor commands
|
|
9
|
+
- Creating custom cleanup strategies or health checks
|
|
10
|
+
- Customizing backup notifications
|
|
11
|
+
- Troubleshooting backup failures
|
|
12
|
+
|
|
13
|
+
## Key Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
|
|
17
|
+
# Run a backup
|
|
18
|
+
|
|
19
|
+
php artisan backup:run
|
|
20
|
+
|
|
21
|
+
# Backup only the database
|
|
22
|
+
|
|
23
|
+
php artisan backup:run --only-db
|
|
24
|
+
|
|
25
|
+
# Backup specific database connections
|
|
26
|
+
|
|
27
|
+
php artisan backup:run --db-name=mysql --db-name=pgsql
|
|
28
|
+
|
|
29
|
+
# Backup only files (no database)
|
|
30
|
+
|
|
31
|
+
php artisan backup:run --only-files
|
|
32
|
+
|
|
33
|
+
# Backup to a specific disk
|
|
34
|
+
|
|
35
|
+
php artisan backup:run --only-to-disk=s3
|
|
36
|
+
|
|
37
|
+
# Custom filename
|
|
38
|
+
|
|
39
|
+
php artisan backup:run --filename=my-backup.zip
|
|
40
|
+
|
|
41
|
+
# Clean old backups
|
|
42
|
+
|
|
43
|
+
php artisan backup:clean
|
|
44
|
+
|
|
45
|
+
# List all backups
|
|
46
|
+
|
|
47
|
+
php artisan backup:list
|
|
48
|
+
|
|
49
|
+
# Monitor backup health
|
|
50
|
+
|
|
51
|
+
php artisan backup:monitor
|
|
52
|
+
|
|
53
|
+
# Use an alternative config key
|
|
54
|
+
|
|
55
|
+
php artisan backup:run --config=backup_secondary
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Scheduling
|
|
59
|
+
|
|
60
|
+
Add to `routes/console.php` or `app/Console/Kernel.php`:
|
|
61
|
+
|
|
62
|
+
```php
|
|
63
|
+
use Illuminate\Support\Facades\Schedule;
|
|
64
|
+
|
|
65
|
+
Schedule::command('backup:clean')->daily()->at('01:00');
|
|
66
|
+
Schedule::command('backup:run')->daily()->at('01:30');
|
|
67
|
+
Schedule::command('backup:monitor')->daily()->at('10:00');
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
Published to `config/backup.php` with sections: `backup` (source files/databases, destination disks, encryption), `notifications` (mail, Slack, Discord), `monitor_backups` (health checks), and `cleanup` (retention strategy).
|
|
73
|
+
|
|
74
|
+
### Database Dump Customization
|
|
75
|
+
|
|
76
|
+
Customize dumps per connection in `config/database.php`:
|
|
77
|
+
|
|
78
|
+
```php
|
|
79
|
+
'mysql' => [
|
|
80
|
+
// ...
|
|
81
|
+
'dump' => [
|
|
82
|
+
'exclude_tables' => ['telescope_entries', 'telescope_monitoring'],
|
|
83
|
+
'useSingleTransaction' => true,
|
|
84
|
+
],
|
|
85
|
+
],
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Enable dump compression:
|
|
89
|
+
|
|
90
|
+
```php
|
|
91
|
+
// config/backup.php
|
|
92
|
+
'database_dump_compressor' => \Spatie\DbDumper\Compressors\GzipCompressor::class,
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Multiple Backup Destinations
|
|
96
|
+
|
|
97
|
+
```php
|
|
98
|
+
// config/backup.php
|
|
99
|
+
'destination' => [
|
|
100
|
+
'disks' => ['local', 's3'],
|
|
101
|
+
],
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Encryption
|
|
105
|
+
|
|
106
|
+
```php
|
|
107
|
+
// config/backup.php
|
|
108
|
+
'password' => env('BACKUP_ARCHIVE_PASSWORD'),
|
|
109
|
+
'encryption' => 'default', // Uses ZipArchive::EM_AES_256
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Custom Cleanup Strategy
|
|
113
|
+
|
|
114
|
+
Extend `Spatie\Backup\Tasks\Cleanup\CleanupStrategy` and implement `deleteOldBackups`:
|
|
115
|
+
|
|
116
|
+
```php
|
|
117
|
+
use Spatie\Backup\BackupDestination\BackupCollection;
|
|
118
|
+
use Spatie\Backup\Tasks\Cleanup\CleanupStrategy;
|
|
119
|
+
|
|
120
|
+
class MyCleanupStrategy extends CleanupStrategy
|
|
121
|
+
{
|
|
122
|
+
public function deleteOldBackups(BackupCollection $backups): void
|
|
123
|
+
{
|
|
124
|
+
$backups
|
|
125
|
+
->reject(fn ($backup) => $backup->date()->gt(now()->subMonth()))
|
|
126
|
+
->each(fn ($backup) => $backup->delete());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Register in `config/backup.php`:
|
|
132
|
+
|
|
133
|
+
```php
|
|
134
|
+
'cleanup' => [
|
|
135
|
+
'strategy' => \App\Backup\MyCleanupStrategy::class,
|
|
136
|
+
],
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Custom Health Check
|
|
140
|
+
|
|
141
|
+
Extend `Spatie\Backup\Tasks\Monitor\HealthCheck` and implement `checkHealth`:
|
|
142
|
+
|
|
143
|
+
```php
|
|
144
|
+
use Spatie\Backup\BackupDestination\BackupDestination;
|
|
145
|
+
use Spatie\Backup\Tasks\Monitor\HealthCheck;
|
|
146
|
+
|
|
147
|
+
class MinimumBackupCount extends HealthCheck
|
|
148
|
+
{
|
|
149
|
+
protected int $minimumCount;
|
|
150
|
+
|
|
151
|
+
public function __construct(int $minimumCount = 3)
|
|
152
|
+
{
|
|
153
|
+
$this->minimumCount = $minimumCount;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public function checkHealth(BackupDestination $backupDestination): void
|
|
157
|
+
{
|
|
158
|
+
$this->failIf(
|
|
159
|
+
$backupDestination->backups()->count() < $this->minimumCount,
|
|
160
|
+
"Expected at least {$this->minimumCount} backups."
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Register in `config/backup.php`:
|
|
167
|
+
|
|
168
|
+
```php
|
|
169
|
+
'health_checks' => [
|
|
170
|
+
\App\Backup\MinimumBackupCount::class => 5,
|
|
171
|
+
],
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Custom Notification
|
|
175
|
+
|
|
176
|
+
Extend `Spatie\Backup\Notifications\BaseNotification`:
|
|
177
|
+
|
|
178
|
+
```php
|
|
179
|
+
use Illuminate\Notifications\Messages\MailMessage;
|
|
180
|
+
use Spatie\Backup\Notifications\BaseNotification;
|
|
181
|
+
|
|
182
|
+
class CustomBackupFailedNotification extends BaseNotification
|
|
183
|
+
{
|
|
184
|
+
public function toMail(): MailMessage
|
|
185
|
+
{
|
|
186
|
+
return (new MailMessage)
|
|
187
|
+
->error()
|
|
188
|
+
->subject("Backup failed for {$this->applicationName()}")
|
|
189
|
+
->line($this->event->exception->getMessage());
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Map it in `config/backup.php`:
|
|
195
|
+
|
|
196
|
+
```php
|
|
197
|
+
'notifications' => [
|
|
198
|
+
'notifications' => [
|
|
199
|
+
\App\Notifications\CustomBackupFailedNotification::class => ['mail'],
|
|
200
|
+
],
|
|
201
|
+
],
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Events
|
|
205
|
+
|
|
206
|
+
All events are in `Spatie\Backup\Events`:
|
|
207
|
+
|
|
208
|
+
- `BackupWasSuccessful` - Backup completed successfully
|
|
209
|
+
- `BackupHasFailed` - Backup failed (includes exception and optional backup destination)
|
|
210
|
+
- `BackupManifestWasCreated` - File manifest created before zipping
|
|
211
|
+
- `BackupZipWasCreated` - Zip archive created (used for encryption hook)
|
|
212
|
+
- `DumpingDatabase` - Database dump in progress
|
|
213
|
+
- `CleanupWasSuccessful` / `CleanupHasFailed` - Cleanup result
|
|
214
|
+
- `HealthyBackupWasFound` / `UnhealthyBackupWasFound` - Monitor result
|
|
215
|
+
|
|
216
|
+
## Common Pitfalls
|
|
217
|
+
|
|
218
|
+
- Forgetting to schedule `backup:clean` alongside `backup:run`, causing disk space to fill up
|
|
219
|
+
- Not excluding `vendor` and `node_modules` from file backups (excluded by default)
|
|
220
|
+
- Setting `only-db` and `only-files` together (mutually exclusive)
|
|
221
|
+
- Missing the `ext-zip` PHP extension
|
|
222
|
+
- Not configuring the notification `mail.to` address after publishing config
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Laravel Permission Development
|
|
2
|
+
|
|
3
|
+
## When to use this skill
|
|
4
|
+
|
|
5
|
+
Use this skill when working with authorization, roles, permissions, access control, middleware guards, or Blade permission directives using spatie/laravel-permission.
|
|
6
|
+
|
|
7
|
+
## Core Concepts
|
|
8
|
+
|
|
9
|
+
- **Users have Roles, Roles have Permissions, Apps check Permissions** (not Roles).
|
|
10
|
+
- Direct permissions on users are an anti-pattern; assign permissions to roles instead.
|
|
11
|
+
- Use `$user->can('permission-name')` for all authorization checks (supports Super Admin via Gate).
|
|
12
|
+
- The `HasRoles` trait (which includes `HasPermissions`) is added to User models.
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
Add the `HasRoles` trait to your User model:
|
|
17
|
+
|
|
18
|
+
```php
|
|
19
|
+
use Spatie\Permission\Traits\HasRoles;
|
|
20
|
+
|
|
21
|
+
class User extends Authenticatable
|
|
22
|
+
{
|
|
23
|
+
use HasRoles;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Creating Roles and Permissions
|
|
28
|
+
|
|
29
|
+
```php
|
|
30
|
+
use Spatie\Permission\Models\Role;
|
|
31
|
+
use Spatie\Permission\Models\Permission;
|
|
32
|
+
|
|
33
|
+
$role = Role::create(['name' => 'writer']);
|
|
34
|
+
$permission = Permission::create(['name' => 'edit articles']);
|
|
35
|
+
|
|
36
|
+
// findOrCreate is idempotent (safe for seeders)
|
|
37
|
+
$role = Role::findOrCreate('writer', 'web');
|
|
38
|
+
$permission = Permission::findOrCreate('edit articles', 'web');
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Assigning Roles and Permissions
|
|
42
|
+
|
|
43
|
+
```php
|
|
44
|
+
// Assign roles to users
|
|
45
|
+
$user->assignRole('writer');
|
|
46
|
+
$user->assignRole('writer', 'admin');
|
|
47
|
+
$user->assignRole(['writer', 'admin']);
|
|
48
|
+
$user->syncRoles(['writer', 'admin']); // replaces all
|
|
49
|
+
$user->removeRole('writer');
|
|
50
|
+
|
|
51
|
+
// Assign permissions to roles (preferred)
|
|
52
|
+
$role->givePermissionTo('edit articles');
|
|
53
|
+
$role->givePermissionTo(['edit articles', 'delete articles']);
|
|
54
|
+
$role->syncPermissions(['edit articles', 'delete articles']);
|
|
55
|
+
$role->revokePermissionTo('edit articles');
|
|
56
|
+
|
|
57
|
+
// Reverse assignment
|
|
58
|
+
$permission->assignRole('writer');
|
|
59
|
+
$permission->syncRoles(['writer', 'editor']);
|
|
60
|
+
$permission->removeRole('writer');
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Checking Roles and Permissions
|
|
64
|
+
|
|
65
|
+
```php
|
|
66
|
+
// Permission checks (preferred - supports Super Admin via Gate)
|
|
67
|
+
$user->can('edit articles');
|
|
68
|
+
$user->canAny(['edit articles', 'delete articles']);
|
|
69
|
+
|
|
70
|
+
// Direct package methods (bypass Gate, no Super Admin support)
|
|
71
|
+
$user->hasPermissionTo('edit articles');
|
|
72
|
+
$user->hasAnyPermission(['edit articles', 'publish articles']);
|
|
73
|
+
$user->hasAllPermissions(['edit articles', 'publish articles']);
|
|
74
|
+
$user->hasDirectPermission('edit articles');
|
|
75
|
+
|
|
76
|
+
// Role checks
|
|
77
|
+
$user->hasRole('writer');
|
|
78
|
+
$user->hasAnyRole(['writer', 'editor']);
|
|
79
|
+
$user->hasAllRoles(['writer', 'editor']);
|
|
80
|
+
$user->hasExactRoles(['writer', 'editor']);
|
|
81
|
+
|
|
82
|
+
// Get assigned roles and permissions
|
|
83
|
+
$user->getRoleNames(); // Collection of role name strings
|
|
84
|
+
$user->getPermissionNames(); // Collection of permission name strings
|
|
85
|
+
$user->getDirectPermissions(); // Direct permissions only
|
|
86
|
+
$user->getPermissionsViaRoles(); // Inherited via roles
|
|
87
|
+
$user->getAllPermissions(); // Both direct and inherited
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Query Scopes
|
|
91
|
+
|
|
92
|
+
```php
|
|
93
|
+
$users = User::role('writer')->get();
|
|
94
|
+
$users = User::withoutRole('writer')->get();
|
|
95
|
+
$users = User::permission('edit articles')->get();
|
|
96
|
+
$users = User::withoutPermission('edit articles')->get();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Middleware
|
|
100
|
+
|
|
101
|
+
Register middleware aliases in `bootstrap/app.php`:
|
|
102
|
+
|
|
103
|
+
```php
|
|
104
|
+
->withMiddleware(function (Middleware $middleware) {
|
|
105
|
+
$middleware->alias([
|
|
106
|
+
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
|
107
|
+
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
|
108
|
+
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
|
109
|
+
]);
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use in routes (pipe `|` for OR logic):
|
|
114
|
+
|
|
115
|
+
```php
|
|
116
|
+
Route::middleware(['permission:edit articles'])->group(function () { ... });
|
|
117
|
+
Route::middleware(['role:manager|writer'])->group(function () { ... });
|
|
118
|
+
Route::middleware(['role_or_permission:manager|edit articles'])->group(function () { ... });
|
|
119
|
+
|
|
120
|
+
// With specific guard
|
|
121
|
+
Route::middleware(['role:manager,api'])->group(function () { ... });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
For single permissions, Laravel's built-in `can` middleware also works:
|
|
125
|
+
|
|
126
|
+
```php
|
|
127
|
+
Route::middleware(['can:edit articles'])->group(function () { ... });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Blade Directives
|
|
131
|
+
|
|
132
|
+
Prefer `@can` (permission-based) over `@role` (role-based):
|
|
133
|
+
|
|
134
|
+
```blade
|
|
135
|
+
@can('edit articles')
|
|
136
|
+
{{-- User can edit articles (supports Super Admin) --}}
|
|
137
|
+
@endcan
|
|
138
|
+
|
|
139
|
+
@canany(['edit articles', 'delete articles'])
|
|
140
|
+
{{-- User can do at least one --}}
|
|
141
|
+
@endcanany
|
|
142
|
+
|
|
143
|
+
@role('admin')
|
|
144
|
+
{{-- Only use for super-admin type checks --}}
|
|
145
|
+
@endrole
|
|
146
|
+
|
|
147
|
+
@hasanyrole('writer|admin')
|
|
148
|
+
{{-- Has writer or admin --}}
|
|
149
|
+
@endhasanyrole
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Super Admin
|
|
153
|
+
|
|
154
|
+
Use `Gate::before` in `AppServiceProvider::boot()`:
|
|
155
|
+
|
|
156
|
+
```php
|
|
157
|
+
use Illuminate\Support\Facades\Gate;
|
|
158
|
+
|
|
159
|
+
public function boot(): void
|
|
160
|
+
{
|
|
161
|
+
Gate::before(function ($user, $ability) {
|
|
162
|
+
return $user->hasRole('Super Admin') ? true : null;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This makes `$user->can()` and `@can` always return true for Super Admins. Must return `null` (not `false`) to allow normal checks for other users.
|
|
168
|
+
|
|
169
|
+
## Policies
|
|
170
|
+
|
|
171
|
+
Use `$user->can()` inside policy methods to check permissions:
|
|
172
|
+
|
|
173
|
+
```php
|
|
174
|
+
class PostPolicy
|
|
175
|
+
{
|
|
176
|
+
public function update(User $user, Post $post): bool
|
|
177
|
+
{
|
|
178
|
+
if ($user->can('edit all posts')) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return $user->can('edit own posts') && $user->id === $post->user_id;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Enums
|
|
188
|
+
|
|
189
|
+
```php
|
|
190
|
+
enum RolesEnum: string
|
|
191
|
+
{
|
|
192
|
+
case WRITER = 'writer';
|
|
193
|
+
case EDITOR = 'editor';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
enum PermissionsEnum: string
|
|
197
|
+
{
|
|
198
|
+
case EDIT_POSTS = 'edit posts';
|
|
199
|
+
case DELETE_POSTS = 'delete posts';
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Creation requires ->value
|
|
203
|
+
Permission::findOrCreate(PermissionsEnum::EDIT_POSTS->value, 'web');
|
|
204
|
+
|
|
205
|
+
// Most methods accept enums directly
|
|
206
|
+
$user->assignRole(RolesEnum::WRITER);
|
|
207
|
+
$user->hasRole(RolesEnum::WRITER);
|
|
208
|
+
$role->givePermissionTo(PermissionsEnum::EDIT_POSTS);
|
|
209
|
+
$user->hasPermissionTo(PermissionsEnum::EDIT_POSTS);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Seeding
|
|
213
|
+
|
|
214
|
+
Always flush the permission cache when seeding:
|
|
215
|
+
|
|
216
|
+
```php
|
|
217
|
+
class RolesAndPermissionsSeeder extends Seeder
|
|
218
|
+
{
|
|
219
|
+
public function run(): void
|
|
220
|
+
{
|
|
221
|
+
// Reset cache
|
|
222
|
+
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
|
223
|
+
|
|
224
|
+
// Create permissions
|
|
225
|
+
Permission::findOrCreate('edit articles', 'web');
|
|
226
|
+
Permission::findOrCreate('delete articles', 'web');
|
|
227
|
+
|
|
228
|
+
// Create roles and assign permissions
|
|
229
|
+
Role::findOrCreate('writer', 'web')
|
|
230
|
+
->givePermissionTo(['edit articles']);
|
|
231
|
+
|
|
232
|
+
Role::findOrCreate('admin', 'web')
|
|
233
|
+
->givePermissionTo(Permission::all());
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Teams (Multi-Tenancy)
|
|
239
|
+
|
|
240
|
+
Enable in `config/permission.php` before running migrations:
|
|
241
|
+
|
|
242
|
+
```php
|
|
243
|
+
'teams' => true,
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Set the active team in middleware:
|
|
247
|
+
|
|
248
|
+
```php
|
|
249
|
+
setPermissionsTeamId($teamId);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
When switching teams, unset cached relations:
|
|
253
|
+
|
|
254
|
+
```php
|
|
255
|
+
$user->unsetRelation('roles')->unsetRelation('permissions');
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Events
|
|
259
|
+
|
|
260
|
+
Enable in `config/permission.php`:
|
|
261
|
+
|
|
262
|
+
```php
|
|
263
|
+
'events_enabled' => true,
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Available events: `RoleAttachedEvent`, `RoleDetachedEvent`, `PermissionAttachedEvent`, `PermissionDetachedEvent` in the `Spatie\Permission\Events` namespace.
|
|
267
|
+
|
|
268
|
+
## Performance
|
|
269
|
+
|
|
270
|
+
- Permissions are cached automatically. The cache is flushed when roles/permissions change via package methods.
|
|
271
|
+
- After direct DB operations, flush manually: `app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions()`
|
|
272
|
+
- For bulk seeding, use `Permission::insert()` for speed, but flush the cache afterward.
|