codebase-scanning
Dynamically detect project patterns and coding style before code generation. MANDATORY before first generation in any session.
What this skill does
# Codebase Scanning Detect project structure, conventions, and coding patterns to ensure generated code matches the existing codebase exactly. ## When to Use **MANDATORY** before the first code generation in any session. Run this scan BEFORE any generate agent produces code. If you have already scanned this session and the results are still in context, skip re-scanning and use the cached profile. ## Phase 1: Structure Detection (~5 seconds) Quickly identify the project layout: ``` CHECK: src/backend/ exists? YES → Nested layout (src/backend/api/, src/backend/db/, etc.) NO → Flat layout (api/, db/, etc.) CHECK: src/frontend/ exists? YES → Nested layout (src/frontend/app/, src/frontend/lib/, etc.) NO → Check for app/ or pages/ directly CHECK: Router registration SCAN: How are routers included in the app? - app_setup/routers_group/ pattern? - Direct app.include_router() in main.py? - APIRouter prefix pattern? CHECK: Frontend directory layout - app/(pages)/ grouping? - Direct app/ pages? - pages/ directory (Pages Router)? ``` ## Phase 2: Pattern Extraction (~10 seconds) Read 2-3 existing entities to extract actual patterns. Read ONE file from each category: ### Backend Patterns **ONE router file** (e.g., the first .py in api/routers/setting/): - How is the session dependency injected? (`SessionDep` param? `Depends(get_session)`?) - Response schema pattern? (`response_model=` on decorator? Return type annotation?) - Error handling pattern? (HTTPException directly? Custom exceptions?) - Pagination pattern? (`skip`/`limit` params? Page-based?) **ONE model** (from db/model.py or db/models/): - Field naming convention (snake_case confirmed?) - Inheritance pattern (`SQLModel`? `Base`? Custom base?) - Type annotations (`Mapped[str]`? `Column(String)`?) - Common fields (is_active, created_at, updated_at, name_en/name_ar?) **ONE schema** (from api/schemas/): - Base class (`CamelModel`? `BaseModel`?) - Field convention (snake_case with camelCase alias?) - Create/Read/Update split pattern **ONE service or CRUD file** (from api/services/ or api/crud/): - Data access pattern (Repository class? CRUD helpers? Direct queries?) - Session handling (passed as param? Stored in __init__?) - Commit pattern (flush vs commit, who commits?) ### Frontend Patterns **ONE page.tsx** (from app/(pages)/): - Server component? Client component? - Data fetching approach (server actions? direct fetch? SWR?) - Layout pattern **ONE table component** (from _components/table/): - State management (`useState` with initialData? `useSWR`?) - Update pattern (in-place `updateItems`? `router.refresh()`?) - Mutation approach (client-side `api.put`? Server actions?) ## Phase 3: Style Profile Construction After extraction, build this profile and keep it in your working context: ``` ┌─────────────────────────────────────────────────────────┐ │ CODEBASE STYLE PROFILE │ ├──────────────────────┬──────────────────────────────────┤ │ Backend layout │ [src/backend/ | flat] │ │ Frontend layout │ [src/frontend/ | flat] │ │ Router registration │ [routers_group | main.py direct] │ │ Session pattern │ [SessionDep | Depends(get_session)] │ │ Schema base class │ [CamelModel | BaseModel] │ │ Data access pattern │ [Repository | CRUD helpers | Service+Repo] │ │ Who commits? │ [Service | Router | CRUD helper] │ │ Bilingual fields │ [yes: name_en/name_ar | no] │ │ Soft delete │ [is_active | hard delete] │ │ Audit fields │ [created_at/updated_at | none] │ │ Model inheritance │ [SQLModel | declarative Base] │ │ Type annotations │ [Mapped[T] | Column(T)] │ │ Frontend state │ [useState | useSWR | hybrid] │ │ Mutation approach │ [client api.put | server actions] │ │ Table update pattern │ [updateItems in-place | router.refresh] │ │ API route pattern │ [route factory | manual proxy] │ │ Import style │ [absolute | relative] │ │ Indentation │ [2 spaces | 4 spaces] │ └──────────────────────┴──────────────────────────────────┘ ``` ## Priority Rule **Codebase patterns ALWAYS override skill reference patterns.** If the actual project uses a different pattern than what's described in skill references: - Follow the **actual project** pattern - Note the divergence for the user - Do NOT "correct" the project to match the skill reference The skill references are starting points. The real codebase is the source of truth. ## Output After scanning, briefly report: 1. Detected project structure (1-2 lines) 2. Key patterns found (the style profile table) 3. Any divergences from skill references (if any) Then proceed with the generation task that triggered this scan.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.