ai-ops-cli 0.1.24 → 0.2.0
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/README.md +107 -45
- package/data/presets.yaml +0 -23
- package/data/skills/README.md +157 -0
- package/data/skills/reference-skills/ai-llm-python-runtime/SKILL.md +10 -0
- package/data/skills/reference-skills/ai-llm-python-runtime/references/reference.md +26 -0
- package/data/skills/reference-skills/backend-python-fastapi-runtime/SKILL.md +10 -0
- package/data/skills/reference-skills/backend-python-fastapi-runtime/references/reference.md +43 -0
- package/data/skills/reference-skills/backend-service-standards/SKILL.md +10 -0
- package/data/skills/reference-skills/backend-service-standards/references/reference.md +29 -0
- package/data/skills/reference-skills/backend-ts-nestjs-runtime/SKILL.md +10 -0
- package/data/skills/reference-skills/backend-ts-nestjs-runtime/references/reference.md +43 -0
- package/data/skills/reference-skills/data-pipeline-python-performance/SKILL.md +10 -0
- package/data/skills/reference-skills/data-pipeline-python-performance/references/reference.md +24 -0
- package/data/skills/reference-skills/db-prisma-postgresql/SKILL.md +10 -0
- package/data/skills/reference-skills/db-prisma-postgresql/references/reference.md +25 -0
- package/data/skills/reference-skills/db-sqlalchemy-postgresql/SKILL.md +10 -0
- package/data/skills/reference-skills/db-sqlalchemy-postgresql/references/reference.md +25 -0
- package/data/skills/reference-skills/frontend-app-flutter-runtime/SKILL.md +10 -0
- package/data/skills/reference-skills/frontend-app-flutter-runtime/references/reference.md +50 -0
- package/data/skills/reference-skills/frontend-web-react-next-runtime/SKILL.md +10 -0
- package/data/skills/reference-skills/frontend-web-react-next-runtime/references/reference.md +51 -0
- package/data/skills/reference-skills/frontend-web-shadcn-ui/SKILL.md +10 -0
- package/data/skills/reference-skills/frontend-web-shadcn-ui/references/reference.md +26 -0
- package/data/skills/reference-skills/graphql-client-integration/SKILL.md +10 -0
- package/data/skills/reference-skills/graphql-client-integration/references/reference.md +22 -0
- package/data/skills/reference-skills/graphql-contract/SKILL.md +10 -0
- package/data/skills/reference-skills/graphql-contract/references/reference.md +22 -0
- package/data/skills/reference-skills/graphql-server-runtime/SKILL.md +10 -0
- package/data/skills/reference-skills/graphql-server-runtime/references/reference.md +40 -0
- package/data/skills/reference-skills/python-language/SKILL.md +10 -0
- package/data/skills/reference-skills/python-language/references/reference.md +26 -0
- package/data/skills/reference-skills/typescript-language/SKILL.md +10 -0
- package/data/skills/reference-skills/typescript-language/references/reference.md +23 -0
- package/data/skills/skill-registry.json +148 -0
- package/data/skills/task-skills/skill-load-check/SKILL.md +8 -0
- package/data/skills/task-skills/skill-load-check/scripts/loaded.js +1 -0
- package/dist/bin/index.js +1263 -307
- package/dist/bin/index.js.map +1 -1
- package/package.json +1 -1
- package/data/rules/ai-llm-python.yaml +0 -35
- package/data/rules/data-pipeline-python.yaml +0 -34
- package/data/rules/engineering-standards.yaml +0 -39
- package/data/rules/fastapi.yaml +0 -34
- package/data/rules/flutter.yaml +0 -40
- package/data/rules/graphql-client-app.yaml +0 -29
- package/data/rules/graphql-client-web.yaml +0 -30
- package/data/rules/graphql-core.yaml +0 -31
- package/data/rules/graphql-server.yaml +0 -33
- package/data/rules/libs-backend-python.yaml +0 -35
- package/data/rules/libs-backend-ts.yaml +0 -36
- package/data/rules/libs-frontend-app.yaml +0 -39
- package/data/rules/libs-frontend-web.yaml +0 -39
- package/data/rules/nestjs-graphql.yaml +0 -31
- package/data/rules/nestjs.yaml +0 -26
- package/data/rules/nextjs.yaml +0 -34
- package/data/rules/prisma-postgresql.yaml +0 -30
- package/data/rules/python.yaml +0 -31
- package/data/rules/react-typescript.yaml +0 -11
- package/data/rules/shadcn-ui.yaml +0 -36
- package/data/rules/sqlalchemy.yaml +0 -32
- package/data/rules/typescript.yaml +0 -22
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
id: ai-llm-python
|
|
2
|
-
category: domain
|
|
3
|
-
tags:
|
|
4
|
-
- python
|
|
5
|
-
- llm
|
|
6
|
-
- ai
|
|
7
|
-
priority: 28
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT parse model outputs with regex/split when schema output is required. Use structured output (Pydantic + response_format/function calling/instructor).'
|
|
11
|
-
- 'DO NOT hardcode prompts inline. Keep prompts versioned in files or managed storage.'
|
|
12
|
-
- 'DO NOT call sync SDK methods from async app paths.'
|
|
13
|
-
- 'DO NOT ignore token limits. Estimate and chunk/truncate input before requests.'
|
|
14
|
-
- 'DO NOT log raw responses containing PII.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Use Pydantic models with instructor or native response_format JSON schema mode.'
|
|
17
|
-
- 'Apply retry with exponential backoff for 429/5xx transient errors.'
|
|
18
|
-
- 'Centralize provider routing via LiteLLM (or equivalent abstraction).'
|
|
19
|
-
- 'Track model, input/output tokens, and latency per call for cost/perf monitoring.'
|
|
20
|
-
- 'Version prompts and include prompt version in request logs.'
|
|
21
|
-
- 'Stream user-facing responses when possible; keep non-streaming for strict structured extraction flows.'
|
|
22
|
-
- 'Define fallback model chains for rate limits or provider outages.'
|
|
23
|
-
decision_table:
|
|
24
|
-
- when: 'Output must match a strict schema'
|
|
25
|
-
then: 'Use structured output with Pydantic schema validation'
|
|
26
|
-
avoid: 'Regex parsing on free-text responses'
|
|
27
|
-
- when: 'Selecting a model'
|
|
28
|
-
then: 'Use the smallest model that meets quality requirements'
|
|
29
|
-
avoid: 'Defaulting to the largest model for all tasks'
|
|
30
|
-
- when: 'Input exceeds context window'
|
|
31
|
-
then: 'Chunk with overlap and aggregate results'
|
|
32
|
-
avoid: 'Silent SDK truncation'
|
|
33
|
-
- when: 'Multiple providers are required'
|
|
34
|
-
then: 'Use a unified provider abstraction (e.g., LiteLLM)'
|
|
35
|
-
avoid: 'Scattered provider-specific call sites'
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
id: data-pipeline-python
|
|
2
|
-
category: domain
|
|
3
|
-
tags:
|
|
4
|
-
- python
|
|
5
|
-
- data-engineering
|
|
6
|
-
- polars
|
|
7
|
-
- duckdb
|
|
8
|
-
priority: 33
|
|
9
|
-
content:
|
|
10
|
-
constraints:
|
|
11
|
-
- 'DO NOT iterate DataFrame rows in Python loops for transformations.'
|
|
12
|
-
- 'DO NOT use Pandas .apply(axis=1). It runs at Python speed; use vectorized expressions or Polars.'
|
|
13
|
-
- 'DO NOT load datasets larger than memory in one shot.'
|
|
14
|
-
- 'DO NOT rely on implicit dtype inference for production pipelines.'
|
|
15
|
-
- 'DO NOT mutate DataFrames in-place.'
|
|
16
|
-
guidelines:
|
|
17
|
-
- 'Prefer Polars for new pipelines, especially lazy mode for query pushdown and parallel execution.'
|
|
18
|
-
- 'Use DuckDB for local SQL analytics on Parquet/CSV and out-of-core workloads.'
|
|
19
|
-
- 'Use streaming/chunked reads for large sources (scan_*, batched readers, out-of-core SQL).'
|
|
20
|
-
- 'Write partitioned Parquet outputs for downstream pruning and faster reads.'
|
|
21
|
-
- 'Enforce explicit schemas at I/O boundaries.'
|
|
22
|
-
decision_table:
|
|
23
|
-
- when: 'Transforming tables up to medium-large scale'
|
|
24
|
-
then: 'Use Polars lazy pipelines'
|
|
25
|
-
avoid: 'Row-wise pandas patterns'
|
|
26
|
-
- when: 'Ad-hoc SQL analysis on local files is needed'
|
|
27
|
-
then: 'Use DuckDB directly on source files'
|
|
28
|
-
avoid: 'Load-all-then-filter in pandas'
|
|
29
|
-
- when: 'Data exceeds available memory'
|
|
30
|
-
then: 'Use Polars scan_* or DuckDB out-of-core execution'
|
|
31
|
-
avoid: 'Full-memory pandas reads'
|
|
32
|
-
- when: 'Custom per-row Python logic is unavoidable'
|
|
33
|
-
then: 'Use vectorized expressions or controlled map APIs'
|
|
34
|
-
avoid: 'General-purpose iter_rows for core pipelines'
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
id: engineering-standards
|
|
2
|
-
category: standard
|
|
3
|
-
tags:
|
|
4
|
-
- general
|
|
5
|
-
- api
|
|
6
|
-
- data-format
|
|
7
|
-
- cross-cutting
|
|
8
|
-
priority: 70
|
|
9
|
-
content:
|
|
10
|
-
constraints:
|
|
11
|
-
- 'DO NOT use floating-point for money. Use minor-unit integers with ISO 4217 currency (e.g., { amount: 1099, currency: "USD" }).'
|
|
12
|
-
- 'DO NOT expose sequential IDs in external APIs. Use UUIDs (prefer UUID v7).'
|
|
13
|
-
- 'DO NOT store or transmit timezone-naive timestamps. Use ISO 8601 UTC (e.g., "2024-01-15T09:30:00Z").'
|
|
14
|
-
- 'DO NOT use magic numbers or strings inline. Extract constants or config.'
|
|
15
|
-
- 'DO NOT return inconsistent error shapes. Use { code: string, message: string, details?: unknown[] }.'
|
|
16
|
-
- 'DO NOT accept unbounded input. Enforce body, array, and string size limits at the API boundary.'
|
|
17
|
-
guidelines:
|
|
18
|
-
- 'Use UTC end-to-end: TIMESTAMPTZ in DB, ISO 8601 UTC in API/logs, local conversion only in the presentation layer.'
|
|
19
|
-
- 'Wrap API responses in a consistent envelope: { data: T | null, error: ErrorEnvelope | null, meta: { requestId: string, timestamp: string } }.'
|
|
20
|
-
- 'Propagate X-Request-Id across gateway, service, logs, DB comments, and outbound calls.'
|
|
21
|
-
- 'Validate environment variables at startup (e.g., Zod parse) and fail fast with all missing/invalid keys.'
|
|
22
|
-
- 'Use domain error codes in DOMAIN_ACTION_REASON format (e.g., PAYMENT_CHARGE_INSUFFICIENT_FUNDS).'
|
|
23
|
-
- 'Support Idempotency-Key for POST/PATCH and replay the cached response for duplicate keys within TTL.'
|
|
24
|
-
- 'Expose GET /health (liveness) and GET /ready (readiness) separately.'
|
|
25
|
-
- 'Return empty collections ([] or {}) instead of null.'
|
|
26
|
-
- 'Handle SIGTERM gracefully: stop intake, drain in-flight requests, close resources, then exit.'
|
|
27
|
-
decision_table:
|
|
28
|
-
- when: 'A new entity needs a primary key'
|
|
29
|
-
then: 'Use UUID v7'
|
|
30
|
-
avoid: 'Auto-increment IDs or UUID v4 by default'
|
|
31
|
-
- when: 'An endpoint returns an error'
|
|
32
|
-
then: 'Return the standard error envelope'
|
|
33
|
-
avoid: 'Ad-hoc error fields (e.g., { success: false, msg })'
|
|
34
|
-
- when: 'Systems exchange timestamps'
|
|
35
|
-
then: 'Use ISO 8601 UTC in API/logs and TIMESTAMPTZ in DB; Unix epoch is acceptable in compact token formats (e.g., JWT exp/iat)'
|
|
36
|
-
avoid: 'Timezone-naive strings or mixed local-time storage'
|
|
37
|
-
- when: 'An API needs versioning'
|
|
38
|
-
then: 'Use URL versioning (/v1, /v2)'
|
|
39
|
-
avoid: 'Header-only versioning by default'
|
package/data/rules/fastapi.yaml
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
id: fastapi
|
|
2
|
-
category: framework
|
|
3
|
-
tags:
|
|
4
|
-
- python
|
|
5
|
-
- fastapi
|
|
6
|
-
- backend
|
|
7
|
-
priority: 42
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT use plain dict/TypedDict as request or response models. Use Pydantic BaseModel with Field constraints.'
|
|
11
|
-
- 'DO NOT run blocking I/O in async handlers. Use async clients or offload to executors.'
|
|
12
|
-
- 'DO NOT return ad-hoc error dicts from handlers. Raise HTTPException/custom exceptions and centralize handlers.'
|
|
13
|
-
- 'DO NOT place business logic in routers. Keep routers thin and inject services via Depends().'
|
|
14
|
-
- 'DO NOT hardcode CORS origins. Load from validated settings.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Use reusable Depends() providers for DB session, auth context, and services.'
|
|
17
|
-
- 'Use APIRouter per domain with clear prefixes/tags and mount in the main app.'
|
|
18
|
-
- 'Set response_model on endpoints for output filtering and OpenAPI correctness.'
|
|
19
|
-
- 'Use Annotated[T, Depends(...)] for typed dependency injection.'
|
|
20
|
-
- 'Use Pydantic Settings for startup-time environment validation.'
|
|
21
|
-
- 'Use lifespan context manager for startup/shutdown lifecycle management.'
|
|
22
|
-
decision_table:
|
|
23
|
-
- when: 'Endpoint is CPU-bound'
|
|
24
|
-
then: 'Use sync def and let FastAPI run it in the threadpool'
|
|
25
|
-
avoid: 'async def with blocking code'
|
|
26
|
-
- when: 'Endpoint is I/O-bound'
|
|
27
|
-
then: 'Use async def with async drivers (asyncpg, httpx, aiofiles)'
|
|
28
|
-
avoid: 'Sync driver calls on hot paths'
|
|
29
|
-
- when: 'Shared resources need setup/teardown'
|
|
30
|
-
then: 'Use lifespan async context manager'
|
|
31
|
-
avoid: '@app.on_event startup/shutdown hooks'
|
|
32
|
-
- when: 'Post-response background work is required'
|
|
33
|
-
then: 'Use BackgroundTasks for light jobs, Celery/TaskIQ for heavy/retriable jobs'
|
|
34
|
-
avoid: 'Awaiting long tasks inside the request handler'
|
package/data/rules/flutter.yaml
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
id: flutter
|
|
2
|
-
category: framework
|
|
3
|
-
tags:
|
|
4
|
-
- dart
|
|
5
|
-
- flutter
|
|
6
|
-
- riverpod
|
|
7
|
-
- mobile
|
|
8
|
-
priority: 30
|
|
9
|
-
content:
|
|
10
|
-
constraints:
|
|
11
|
-
- 'DO NOT use dynamic as a default type. Prefer concrete types, Object, or sealed unions.'
|
|
12
|
-
- 'DO NOT put business logic in Widget build(). Keep widgets declarative.'
|
|
13
|
-
- 'DO NOT use StatefulWidget for shared or long-lived state. Use Riverpod providers.'
|
|
14
|
-
- 'DO NOT use GlobalKey to reach into child state for app data flow.'
|
|
15
|
-
- 'DO NOT keep mutable model fields. Prefer immutable classes with copyWith/freezed.'
|
|
16
|
-
- 'DO NOT run heavy synchronous work on the UI thread. Use compute or Isolate.'
|
|
17
|
-
guidelines:
|
|
18
|
-
- 'Use Riverpod with @riverpod code generation and feature-local providers.'
|
|
19
|
-
- 'Use feature-first directories: lib/features/<feature>/{view,model,provider,logic} and shared code in lib/core.'
|
|
20
|
-
- 'Use sealed classes and pattern matching for Result/Async state handling.'
|
|
21
|
-
- 'Prefer const constructors where possible for rebuild efficiency.'
|
|
22
|
-
- 'Use go_router for declarative routes and deep-link handling.'
|
|
23
|
-
- 'Use freezed for immutable models and generated equality/copy/JSON methods.'
|
|
24
|
-
- 'Write widget tests with ProviderScope.overrides and unit-test pure logic separately.'
|
|
25
|
-
- 'Profile with DevTools before optimization; use RepaintBoundary where repaint isolation is needed.'
|
|
26
|
-
- 'Handle async states explicitly with AsyncValue or a Result type (loading/success/failure). Set a global error boundary to catch unhandled exceptions before they reach the UI.'
|
|
27
|
-
- 'Access external APIs/storage via repositories; providers should depend on repository interfaces.'
|
|
28
|
-
decision_table:
|
|
29
|
-
- when: 'State is local and ephemeral (focus, small toggle)'
|
|
30
|
-
then: 'Use StatefulWidget or flutter_hooks state'
|
|
31
|
-
avoid: 'Creating global/shared providers for trivial local state'
|
|
32
|
-
- when: 'State is shared or must outlive a widget'
|
|
33
|
-
then: 'Use Riverpod Notifier/AsyncNotifier'
|
|
34
|
-
avoid: 'Prop-drilling callback chains'
|
|
35
|
-
- when: 'A model needs equality/copy/JSON generation'
|
|
36
|
-
then: 'Use @freezed + build_runner'
|
|
37
|
-
avoid: 'Manual ==/hashCode/copyWith implementations'
|
|
38
|
-
- when: 'Navigation and deep links are needed'
|
|
39
|
-
then: 'Use GoRouter route configuration'
|
|
40
|
-
avoid: 'Imperative Navigator-only architecture'
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
id: graphql-client-app
|
|
2
|
-
category: api
|
|
3
|
-
tags:
|
|
4
|
-
- graphql
|
|
5
|
-
- frontend
|
|
6
|
-
- flutter
|
|
7
|
-
priority: 46
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT call GraphQL endpoints directly from widgets. Route operations through provider/repository layers to avoid rebuild-driven duplicate requests and side effects.'
|
|
11
|
-
- 'DO NOT parse GraphQL response maps in UI code. Convert payloads to typed freezed/json_serializable models in the data layer to prevent runtime cast/null errors.'
|
|
12
|
-
- 'DO NOT treat HTTP 200 as success when GraphQL errors[] exists. Map GraphQL errors to typed domain failures.'
|
|
13
|
-
- 'DO NOT create ad-hoc Dio instances for GraphQL calls. Reuse the shared DI-injected client with auth interceptors.'
|
|
14
|
-
guidelines:
|
|
15
|
-
- 'Use Riverpod providers as the boundary between presentation and GraphQL data access.'
|
|
16
|
-
- 'Generate GraphQL DTO/union models with the same build_runner pipeline used for other app models.'
|
|
17
|
-
- 'Map __typename-based unions to freezed union types to force exhaustive handling.'
|
|
18
|
-
- 'Keep optimistic update and cache invalidation logic in repositories/providers, not in widgets.'
|
|
19
|
-
- 'Log operationName with redacted variables for debugging failed GraphQL operations.'
|
|
20
|
-
decision_table:
|
|
21
|
-
- when: 'A widget needs GraphQL data'
|
|
22
|
-
then: 'Read a Riverpod provider that delegates to repository/use-case'
|
|
23
|
-
avoid: 'Calling Dio/GraphQL requests directly inside build() or event handlers'
|
|
24
|
-
- when: 'A mutation returns data plus business errors'
|
|
25
|
-
then: 'Preserve successful fields and map typed errors into UI state'
|
|
26
|
-
avoid: 'Treating the full response as fatal failure'
|
|
27
|
-
- when: 'New GraphQL documents are added'
|
|
28
|
-
then: 'Run build_runner to regenerate typed models before commit'
|
|
29
|
-
avoid: 'Manual map access against dynamic JSON payloads'
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
id: graphql-client-web
|
|
2
|
-
category: api
|
|
3
|
-
tags:
|
|
4
|
-
- graphql
|
|
5
|
-
- frontend
|
|
6
|
-
- nextjs
|
|
7
|
-
- apollo
|
|
8
|
-
priority: 47
|
|
9
|
-
content:
|
|
10
|
-
constraints:
|
|
11
|
-
- 'DO NOT call /graphql with ad-hoc fetch wrappers in Next.js App Router features. Use the shared Apollo client stack to preserve auth links and normalized cache behavior.'
|
|
12
|
-
- 'DO NOT handwrite GraphQL operation/result types or cast payloads with as assertions. Use generated TypedDocumentNode artifacts.'
|
|
13
|
-
- 'DO NOT treat HTTP 200 as success when GraphQL errors[] exists. Handle partial-success responses explicitly.'
|
|
14
|
-
- 'DO NOT create per-feature ApolloClient instances. Reuse one configured provider to preserve auth/cache/link behavior.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Use @apollo/client with @apollo/experimental-nextjs-app-support and mount ApolloNextAppProvider once at the app root.'
|
|
17
|
-
- 'Use GraphQL Codegen client-preset and import generated graphql(...) documents from feature modules.'
|
|
18
|
-
- 'Set fetchPolicy explicitly per operation (cache-first, network-only, no-cache) based on freshness requirements.'
|
|
19
|
-
- 'Co-locate .graphql documents and fragments with feature code, and keep fragment names feature-prefixed.'
|
|
20
|
-
- 'Normalize GraphQL errors/extensions into a shared UI error model before rendering.'
|
|
21
|
-
decision_table:
|
|
22
|
-
- when: 'GraphQL data fetching is needed in App Router'
|
|
23
|
-
then: 'Use the shared ApolloNextAppProvider + generated documents'
|
|
24
|
-
avoid: 'Ad-hoc raw fetch cache wiring in components'
|
|
25
|
-
- when: 'A mutation can return both data and business errors'
|
|
26
|
-
then: 'Render partial-success data and surface typed errors from the same response'
|
|
27
|
-
avoid: 'Throwing away data whenever errors[] is present'
|
|
28
|
-
- when: 'A new query document is added'
|
|
29
|
-
then: 'Regenerate codegen artifacts before committing'
|
|
30
|
-
avoid: 'Shipping stale generated types/documents'
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
id: graphql-core
|
|
2
|
-
category: api
|
|
3
|
-
tags:
|
|
4
|
-
- graphql
|
|
5
|
-
- api
|
|
6
|
-
- schema-contract
|
|
7
|
-
priority: 48
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT rely on implicit nullability. Mark every field intentionally (prefer non-null by default).'
|
|
11
|
-
- 'DO NOT return unbounded lists. Every collection must provide pagination arguments and a stable cursor.'
|
|
12
|
-
- 'DO NOT expose internal implementation details in enum values. Use semantic SCREAMING_SNAKE_CASE names that remain stable across refactors.'
|
|
13
|
-
- 'DO NOT rename/remove published fields or types in the same release. Deprecate first, then remove in the next major.'
|
|
14
|
-
guidelines:
|
|
15
|
-
- 'Follow naming conventions: PascalCase for types/enums, camelCase for fields/arguments, SCREAMING_SNAKE_CASE for enum values.'
|
|
16
|
-
- 'Prefer cursor pagination (first/after) for user-facing lists; use offset only for bounded admin tables.'
|
|
17
|
-
- 'Define typed FilterInput/OrderByInput for filtering and sorting instead of JSON-like free-form arguments.'
|
|
18
|
-
- 'Document scalar contracts (DateTime, UUID, JSON) with accepted formats and timezone policy.'
|
|
19
|
-
decision_table:
|
|
20
|
-
- when: 'A field returns a collection'
|
|
21
|
-
then: 'Use cursor pagination with a stable cursor and deterministic ordering'
|
|
22
|
-
avoid: 'Returning unbounded [Node!]! lists'
|
|
23
|
-
- when: 'A field or type must be renamed/removed'
|
|
24
|
-
then: 'Mark it as @deprecated with a migration reason, keep compatibility for at least one release, remove in next major'
|
|
25
|
-
avoid: 'Immediate rename/removal that breaks existing client operations'
|
|
26
|
-
- when: 'A schema change is high-risk (widely used field, auth/payment domain)'
|
|
27
|
-
then: 'Add pre-release usage checks (operation usage, top callers), publish rollback criteria, and keep a revert path that restores the previous contract'
|
|
28
|
-
avoid: 'Shipping a contract change without usage visibility or rollback plan'
|
|
29
|
-
- when: 'Filtering or sorting is complex'
|
|
30
|
-
then: 'Define typed FilterInput/OrderByInput types'
|
|
31
|
-
avoid: 'Accepting raw JSON blobs or ad-hoc string filters'
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
id: graphql-server
|
|
2
|
-
category: api
|
|
3
|
-
tags:
|
|
4
|
-
- graphql
|
|
5
|
-
- api
|
|
6
|
-
- backend
|
|
7
|
-
priority: 44
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT perform mutations in Query resolvers. Reads belong to Query, writes belong to Mutation.'
|
|
11
|
-
- 'DO NOT throw top-level GraphQL errors for expected business failures. Return typed domain errors in payloads.'
|
|
12
|
-
- 'DO NOT issue per-parent DB queries from field resolvers. Use request-scoped batching (DataLoader or equivalent).'
|
|
13
|
-
- 'DO NOT accept multiple scalar mutation arguments. Standardize on one input object (mutation X($input: XInput!)).'
|
|
14
|
-
- 'DO NOT expose unauthenticated subscription/live update endpoints in production.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Keep resolvers thin and delegate business logic to service/use-case layers.'
|
|
17
|
-
- 'Use payload types that carry both success data and typed userErrors for partial success handling.'
|
|
18
|
-
- 'Apply query depth/complexity limits and operation timeout guards to prevent expensive nested queries.'
|
|
19
|
-
- 'Record operationName and requestId in structured logs for mutation/subscription debugging.'
|
|
20
|
-
- 'Document idempotency expectations for side-effecting mutations (payment, provisioning, outbound integrations).'
|
|
21
|
-
decision_table:
|
|
22
|
-
- when: 'A mutation can fail due to business validation'
|
|
23
|
-
then: 'Return payload data + typed userErrors and keep top-level errors for unexpected faults only'
|
|
24
|
-
avoid: 'Throwing generic Error for expected business branches'
|
|
25
|
-
- when: 'A field resolver loads related entities'
|
|
26
|
-
then: 'Batch and cache per-request with DataLoader (or equivalent)'
|
|
27
|
-
avoid: 'Repository call per parent row (N+1)'
|
|
28
|
-
- when: 'A new subscription is introduced'
|
|
29
|
-
then: 'Require auth/tenant checks and choose production-safe PubSub transport'
|
|
30
|
-
avoid: 'Unauthenticated or in-memory-only subscription setup in production'
|
|
31
|
-
- when: 'A mutation triggers irreversible side effects (billing, provisioning, partner API)'
|
|
32
|
-
then: 'Verify pre-conditions first, require idempotency keys, and define compensating/rollback actions before execution'
|
|
33
|
-
avoid: 'Calling external side effects before validation or without replay/rollback strategy'
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
id: libs-backend-python
|
|
2
|
-
category: tooling
|
|
3
|
-
tags:
|
|
4
|
-
- python
|
|
5
|
-
- backend
|
|
6
|
-
priority: 22
|
|
7
|
-
content:
|
|
8
|
-
constraints:
|
|
9
|
-
- 'DO NOT use requirements.txt as the primary dependency spec. Use pyproject.toml with uv (preferred) or Poetry, and commit the lock file.'
|
|
10
|
-
- 'DO NOT use print() for logging. Use structured JSON logging (structlog).'
|
|
11
|
-
- 'DO NOT use unittest.TestCase. Use pytest with fixtures.'
|
|
12
|
-
- 'DO NOT rely on bare assert in production code. Raise explicit exceptions.'
|
|
13
|
-
guidelines:
|
|
14
|
-
- 'Use uv for environment and dependency management (uv sync, uv run).'
|
|
15
|
-
- 'Use pytest + pytest-asyncio + pytest-cov for tests.'
|
|
16
|
-
- 'Use httpx for sync/async HTTP and ASGITransport for FastAPI integration tests.'
|
|
17
|
-
- 'Use structlog and bind request_id/user_id in context.'
|
|
18
|
-
- 'Use ruff for lint + format and enforce it in CI.'
|
|
19
|
-
- 'Use mypy or pyright in strict mode.'
|
|
20
|
-
- 'Use pydantic-settings for env loading/validation.'
|
|
21
|
-
- 'Use tenacity for retry/backoff around transient external calls.'
|
|
22
|
-
- 'Use pandera or Great Expectations for data quality validation in pipelines.'
|
|
23
|
-
decision_table:
|
|
24
|
-
- when: 'Package management is needed'
|
|
25
|
-
then: 'Use uv + pyproject.toml + lock file'
|
|
26
|
-
avoid: 'pip-only requirements.txt workflows'
|
|
27
|
-
- when: 'Lint/format tooling is needed'
|
|
28
|
-
then: 'Use ruff as the default toolchain'
|
|
29
|
-
avoid: 'Split flake8/black/isort stacks'
|
|
30
|
-
- when: 'Data quality checks are needed'
|
|
31
|
-
then: 'Use pandera or Great Expectations with explicit checks'
|
|
32
|
-
avoid: 'Scattered inline asserts with no reporting'
|
|
33
|
-
- when: 'HTTP client is needed'
|
|
34
|
-
then: 'Use httpx'
|
|
35
|
-
avoid: 'Mixing requests/aiohttp across services'
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
id: libs-backend-ts
|
|
2
|
-
category: tooling
|
|
3
|
-
tags:
|
|
4
|
-
- typescript
|
|
5
|
-
- nestjs
|
|
6
|
-
- backend
|
|
7
|
-
priority: 25
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT use moment/dayjs. Standardize on date-fns with named imports.'
|
|
11
|
-
- 'DO NOT use jsonwebtoken. Use jose 6+.'
|
|
12
|
-
- 'DO NOT handle Express req/res directly in NestJS handlers.'
|
|
13
|
-
- 'DO NOT import lodash as a full bundle. Prefer native APIs or per-function imports.'
|
|
14
|
-
- 'DO NOT use node-fetch/got in NestJS services. Use @nestjs/axios HttpModule or native fetch().'
|
|
15
|
-
- 'DO NOT use winston/morgan/console.log for app logs. Use pino via nestjs-pino.'
|
|
16
|
-
guidelines:
|
|
17
|
-
- 'Use class-validator + class-transformer DTO validation with ValidationPipe({ whitelist: true }).'
|
|
18
|
-
- 'Use jose for JWT sign/verify and JWKS workflows.'
|
|
19
|
-
- 'Use pino + nestjs-pino as the default structured logger.'
|
|
20
|
-
- 'Use rxjs operators for NestJS interceptors, guards, and event streams.'
|
|
21
|
-
- 'Use Vitest + @nestjs/testing + supertest for unit/e2e tests.'
|
|
22
|
-
- 'Use zod for schema validation outside DTOs (env, external payloads).'
|
|
23
|
-
- 'Keep TypeScript strict mode enabled.'
|
|
24
|
-
decision_table:
|
|
25
|
-
- when: 'JWT auth is needed'
|
|
26
|
-
then: 'Use jose (SignJWT, jwtVerify, createRemoteJWKSet)'
|
|
27
|
-
avoid: 'jsonwebtoken'
|
|
28
|
-
- when: 'Date handling is needed'
|
|
29
|
-
then: 'Use date-fns named imports'
|
|
30
|
-
avoid: 'moment/dayjs'
|
|
31
|
-
- when: 'Utility helpers are needed (clone/groupBy)'
|
|
32
|
-
then: 'Use native JS first; fallback to scoped lodash imports only'
|
|
33
|
-
avoid: 'import _ from "lodash"'
|
|
34
|
-
- when: 'Structured logging is needed'
|
|
35
|
-
then: 'Use pino via nestjs-pino LoggerModule.forRoot()'
|
|
36
|
-
avoid: 'console.log or mixed logging stacks'
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
id: libs-frontend-app
|
|
2
|
-
category: tooling
|
|
3
|
-
tags:
|
|
4
|
-
- dart
|
|
5
|
-
- flutter
|
|
6
|
-
- frontend
|
|
7
|
-
priority: 15
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT use http for API calls. Standardize on dio 5+.'
|
|
11
|
-
- 'DO NOT use Provider or Bloc. Standardize on flutter_riverpod with code generation.'
|
|
12
|
-
- 'DO NOT handwrite data classes (==, hashCode, copyWith, toJson). Use freezed.'
|
|
13
|
-
- 'DO NOT use Navigator 1.0 push/pop APIs for app routing. Use go_router.'
|
|
14
|
-
- 'DO NOT manually implement JSON serialization for models. Use json_serializable/freezed generation.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Use @riverpod with riverpod_generator and build_runner for provider generation.'
|
|
17
|
-
- 'Use freezed for immutable models and unions.'
|
|
18
|
-
- 'Define routes in a central GoRouter config and navigate with context.go()/push().'
|
|
19
|
-
- 'Create one shared Dio instance via Riverpod DI with interceptors and auth headers.'
|
|
20
|
-
- 'Use shared_preferences for non-sensitive keys and flutter_secure_storage for secrets.'
|
|
21
|
-
- 'Use cached_network_image for network image caching and placeholders.'
|
|
22
|
-
- 'Use very_good_analysis and treat warnings as CI failures.'
|
|
23
|
-
- 'Use intl/easy_localization with ARB-based translations.'
|
|
24
|
-
decision_table:
|
|
25
|
-
- when: 'HTTP API calls are needed'
|
|
26
|
-
then: 'Use DI-injected central Dio client'
|
|
27
|
-
avoid: 'Per-feature ad-hoc http clients'
|
|
28
|
-
- when: 'Simple local persistence is needed'
|
|
29
|
-
then: 'Use shared_preferences or flutter_secure_storage by data sensitivity'
|
|
30
|
-
avoid: 'SQLite/Hive for plain key-value settings'
|
|
31
|
-
- when: 'Network images are rendered'
|
|
32
|
-
then: 'Use cached_network_image with placeholder/error states'
|
|
33
|
-
avoid: 'Bare Image.network everywhere'
|
|
34
|
-
- when: 'Test mocking is needed'
|
|
35
|
-
then: 'Use mocktail (class-based, no code generation required)'
|
|
36
|
-
avoid: 'mockito with @GenerateMocks annotation boilerplate'
|
|
37
|
-
- when: 'Code generation is required'
|
|
38
|
-
then: 'Run build_runner watch in dev and build in CI'
|
|
39
|
-
avoid: 'Manually editing generated files'
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
id: libs-frontend-web
|
|
2
|
-
category: tooling
|
|
3
|
-
tags:
|
|
4
|
-
- typescript
|
|
5
|
-
- react
|
|
6
|
-
- nextjs
|
|
7
|
-
- frontend
|
|
8
|
-
priority: 20
|
|
9
|
-
content:
|
|
10
|
-
constraints:
|
|
11
|
-
- 'DO NOT use moment.js or dayjs. Standardize on date-fns with named imports.'
|
|
12
|
-
- 'DO NOT use react-icons. Use lucide-react named imports only.'
|
|
13
|
-
- 'DO NOT use axios in browser code. Use native fetch() for Next.js cache/revalidate integration.'
|
|
14
|
-
- 'DO NOT build conditional className strings manually. Use cn() and cva().'
|
|
15
|
-
- 'DO NOT install parallel UI kits (MUI, Ant, Chakra) alongside shadcn/ui.'
|
|
16
|
-
- 'DO NOT use Redux/Recoil/MobX for local UI state. Use zustand for client UI state.'
|
|
17
|
-
guidelines:
|
|
18
|
-
- 'Keep styling on Tailwind + design tokens (CSS variables) and cva variants.'
|
|
19
|
-
- 'Use next-intl for i18n and next-themes for theme switching.'
|
|
20
|
-
- 'Render Recharts inside client components only.'
|
|
21
|
-
- 'Mount one Sonner <Toaster /> at the app root and call toast() from features.'
|
|
22
|
-
- 'Sanitize user HTML with isomorphic-dompurify before dangerouslySetInnerHTML.'
|
|
23
|
-
- 'Use Vitest + Testing Library; prefer userEvent over fireEvent.'
|
|
24
|
-
decision_table:
|
|
25
|
-
- when: 'Date handling is needed'
|
|
26
|
-
then: 'Use date-fns named imports'
|
|
27
|
-
avoid: 'moment/dayjs'
|
|
28
|
-
- when: 'Icons are needed'
|
|
29
|
-
then: 'Use lucide-react named imports'
|
|
30
|
-
avoid: 'react-icons or inline SVG'
|
|
31
|
-
- when: 'Form validation is needed'
|
|
32
|
-
then: 'Use zod + react-hook-form + zod resolver'
|
|
33
|
-
avoid: 'Manual validation in component event handlers'
|
|
34
|
-
- when: 'User-generated HTML must be rendered'
|
|
35
|
-
then: 'Sanitize with isomorphic-dompurify first, then dangerouslySetInnerHTML'
|
|
36
|
-
avoid: 'Rendering unsanitized HTML (XSS risk)'
|
|
37
|
-
- when: 'Client UI state is needed (modals, wizard step, sidebar)'
|
|
38
|
-
then: 'Use a zustand slice'
|
|
39
|
-
avoid: 'Global Redux/Recoil for simple UI state'
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
id: nestjs-graphql
|
|
2
|
-
category: framework
|
|
3
|
-
tags:
|
|
4
|
-
- typescript
|
|
5
|
-
- nestjs
|
|
6
|
-
- graphql
|
|
7
|
-
priority: 43
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT put business logic in Resolvers. Keep resolvers thin and delegate to Services.'
|
|
11
|
-
- 'DO NOT access raw GraphQL args/context manually when typed decorators are available. Use @Args() with typed DTOs.'
|
|
12
|
-
- 'DO NOT query the DB directly inside @ResolveField(). Use request-scoped DataLoaders.'
|
|
13
|
-
- 'DO NOT expose unauthenticated @Subscription() endpoints. Protect with guards and subscriber checks.'
|
|
14
|
-
- 'DO NOT maintain manual SDL in code-first projects. TypeScript decorators are the source of truth.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Use one resolver per domain entity with @Resolver(), @Query(), @Mutation(), and @ResolveField() responsibilities clearly separated.'
|
|
17
|
-
- 'Register DataLoaders as request-scoped providers to enable per-request batching without cross-request leakage.'
|
|
18
|
-
- 'Add decorator descriptions for public schema types and fields to keep generated SDL self-documenting.'
|
|
19
|
-
- 'Enforce query depth/complexity limits to prevent expensive nested query abuse.'
|
|
20
|
-
- 'Define and register custom scalars (DateTime, UUID, JSON) consistently in GraphQL module config.'
|
|
21
|
-
- 'Reuse Guards/Interceptors from REST and adapt context via GqlExecutionContext.'
|
|
22
|
-
decision_table:
|
|
23
|
-
- when: 'A field resolver loads related data (e.g., user.posts)'
|
|
24
|
-
then: 'Use @ResolveField() + request-scoped DataLoader batching'
|
|
25
|
-
avoid: 'Repository call per parent row (N+1)'
|
|
26
|
-
- when: 'Real-time push is required'
|
|
27
|
-
then: 'Use @Subscription() with Redis PubSub for multi-instance deployments'
|
|
28
|
-
avoid: 'In-memory PubSub in production'
|
|
29
|
-
- when: 'Resolver auth is required'
|
|
30
|
-
then: 'Apply @UseGuards(GqlAuthGuard) and read user from GqlExecutionContext'
|
|
31
|
-
avoid: 'Manual JWT parsing inside resolver methods'
|
package/data/rules/nestjs.yaml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
id: nestjs
|
|
2
|
-
category: framework
|
|
3
|
-
tags:
|
|
4
|
-
- typescript
|
|
5
|
-
- nestjs
|
|
6
|
-
priority: 45
|
|
7
|
-
content:
|
|
8
|
-
constraints:
|
|
9
|
-
- 'DO NOT use @Res() or @Response() for manual response handling in normal routes. Return values and let Nest handle serialization/interceptors.'
|
|
10
|
-
- 'DO NOT put business logic in Controllers. Delegate to Services.'
|
|
11
|
-
- 'DO NOT use forwardRef() as a default fix for circular dependencies. Refactor module boundaries.'
|
|
12
|
-
- 'DO NOT read process.env directly in services/controllers. Use ConfigService with validated schema.'
|
|
13
|
-
- 'DO NOT use console.log for app logging. Use Nest Logger or a DI-managed logger (e.g., pino).'
|
|
14
|
-
guidelines:
|
|
15
|
-
- 'Organize by feature module and co-locate controller/service/DTO files by domain.'
|
|
16
|
-
- 'Use class-validator DTOs for request boundaries and avoid exposing persistence entities directly.'
|
|
17
|
-
- 'Register global ValidationPipe, filters, and guards in main.ts bootstrap.'
|
|
18
|
-
- 'Use custom HttpException types for domain/business failures.'
|
|
19
|
-
- 'Use @nestjs/swagger decorators for REST APIs; GraphQL schema serves as contract for GraphQL APIs.'
|
|
20
|
-
decision_table:
|
|
21
|
-
- when: 'A cross-cutting check needs handler metadata (auth/roles)'
|
|
22
|
-
then: 'Use Guards'
|
|
23
|
-
avoid: 'Middleware for authorization logic'
|
|
24
|
-
- when: 'You need response transform/caching/timing'
|
|
25
|
-
then: 'Use Interceptors'
|
|
26
|
-
avoid: 'Middleware for response-layer behavior'
|
package/data/rules/nextjs.yaml
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
id: nextjs
|
|
2
|
-
category: framework
|
|
3
|
-
tags:
|
|
4
|
-
- typescript
|
|
5
|
-
- react
|
|
6
|
-
- nextjs
|
|
7
|
-
- app-router
|
|
8
|
-
priority: 50
|
|
9
|
-
content:
|
|
10
|
-
constraints:
|
|
11
|
-
- "DO NOT import server-only code into Client Components. Enforce with 'server-only'."
|
|
12
|
-
- 'DO NOT store secrets in NEXT_PUBLIC_ variables. Only NEXT_PUBLIC_ vars are exposed to the browser bundle.'
|
|
13
|
-
- 'DO NOT use next/router in App Router projects. Use next/navigation APIs.'
|
|
14
|
-
guidelines:
|
|
15
|
-
- 'Follow App Router file conventions (page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx).'
|
|
16
|
-
- "Keep Server Actions in dedicated files (e.g., actions.ts) with 'use server'."
|
|
17
|
-
- 'Use next/image with explicit dimensions or fill + sizes.'
|
|
18
|
-
- 'Use next/font in root layout and apply through CSS variables.'
|
|
19
|
-
- 'Use middleware.ts only for cross-cutting concerns (auth redirect, locale, header policy).'
|
|
20
|
-
- 'Export metadata (or generateMetadata) for public pages with title/description/OpenGraph.'
|
|
21
|
-
- 'Add JSON-LD structured data for public pages when SEO/GEO matters.'
|
|
22
|
-
decision_table:
|
|
23
|
-
- when: 'A component needs browser APIs, state hooks, or event handlers'
|
|
24
|
-
then: "Add 'use client' at the smallest leaf component"
|
|
25
|
-
avoid: "Marking high-level parent trees as 'use client'"
|
|
26
|
-
- when: 'Page data is needed for initial render'
|
|
27
|
-
then: 'Fetch in Server Components with async/await'
|
|
28
|
-
avoid: 'Client-side useEffect fetch for primary page data'
|
|
29
|
-
- when: 'Internal form mutation is needed'
|
|
30
|
-
then: 'Use Server Actions'
|
|
31
|
-
avoid: 'route.ts endpoints for simple internal form writes'
|
|
32
|
-
- when: 'External API/webhook endpoint is needed'
|
|
33
|
-
then: 'Use route.ts with explicit HTTP method exports'
|
|
34
|
-
avoid: 'Server Actions for public API integration points'
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
id: prisma-postgresql
|
|
2
|
-
category: database
|
|
3
|
-
tags:
|
|
4
|
-
- typescript
|
|
5
|
-
- prisma
|
|
6
|
-
- postgresql
|
|
7
|
-
priority: 40
|
|
8
|
-
content:
|
|
9
|
-
constraints:
|
|
10
|
-
- 'DO NOT interpolate strings in $queryRawUnsafe. Use $queryRaw tagged templates or parameterized placeholders.'
|
|
11
|
-
- 'DO NOT return Prisma models directly from APIs. Use select or DTO mapping to avoid leaking sensitive fields.'
|
|
12
|
-
- 'DO NOT define mutable models without updatedAt DateTime @updatedAt.'
|
|
13
|
-
- 'DO NOT use $use() middleware. Use Client Extensions ($extends) in Prisma v7+.'
|
|
14
|
-
- 'DO NOT use prisma db push in production. Use prisma migrate deploy with versioned migrations.'
|
|
15
|
-
guidelines:
|
|
16
|
-
- 'Use generator client { provider = "prisma-client"; output = "./generated/prisma/client" }.'
|
|
17
|
-
- 'Use @prisma/adapter-pg and set explicit pool/timeout values for your environment.'
|
|
18
|
-
- 'Add indexes for frequent where/orderBy/join patterns, including composite indexes where needed.'
|
|
19
|
-
- 'Set explicit timeout and maxWait for interactive transactions.'
|
|
20
|
-
- 'Centralize datasource and migration settings in prisma.config.ts.'
|
|
21
|
-
- 'Implement soft delete with a Client Extension query hook that injects deletedAt: null filtering.'
|
|
22
|
-
- 'Prefer cursor pagination over deep skip/take for large tables.'
|
|
23
|
-
- 'Use an external pooler (e.g., PgBouncer) or explicit adapter connection limits in serverless/container workloads.'
|
|
24
|
-
decision_table:
|
|
25
|
-
- when: 'A query needs PostgreSQL features Prisma API cannot express well'
|
|
26
|
-
then: 'Use $queryRaw with tagged templates and typed result mapping'
|
|
27
|
-
avoid: 'Unsafe string-built SQL'
|
|
28
|
-
- when: 'A transaction has dependent steps'
|
|
29
|
-
then: 'Use interactive $transaction(async (tx) => ...) with explicit timeout/maxWait'
|
|
30
|
-
avoid: 'Batch $transaction([...]) for interdependent operations'
|
package/data/rules/python.yaml
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
id: python
|
|
2
|
-
category: language
|
|
3
|
-
tags:
|
|
4
|
-
- python
|
|
5
|
-
priority: 55
|
|
6
|
-
content:
|
|
7
|
-
constraints:
|
|
8
|
-
- 'DO NOT use Any in type hints. Use object or concrete generics instead.'
|
|
9
|
-
- 'DO NOT use mutable default arguments. Use None + factory inside the function.'
|
|
10
|
-
- 'DO NOT use bare except or broad except Exception. Catch specific exception types.'
|
|
11
|
-
- 'DO NOT use wildcard imports.'
|
|
12
|
-
- 'DO NOT use type(x) == T checks. Prefer isinstance() or protocol-based checks.'
|
|
13
|
-
- 'DO NOT use # type: ignore without an explicit error code.'
|
|
14
|
-
guidelines:
|
|
15
|
-
- 'Annotate all function parameters and return types, including -> None.'
|
|
16
|
-
- 'Use Pydantic v2 BaseModel for DTO/config schemas; use field_validator/model_validator APIs.'
|
|
17
|
-
- 'Use TypeAlias, TypeVar, ParamSpec, TypedDict, and Literal to model intent clearly.'
|
|
18
|
-
- 'Keep business logic in pure *_logic.py modules; keep routers/services thin.'
|
|
19
|
-
- 'Use @dataclass(frozen=True) for immutable value objects that do not need runtime validation.'
|
|
20
|
-
- 'Use pathlib.Path for filesystem paths.'
|
|
21
|
-
- 'Use f-strings for string formatting.'
|
|
22
|
-
decision_table:
|
|
23
|
-
- when: 'Structured input/output needs validation or serialization'
|
|
24
|
-
then: 'Use Pydantic v2 models'
|
|
25
|
-
avoid: 'Unvalidated dict payloads'
|
|
26
|
-
- when: 'Immutable value object without runtime validation is enough'
|
|
27
|
-
then: 'Use @dataclass(frozen=True)'
|
|
28
|
-
avoid: 'Using Pydantic where validation is unnecessary'
|
|
29
|
-
- when: 'Runtime type narrowing is needed'
|
|
30
|
-
then: 'Use isinstance() or model_validate()'
|
|
31
|
-
avoid: 'Fragile type()/hasattr() checks'
|