← Back to list

enforce-business-rules
by iurygdeoliveira
Repositorio destinado a fornecer um kit inicial para desenvolvimento de SaaS usando laravel e filament
⭐ 29🍴 12📅 Jan 20, 2026
SKILL.md
name: enforce-business-rules description: Validates code against the project's critical business logic (Multi-tenancy, RBAC, IDOR, SaaS Limits).
Enforce Business Rules
Use this skill BEFORE writing complex logic or AFTER generating code to ensure it adheres to the projects "Ironclad Business Laws".
1. Tenancy Laws (Multi-Tenancy)
Context: Single Database, Tenant-per-record (tenant_id).
- Rule T1 (Scoped Queries): NEVER query models directly without considering the Tenant Scope. Filament does this automatically, but custom Controllers/Jobs must manually apply
where('tenant_id', $tenant->id). - Rule T2 (Team Resolver): We use
spatie/laravel-permissionwith Teams.- The
team_idIS thetenant_id. - DO NOT use global roles for tenant-specific users. Use
RoleType::USERorRoleType::OWNERscoped to the tenant.
- The
2. Authorization Laws (RBAC)
Context: Hierarchical Access (Admin > Owner > User).
- Rule A1 (Policy First): authorization logic lives in Policies, NOT Controllers.
- Rule A2 (The
beforeFilter): Every Policy MUST implementbefore($user)to grant unrestricted access toRoleType::ADMINandRoleType::OWNER.public function before(User $user): ?bool { if ($user->hasRole(RoleType::ADMIN->value)) return true; if ($user->isOwnerOfTenant(Filament::getTenant())) return true; return null; } - Rule A3 (Enum Permissions): usage of
Permission::for('resource')is MANDATORY. Do not hardcode strings like'update users'.
3. Security Laws (IDOR & Data)
- Rule S1 (UUID Mandatory): All public-facing IDs (URLs, API) MUST use UUIDs.
- Model must use
App\Traits\UuidTrait. - Migration must have
$table->uuid('uuid')->unique();. - Route Key must be
return 'uuid';.
- Model must use
- Rule S2 (Route Binding): Always use Implicit Route Binding scoped to the tenant to prevent IDOR.
- Bad:
Media::find($id) - Good:
$tenant->media()->where('uuid', $uuid)->firstOrFail()
- Bad:
4. SaaS Laws (Limits & Plans)
- Rule P1 (Centralized Logic): Limits (e.g., "Max 50 videos") should be checked via a unified Service/Trait, not hardcoded.
Workflow for Agents
- Identify Context: Are we in Admin Panel (Global) or App Panel (Tenant)?
- Check Tenancy: If App Panel, ensure
tenant_idis handled. - Check IDs: proper usage of
UuidTrait? - Check Auth:
Policycreated withbeforemethod?
Verification Checklist
- Does the Model have
UuidTrait? - Does the Policy have
before()handling Admin/Owner? - Is
tenant_idbeing populated on creation? - Are permissions using
Permission::VIEW->for('x')?
Score
Total Score
80/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
✓説明文
100文字以上の説明がある
+10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon

