Help us improve
Share bugs, ideas, or general feedback.
From aidd-overlay
Audits a project's data layer (client + server) against a stack-aware checklist (N+1, query count, pagination, real-time listeners, payload size, cache strategy, quota/cost, indexing, security rules, observability) and produces a ranked roadmap. Detects the data-layer stack (Firebase, Supabase, Prisma, Drizzle, TypeORM, Sequelize, Mongoose, Django ORM, Laravel Eloquent, Doctrine, DynamoDB, GraphQL, tRPC, Hasura, raw REST) and reuses an existing template or proposes generating a new one. Use when the user mentions data perf, API perf, slow query, data-layer N+1 (queries répétées sur même collection/table — distinct from web-optimize's render-time N+1), Firestore quota, "trop de reads", "trop de requêtes", egress, rate limit, cold start, connection pool, réplication, read replica, sharding, "API lente", "backend lent", "DB perf", "audit data", "audit backend", or invokes /data-optimize.
npx claudepluginhub rebellioussmile/my-claude-marketplaceHow this skill is triggered — by the user, by Claude, or both
Slash command
/aidd-overlay:data-optimize <route, action or scope to audit (optional)><route, action or scope to audit (optional)>The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Run a structured data-layer audit on a project — covering both the calls emitted by the client (count, batching, cache, listeners) and the server logic that handles them (queries, indexes, quota, security rules) — picking the right checklist for the detected stack, and emit an actionable roadmap.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Run a structured data-layer audit on a project — covering both the calls emitted by the client (count, batching, cache, listeners) and the server logic that handles them (queries, indexes, quota, security rules) — picking the right checklist for the detected stack, and emit an actionable roadmap.
firebase config / prisma/schema.prisma / models.py / Models/*.php / drizzle.config.ts / equivalent), (b) one hot read path (composable, controller, repository, GraphQL resolver), (c) one hot write path. Generic advice without this evidence is rejected🟢 / 🟡 / 🔴 / N/A + file:line references when actionableaidd_docs/tasks/audits/<yyyy_mm_dd>_data-<stack>-<scope-slug>.md. If aidd_docs/ does not exist, fallback to docs/data-audits/<yyyy_mm_dd>_data-<stack>-<scope-slug>.md (create dir if needed). Day-level granularity prevents collision when multiple audits target the same scope in one month-v2, -v3 to the slug rather than overwriting the previous reportaidd_docs/internal/decisions/ exists; otherwise inline the rationale in the audit report itself# 1. Detect the data-layer stack — read every relevant manifest
cat package.json 2>/dev/null | grep -E '"(firebase|firebase-admin|@supabase/supabase-js|@prisma/client|drizzle-orm|typeorm|sequelize|mongoose|@aws-sdk/client-dynamodb|@apollo/client|urql|@trpc/client|@hasura|graphql-request)"'
cat composer.json 2>/dev/null | grep -E '"(laravel/framework|symfony/orm-pack|doctrine/orm|mongodb/mongodb)"'
ls manage.py 2>/dev/null && echo "Django ORM (models live in <app>/models.py)"
test -f prisma/schema.prisma && echo "Prisma detected"
test -f drizzle.config.ts && echo "Drizzle detected"
test -f firebase.json && echo "Firebase project detected"
test -f supabase/config.toml && echo "Supabase project detected"
# 1bis. Detect package manager from lockfile (drives all DB/CLI commands below)
PM=${PM:-pnpm}
[ -f pnpm-lock.yaml ] && PM=pnpm
[ -f yarn.lock ] && PM=yarn
[ -f package-lock.json ] && PM=npm
[ -f bun.lockb ] && PM=bun
echo "Using package manager: $PM"
# 1ter. Detect monorepo — if any workspace marker is found, STOP and ask user which package to audit
# JS/TS: pnpm-workspace.yaml, turbo.json, nx.json, lerna.json
# Python: pyproject.toml [tool.uv.workspace] / [tool.rye.workspace]
# PHP: composer.json with "wikimedia/composer-merge-plugin" or repositories.path entries
# Rust: top-level Cargo.toml [workspace]
ls pnpm-workspace.yaml turbo.json nx.json lerna.json 2>/dev/null
grep -l '\[tool\.\(uv\|rye\)\.workspace\]' pyproject.toml 2>/dev/null
grep -l 'composer-merge-plugin\|"path"' composer.json 2>/dev/null
grep -l '^\[workspace\]' Cargo.toml 2>/dev/null
echo "⚠️ Any output above = monorepo — STOP and ask the user which package/workspace to audit before continuing"
# 1quater. No detection match? Fallback before generating an "other" template:
# Dump direct deps and ask user which one is the data layer
[ -z "$DETECTED_STACK" ] && {
echo "No data-layer SDK matched. Showing direct deps for user to identify:"
cat package.json 2>/dev/null | jq '.dependencies // {}'
cat composer.json 2>/dev/null | jq '.require // {}'
cat pyproject.toml 2>/dev/null | grep -A 50 '\[project\.dependencies\]\|\[tool\.poetry\.dependencies\]'
echo "→ Ask the user: which of these talks to the data store? (paste name + version)"
}
# 2. Capture baseline (uses $PM detected above; pick the stack-matching command)
# JS stacks — count outgoing HTTP from a user flow via Playwright trace or HAR export
$PM playwright test --trace on tests/e2e/<flow>.spec.ts
# Firestore — Firebase Console → Firestore → Usage tab (reads/writes/day)
# Postgres + Prisma — enable query log: prisma.$on('query', ...) ; or pg_stat_statements
# Django — pip install django-debug-toolbar OR django-silk ; count SQL/page in dev
# Laravel — composer require barryvdh/laravel-debugbar ; count queries/page
# DynamoDB — CloudWatch Metrics : ConsumedReadCapacityUnits / ConsumedWriteCapacityUnits
# 3. Apply checklist (see Workflow)
Cross-project use: this skill lives in
.claude/skills/data-optimize/(project-scoped). To use it across all your projects, copy thedata-optimize/folder to~/.claude/skills/data-optimize/.
---
title: data-optimize workflow
---
flowchart LR
Detect["Detect data stack"]
Pick{"Stack source?"}
LoadSingle["Load single template"]
LoadHybrid["Load primary template plus hybrid section"]
AskUser["Ask user: generate? (yes / no / use Firebase as base)"]
Generate["Generate new template"]
Stop["Halt — user declined"]
Baseline["Capture baseline counters"]
Audit["Apply checklist line by line"]
Roadmap["Emit ranked roadmap"]
Detect --> Pick
Pick -- "single match" --> LoadSingle
Pick -- "hybrid match" --> LoadHybrid
Pick -- "no match" --> AskUser
AskUser -- "yes / Firebase base" --> Generate
AskUser -- "no" --> Stop
LoadSingle --> Baseline
LoadHybrid --> Baseline
Generate --> Baseline
Baseline --> Audit
Audit --> Roadmap
Do:
package.json → JS/TS data SDKs (Firebase, Supabase, Prisma, Drizzle, Mongoose, AWS SDK, Apollo, urql, tRPC)composer.json → PHP ORMs (Eloquent via laravel/framework, Doctrine via doctrine/orm or symfony/orm-pack)requirements.txt / pyproject.toml → Django ORM, SQLAlchemy, motor (Mongo), boto3 (AWS)firebase, supabase, prisma, drizzle, typeorm, sequelize, mongoose,
django-orm, laravel-eloquent, doctrine,
dynamodb, graphql-apollo, graphql-urql, trpc, hasura,
rest-vanilla, otherfirebase.json, firestore.rules, firestore.indexes.jsonsupabase/config.toml, supabase/migrations/prisma/schema.prisma, drizzle.config.ts, ormconfig.{js,ts}models.py (Django), Models/*.php + database/migrations/ (Laravel), src/Entity/*.php (Symfony Doctrine)serverless.yml / CDK with DynamoDB tables; GraphQL schema.graphql or *.gqlreferences/api-mapping.md entries (do NOT generate a new combined template).server/api/*, routes/web.php, Django views), GraphQL operations (*.gql, generated hooks), tRPC procedures.Success criteria: Stack(s) + version + role (primary/secondary, OLTP/OLAP/cache/queue) reported back to user.
Do:
Look for matching template under aidd_docs/templates/dev/data_checklist_*.md (or docs/data-templates/ if no aidd_docs/)
If found (e.g. data_checklist_firebase.md): load it and proceed to Step 3
If hybrid stack (e.g. firebase + prisma): load primary template (firebase) and read the matching hybrid sections in references/api-mapping.md. Concatenate items in the audit. No new template generated.
If no template matches the stack: halt the workflow and ask the user before proceeding:
"No data checklist exists for
<stack>. Should I generatedata_checklist_<stack>.mdfrom official best practices adapted to this project? (yes / no / use the Firebase checklist as a base)"
If user accepts generation:
references/api-mapping.md "Schéma général"). Section §11 is mandatory in every generated template; it drives Step 6 of this workflow## Common anti-patterns (rejected) (table) and ## Quick verification commands (block)references/api-mapping.md pivotsaidd_docs/templates/dev/data_checklist_<stack>.md (or docs/data-templates/<stack>.md)aidd_docs/internal/decisions/ exists: create a DEC documenting the convention choicesSuccess criteria: A checklist source is loaded into context, stack-appropriate.
Do:
request = one user-visible action (page load, button click, form submit). NOT one HTTP roundtrip — modern apps fire many HTTP/gRPC calls per action.query = one DB call (one getDocs/getDoc/onSnapshot invocation; one Prisma method call; one SQL statement).getDocs/getDoc/onSnapshot count from logs; Prisma $on('query', ...) middleware; Django len(connection.queries); Laravel Debugbar; pg_stat_statements calls columnperformance.now() around awaitaidd_docs/tasks/audits/baselines/<scope-slug>.json with shape { "captured_at": "<ISO date>", "stack": "<stack>", "counters": { "requests_per_action": [...], "queries_per_request": [...], "payload_kb": [...], "p95_ms": [...] } }. Future audits on the same scope MUST reference this file in their report header — without it, claims like "fix removed 4 queries" are unfalsifiable across iterationsmin_instances: 1 (Cloud Functions Gen 2) / provisioned_concurrency (Lambda) and document this in the baseline header — restore prior config after audit if cost mattersSuccess criteria: Baseline counters quoted with source AND noise characterized AND deterministic baseline (requests/queries/bytes/quota) recorded AND baselines/<scope-slug>.json persisted.
Do:
For each section, run the verification commands listed at the bottom of the matching template (or api-mapping.md pivots for hybrid)
Mark items with status emoji + actionable note (file:line or fix recipe)
Quick verification reflexes:
# Firestore — query without limit() (read-amplification risk)
grep -rn "query(" --include="*.vue" --include="*.js" --include="*.ts" \
| grep -v "limit("
# Firestore — onSnapshot without unsubscribe (memory + read leak)
grep -rn "onSnapshot" --include="*.vue" --include="*.js" --include="*.ts" -A 5 \
| grep -B 1 -v "unsubscribe\|onUnmounted"
# Prisma — missing select (over-fetching)
grep -rn "prisma\.\w\+\.find" --include="*.ts" --include="*.js" \
| grep -v "select:"
# Django — query in loop (N+1)
grep -rn "for .* in " --include="*.py" -A 3 \
| grep -B 1 "\.objects\.\|\.filter\(" \
| grep -v "select_related\|prefetch_related"
# Laravel — Eloquent N+1 (no with())
grep -rn "::all\|::get(" --include="*.php" \
| grep -v "->with("
# GraphQL — N+1 in resolvers without DataLoader
grep -rn "Promise.all\|.map(async" --include="*.ts" --include="*.js" \
| grep -v "DataLoader\|dataloader"
Group fixes by ROI (quick wins / structural / monitoring)
Null result handling: an audit step can produce zero actionable findings (e.g. grep for unbatched Firestore writes returns 0 — pattern already audited and clean). Record null results explicitly in the report ("§4 audit: 0 unbatched writes found — pattern compliant since commit X") so the next iteration doesn't redo the same audit
Success criteria: Every checklist line has a status; no [ ] left unchecked. Null results documented with the reason.
Do:
aidd_docs/tasks/audits/<yyyy_mm_dd>_data-<stack>-<scope-slug>.md (fallback docs/data-audits/...)
<stack> example: firebase, prisma, eloquent, firebase-prisma (hybrid). Use - separator between stacks, never + (breaks Markdown auto-link, URL handling, and some Windows tooling)<scope-slug> canonical form (REQUIRED for cross-run matching):
ee not é)candidate-flow, admin-dashboard, signup, full-appCandidate_Flow, signup flow, inscription-entreprise-très-long-slug<scope> not provided as argument: default to full-app (audit covers all data paths)-v2, -v3 to keep history (no overwrite)firebase + prisma + redis), do NOT concatenate into one report. Emit separate <yyyy_mm_dd>_data-<stack>-<scope-slug>.md files per stack and a top-level cross-link index <yyyy_mm_dd>_data-multi-<scope-slug>.md listing them with shared baseline reference. Single hybrid file > 33 sections is unreviewableawait on a write, query without index on a one-off table, .exists() in a single loop) belongs in:
gh issue create (or equivalent) so the fix has a follow-up ownerapi-mapping.md pivots, or .claude/rules/ — those files codify recurring patterns, not point fixes. A bug ≠ an anti-pattern.Success criteria: User can execute Phase F0 from the report alone, no further questions. Each fix has a deterministic primary success criterion (request/query/byte/quota delta). Each bug has either a roadmap entry + tracker issue, or is silently fixed in the same PR if trivial — never normative pollution.
Do:
data_checklist_<stack>.md) — mandatory, not optional## Checklist learnings section at the top of the audit report capturing:
[gap] §N: <missing bullet>[fp] §N: <bullet> — reason[reword] §N: <before> → <after>[antipattern] <pattern> | <why rejected>[grep] <command> — <what it surfaces>api-mapping.md — formatted [pivot] <stack>: <missing pivot>[unit] §N: <ambiguity> → <proposed wording>[antipattern]. Only elevate to anti-pattern if you can cite ≥ 2 distinct occurrences in the codebase OR a recognized generic class.aidd_docs/templates/dev/data_checklist_<stack>.mdreferences/api-mapping.mdtests.md if a new detection case emerged (regression row in the test matrix)## Checklist learnings in the report; future audits aggregateSuccess criteria: Every audit ends with a ## Checklist learnings section, even if empty ([none] line). The skill gets monotonically better project-by-project.
| Type | Path | Description |
|---|---|---|
| Template | aidd_docs/templates/dev/data_checklist_<stack>.md | Auto-generated on first audit when missing (e.g. firebase, prisma, eloquent) |
| Reference | references/api-mapping.md | Pivots per stack (Firebase, Supabase, Prisma, Drizzle, ORMs, DynamoDB, GraphQL, tRPC) |
| Output | aidd_docs/tasks/audits/<yyyy_mm_dd>_data-<stack>-<scope-slug>.md | Audit report destination (fallback docs/data-audits/... if no aidd_docs/) |
| Baseline | aidd_docs/tasks/audits/baselines/<scope-slug>.json | Persisted deterministic counters — referenced by every audit on the same scope for reproducible cross-run comparison |
| Tests | .claude/skills/data-optimize/tests.md | Smoke test cases for stack detection — run before trusting the skill on new stacks |