prowler-api
БесплатноЗапускает вложенные скриптыНе проверенProwler API patterns: RLS, RBAC, providers, Celery tasks, SSE. Trigger: When working in api/ on models/serializers/viewsets/filters/tasks involving tenant…
Об этом скилле
When to Use
Use this skill for Prowler-specific patterns:
- Row-Level Security (RLS) / tenant isolation
- RBAC permissions and role checks
- Provider lifecycle and validation
- Celery tasks with tenant context
- Multi-database architecture (primary, replica, admin)
- Server-Sent Events (SSE) endpoints
For generic DRF patterns (ViewSets, Serializers, Filters, JSON:API), use django-drf skill.
All paths below are relative to api/src/backend/ unless they start with api/.
Critical Rules
- ALWAYS use
rls_transaction(tenant_id)when querying tenant data outside a ViewSet (tasks, jobs, management commands) - ALWAYS take
tenant_idfrom the auth token (request.tenant_id), NEVER fromrequest.data - ALWAYS pass
tenant_idtoget_role(user, tenant_id); insideBaseRLSViewSetuse the cachedself.user_role - ALWAYS use explicit through models (inheriting
RowLevelSecurityProtectedModel) for M2M relationships - ALWAYS give Celery tasks a
name=; route withqueue=(omitted = defaultceleryqueue) - ALWAYS call tasks with keyword arguments (
tenant_id=...): the decorators readkwargs - NEVER access
Provider.objects(or any tenant model) in Celery without RLS context - NEVER combine plain
@set_tenantwith@handle_provider_deletion:@set_tenantpopstenant_id, which@handle_provider_deletionneeds. Use@set_tenant(keep_tenant=True) - NEVER use
MainRouter.admin_dbunless it is an auth or cross-tenant admin operation (it bypasses RLS)
rls_transaction(value, parameter=POSTGRES_TENANT_VAR, using=None, retry_on_replica=True)validates thatvalueis a UUID (UUID objects and strings both work) and raisesValidationErrorotherwise.
Architecture Overview
Databases (config/django/{devel,production,testing}.py)
| Alias | DB user | Purpose | RLS |
|---|---|---|---|
default |
POSTGRES_USER (default = the prowler_user entry) |
Standard API queries | Yes |
admin |
POSTGRES_ADMIN_USER |
Migrations, auth lookups, Django internal tables | No |
replica |
POSTGRES_REPLICA_USER |
Read-only queries | Yes |
admin_replica |
POSTGRES_ADMIN_USER |
Admin reads on replica | No |
neo4j |
NEO4J_USER |
Graph DB for Attack Paths (not routed by Django) | - |
from api.db_router import MainRouter, READ_REPLICA_ALIAS
User.objects.using(MainRouter.admin_db).get(id=user_id) # Auth lookups (bypasses RLS)
with rls_transaction(tenant_id, using=READ_REPLICA_ALIAS): # Read-heavy task code
Finding.objects.filter(scan_id=scan_id).count()
MainRouter.allow_migrate()only allowsadmin: runmanage.py migrate --database admin.READ_REPLICA_ALIASisNonewithout a replica;rls_transactionthen usesdefault.- Replica failures retry (
POSTGRES_REPLICA_MAX_ATTEMPTS, default 3) and then fall back to primary.
RLS Request Flow (api/base_views.py)
Request -> BaseRLSViewSet.dispatch() replica for SAFE_METHODS (if configured), transaction.atomic
-> BaseRLSViewSet.initial() tenant_id from request.auth (JWT or API key)
rls_transaction(tenant_id) -> set_config('api.tenant_id', ...)
-> queries are tenant-scoped; serializer context gets tenant_id
Other bases in the same file: BaseTenantViewset (tenant CRUD), BaseUserViewset (user endpoints), BaseViewSet (no RLS).
Implementation Checklist
| # | Pattern | Reference | Key Points |
|---|---|---|---|
| 1 | RLS Models | api/rls.py |
Inherit RowLevelSecurityProtectedModel, add RowLevelSecurityConstraint |
| 2 | RLS Transactions | api/db_utils.py |
rls_transaction(tenant_id) context manager |
| 3 | RBAC Permissions | api/rbac/permissions.py |
Permissions enum, HasPermissions, get_role(), get_providers() |
| 4 | Provider Validation | api/models.py |
validate_<provider>_uid() staticmethods on Provider |
| 5 | Celery Tasks | tasks/tasks.py, api/decorators.py, config/celery.py |
@shared_task(base=RLSTask, name=...), @set_tenant, @handle_provider_deletion |
| 6 | Task business logic | tasks/jobs/*.py |
Keep tasks.py thin; logic lives in jobs/ |
| 7 | RLS Serializers | api/v1/serializers.py |
Inherit RLSSerializer to auto-inject tenant_id |
| 8 | Base ViewSets | api/base_views.py |
BaseRLSViewSet for tenant-scoped resources |
| 9 | SSE endpoints | api/sse/ |
Subclass BaseSSEViewSet, build channels with make_channel_name() |
| 10 | Changelog | api/changelog.d/ |
Add a towncrier fragment, never edit CHANGELOG.md (see prowler-changelog) |
Full file paths: See references/file-locations.md
Decision Trees
Which Base Model?
Tenant-scoped data -> RowLevelSecurityProtectedModel
Global/shared data -> models.Model + BaseSecurityConstraint (rare)
Partitioned time-series
Установить prowler-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadEditWriteGlobGrepBashWebFetchWebSearchTaskВложенные файлы
FAQ
Что делает скилл prowler-api?
Prowler API patterns: RLS, RBAC, providers, Celery tasks, SSE. Trigger: When working in api/ on models/serializers/viewsets/filters/tasks involving tenant isolation (RLS), RBAC, provider lifecycle, Celery tasks or SSE endpoints.
Как установить скилл prowler-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл prowler-api запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic