ai-ops-compiler 0.1.4 → 0.1.6
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/data/presets.yaml +4 -0
- package/data/rules/ai-llm-python.yaml +24 -24
- package/data/rules/code-philosophy.yaml +17 -17
- package/data/rules/data-pipeline-python.yaml +21 -21
- package/data/rules/engineering-standards.yaml +26 -27
- package/data/rules/fastapi.yaml +20 -23
- package/data/rules/flutter.yaml +28 -28
- package/data/rules/graphql.yaml +22 -22
- package/data/rules/libs-backend-python.yaml +23 -24
- package/data/rules/libs-backend-ts.yaml +27 -32
- package/data/rules/libs-frontend-app.yaml +27 -30
- package/data/rules/libs-frontend-web.yaml +31 -36
- package/data/rules/nestjs-graphql.yaml +20 -20
- package/data/rules/nestjs.yaml +16 -16
- package/data/rules/nextjs.yaml +22 -22
- package/data/rules/plan-mode.yaml +30 -0
- package/data/rules/prisma-postgresql.yaml +19 -19
- package/data/rules/python.yaml +18 -18
- package/data/rules/shadcn-ui.yaml +23 -23
- package/data/rules/sqlalchemy.yaml +21 -21
- package/data/rules/typescript.yaml +13 -13
- package/dist/index.d.ts +14 -2
- package/dist/index.js +45 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/data/presets.yaml
CHANGED
|
@@ -4,6 +4,7 @@ frontend-web:
|
|
|
4
4
|
- role-persona
|
|
5
5
|
- communication
|
|
6
6
|
- code-philosophy
|
|
7
|
+
- plan-mode
|
|
7
8
|
- naming-convention
|
|
8
9
|
- engineering-standards
|
|
9
10
|
- typescript
|
|
@@ -18,6 +19,7 @@ frontend-app:
|
|
|
18
19
|
- role-persona
|
|
19
20
|
- communication
|
|
20
21
|
- code-philosophy
|
|
22
|
+
- plan-mode
|
|
21
23
|
- naming-convention
|
|
22
24
|
- engineering-standards
|
|
23
25
|
- flutter
|
|
@@ -29,6 +31,7 @@ backend-ts:
|
|
|
29
31
|
- role-persona
|
|
30
32
|
- communication
|
|
31
33
|
- code-philosophy
|
|
34
|
+
- plan-mode
|
|
32
35
|
- naming-convention
|
|
33
36
|
- engineering-standards
|
|
34
37
|
- typescript
|
|
@@ -44,6 +47,7 @@ backend-python:
|
|
|
44
47
|
- role-persona
|
|
45
48
|
- communication
|
|
46
49
|
- code-philosophy
|
|
50
|
+
- plan-mode
|
|
47
51
|
- naming-convention
|
|
48
52
|
- engineering-standards
|
|
49
53
|
- python
|
|
@@ -7,29 +7,29 @@ tags:
|
|
|
7
7
|
priority: 28
|
|
8
8
|
content:
|
|
9
9
|
constraints:
|
|
10
|
-
- 'DO NOT parse
|
|
11
|
-
- 'DO NOT hardcode prompts inline.
|
|
12
|
-
- 'DO NOT call
|
|
13
|
-
- 'DO NOT ignore token limits.
|
|
14
|
-
- 'DO NOT log
|
|
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
15
|
guidelines:
|
|
16
|
-
- 'Use instructor or native
|
|
17
|
-
- 'Apply
|
|
18
|
-
- '
|
|
19
|
-
- 'Track
|
|
20
|
-
- '
|
|
21
|
-
- '
|
|
22
|
-
- 'Define
|
|
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
23
|
decision_table:
|
|
24
|
-
- when: '
|
|
25
|
-
then: 'Use
|
|
26
|
-
avoid: 'Regex parsing
|
|
27
|
-
- when: 'Selecting a model
|
|
28
|
-
then: 'Use the smallest model
|
|
29
|
-
avoid: 'Defaulting to the largest
|
|
30
|
-
- when: 'Input
|
|
31
|
-
then: 'Chunk with overlap
|
|
32
|
-
avoid: 'Silent
|
|
33
|
-
- when: 'Multiple
|
|
34
|
-
then: 'Use
|
|
35
|
-
avoid: '
|
|
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'
|
|
@@ -9,22 +9,22 @@ tags:
|
|
|
9
9
|
priority: 80
|
|
10
10
|
content:
|
|
11
11
|
constraints:
|
|
12
|
-
-
|
|
13
|
-
- 'DO NOT extract
|
|
14
|
-
- 'DO NOT mutate state. Use const
|
|
15
|
-
- 'DO NOT
|
|
12
|
+
- 'DO NOT write clever or opaque code. Prefer explicit intent over tricks.'
|
|
13
|
+
- 'DO NOT extract shared abstractions before the Rule of Three.'
|
|
14
|
+
- 'DO NOT mutate state. Use const/final and spread operators for immutability.'
|
|
15
|
+
- 'DO NOT mix side effects into core business functions.'
|
|
16
16
|
guidelines:
|
|
17
|
-
- '
|
|
18
|
-
- 'Prefer duplication over
|
|
19
|
-
- 'For
|
|
20
|
-
- '
|
|
21
|
-
- 'Use const/final
|
|
17
|
+
- 'Optimize for readability and maintainability first.'
|
|
18
|
+
- 'Prefer temporary duplication over premature abstraction.'
|
|
19
|
+
- 'For non-trivial business rules, start with a failing test (TDD).'
|
|
20
|
+
- 'Use a functional-core / imperative-shell structure.'
|
|
21
|
+
- 'Use immutable updates (const/final, copy/spread patterns).'
|
|
22
22
|
decision_table:
|
|
23
|
-
- when: '
|
|
24
|
-
then: 'Write
|
|
25
|
-
avoid: '
|
|
26
|
-
- when: 'Similar code appears in
|
|
27
|
-
then: 'Keep
|
|
28
|
-
avoid: '
|
|
29
|
-
- when: 'Similar code appears in
|
|
30
|
-
then: 'Extract
|
|
23
|
+
- when: 'Implementing complex business logic'
|
|
24
|
+
then: 'Write failing tests first, then implement pure functions'
|
|
25
|
+
avoid: 'Implementation-first with mixed I/O'
|
|
26
|
+
- when: 'Similar code appears in two places'
|
|
27
|
+
then: 'Keep duplication temporarily'
|
|
28
|
+
avoid: 'Early shared abstraction'
|
|
29
|
+
- when: 'Similar code appears in three or more places'
|
|
30
|
+
then: 'Extract a clearly named shared function'
|
|
@@ -8,27 +8,27 @@ tags:
|
|
|
8
8
|
priority: 33
|
|
9
9
|
content:
|
|
10
10
|
constraints:
|
|
11
|
-
- 'DO NOT iterate
|
|
12
|
-
- 'DO NOT use Pandas .apply(axis=1). It runs at Python speed
|
|
13
|
-
- 'DO NOT load
|
|
14
|
-
- 'DO NOT rely on
|
|
15
|
-
- 'DO NOT mutate DataFrames in-place
|
|
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
16
|
guidelines:
|
|
17
|
-
- 'Prefer Polars for new pipelines
|
|
18
|
-
- 'Use DuckDB for SQL
|
|
19
|
-
- 'Use
|
|
20
|
-
- 'Write
|
|
21
|
-
- 'Enforce explicit schemas at
|
|
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
22
|
decision_table:
|
|
23
|
-
- when: '
|
|
24
|
-
then: 'Polars lazy
|
|
25
|
-
avoid: '
|
|
26
|
-
- when: 'Ad-hoc SQL analysis on local
|
|
27
|
-
then: 'DuckDB
|
|
28
|
-
avoid: '
|
|
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
29
|
- when: 'Data exceeds available memory'
|
|
30
|
-
then: 'Polars scan_*
|
|
31
|
-
avoid: 'pandas
|
|
32
|
-
- when: '
|
|
33
|
-
then: '
|
|
34
|
-
avoid: '
|
|
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'
|
|
@@ -8,33 +8,32 @@ tags:
|
|
|
8
8
|
priority: 70
|
|
9
9
|
content:
|
|
10
10
|
constraints:
|
|
11
|
-
- 'DO NOT use floating-point
|
|
12
|
-
- 'DO NOT expose sequential
|
|
13
|
-
- 'DO NOT store or transmit
|
|
14
|
-
- 'DO NOT use magic numbers or
|
|
15
|
-
- 'DO NOT return inconsistent error
|
|
16
|
-
- 'DO NOT accept unbounded input. Enforce
|
|
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
17
|
guidelines:
|
|
18
|
-
- 'UTC
|
|
19
|
-
- 'Wrap
|
|
20
|
-
- 'Propagate
|
|
21
|
-
- 'Validate environment variables at
|
|
22
|
-
- '
|
|
23
|
-
- '
|
|
24
|
-
- 'Expose GET /health (liveness
|
|
25
|
-
- '
|
|
26
|
-
- '
|
|
27
|
-
- 'Handle SIGTERM for graceful shutdown: (1) stop accepting new requests, (2) wait for in-flight requests to complete, (3) close DB connection pools and message queue connections before exiting. Align the shutdown timeout with Kubernetes terminationGracePeriodSeconds to avoid forceful pod kills.'
|
|
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.'
|
|
28
27
|
decision_table:
|
|
29
28
|
- when: 'A new entity needs a primary key'
|
|
30
|
-
then: 'Use UUID v7
|
|
31
|
-
avoid: 'Auto-increment
|
|
32
|
-
- when: 'An
|
|
33
|
-
then: '
|
|
34
|
-
avoid: '
|
|
35
|
-
- when: '
|
|
36
|
-
then: 'Use ISO 8601 UTC
|
|
37
|
-
avoid: '
|
|
38
|
-
- when: 'An API needs
|
|
39
|
-
then: 'Use URL
|
|
40
|
-
avoid: 'Header-
|
|
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
CHANGED
|
@@ -7,31 +7,28 @@ tags:
|
|
|
7
7
|
priority: 42
|
|
8
8
|
content:
|
|
9
9
|
constraints:
|
|
10
|
-
- 'DO NOT use plain dict
|
|
11
|
-
- 'DO NOT
|
|
12
|
-
- 'DO NOT return
|
|
13
|
-
- 'DO NOT
|
|
14
|
-
- 'DO NOT hardcode CORS origins. Load
|
|
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
15
|
guidelines:
|
|
16
|
-
- 'Use Depends() for
|
|
17
|
-
- '
|
|
18
|
-
- '
|
|
19
|
-
- 'Use Annotated[T, Depends(...)]
|
|
20
|
-
- 'Use Pydantic Settings
|
|
21
|
-
- 'Use lifespan
|
|
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
22
|
decision_table:
|
|
23
23
|
- when: 'Endpoint is CPU-bound'
|
|
24
|
-
then: 'Use def
|
|
25
|
-
avoid: 'async def with blocking code
|
|
24
|
+
then: 'Use sync def and let FastAPI run it in the threadpool'
|
|
25
|
+
avoid: 'async def with blocking code'
|
|
26
26
|
- when: 'Endpoint is I/O-bound'
|
|
27
|
-
then: 'Use async def with async drivers (asyncpg, httpx
|
|
28
|
-
avoid: '
|
|
29
|
-
- when: 'Shared
|
|
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
30
|
then: 'Use lifespan async context manager'
|
|
31
|
-
avoid: '@app.on_event
|
|
32
|
-
- when: '
|
|
33
|
-
then: '
|
|
34
|
-
avoid: '
|
|
35
|
-
- when: 'Fire-and-forget work is needed after responding'
|
|
36
|
-
then: 'Lightweight tasks: BackgroundTasks (FastAPI built-in). Heavy tasks or retry needed: Celery or TaskIQ (async-native).'
|
|
37
|
-
avoid: 'Awaiting the task synchronously inside the route handler (delays response)'
|
|
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
CHANGED
|
@@ -8,33 +8,33 @@ tags:
|
|
|
8
8
|
priority: 30
|
|
9
9
|
content:
|
|
10
10
|
constraints:
|
|
11
|
-
- 'DO NOT use
|
|
12
|
-
- 'DO NOT
|
|
13
|
-
-
|
|
14
|
-
- 'DO NOT use GlobalKey to
|
|
15
|
-
- 'DO NOT
|
|
16
|
-
- 'DO NOT
|
|
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
17
|
guidelines:
|
|
18
|
-
- 'Use Riverpod with code generation
|
|
19
|
-
- '
|
|
20
|
-
- 'Use sealed
|
|
21
|
-
-
|
|
22
|
-
- 'Use
|
|
23
|
-
- 'Use
|
|
24
|
-
- 'Write widget tests with
|
|
25
|
-
- '
|
|
26
|
-
- 'Handle async states explicitly
|
|
27
|
-
- '
|
|
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
28
|
decision_table:
|
|
29
|
-
- when: 'State is
|
|
30
|
-
then: 'Use StatefulWidget or flutter_hooks
|
|
31
|
-
avoid: 'Creating
|
|
32
|
-
- when:
|
|
33
|
-
then: 'Use Riverpod Notifier
|
|
34
|
-
avoid: '
|
|
35
|
-
- when: 'A
|
|
36
|
-
then: '
|
|
37
|
-
avoid: '
|
|
38
|
-
- when: '
|
|
39
|
-
then: '
|
|
40
|
-
avoid: 'Imperative Navigator
|
|
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'
|
package/data/rules/graphql.yaml
CHANGED
|
@@ -7,28 +7,28 @@ tags:
|
|
|
7
7
|
priority: 48
|
|
8
8
|
content:
|
|
9
9
|
constraints:
|
|
10
|
-
- 'DO NOT rely on implicit nullability
|
|
11
|
-
- 'DO NOT perform
|
|
12
|
-
- 'DO NOT
|
|
13
|
-
- 'DO NOT return unbounded lists. Every collection
|
|
14
|
-
- 'DO NOT expose internal implementation details in enum
|
|
10
|
+
- 'DO NOT rely on implicit nullability. Mark every field intentionally (prefer non-null by default).'
|
|
11
|
+
- 'DO NOT perform mutations in Query resolvers. Reads belong to Query, writes belong to Mutation.'
|
|
12
|
+
- 'DO NOT return a generic Error type. Use operation-specific typed errors (union or payload errors).'
|
|
13
|
+
- 'DO NOT return unbounded lists. Every collection must support pagination.'
|
|
14
|
+
- 'DO NOT expose internal implementation details in enum values. Use semantic SCREAMING_SNAKE_CASE names.'
|
|
15
15
|
guidelines:
|
|
16
|
-
- 'Prefer cursor
|
|
17
|
-
- '
|
|
18
|
-
- 'Return
|
|
19
|
-
- '
|
|
20
|
-
- 'Follow
|
|
21
|
-
- '
|
|
16
|
+
- 'Prefer cursor pagination (first/after) for user-facing lists; use offset pagination only for bounded admin tables.'
|
|
17
|
+
- 'Use a single input object for every mutation: mutation X($input: XInput!).'
|
|
18
|
+
- 'Return mutation payload types that can carry both result data and structured errors.'
|
|
19
|
+
- 'Use DataLoader for related entity resolution; field resolvers must not issue per-parent DB queries.'
|
|
20
|
+
- 'Follow naming conventions: PascalCase types/enums, camelCase fields/args, SCREAMING_SNAKE_CASE enum values.'
|
|
21
|
+
- 'Deprecate fields first with @deprecated(reason: "...") and remove only in the next major version.'
|
|
22
22
|
decision_table:
|
|
23
23
|
- when: 'A field returns a collection'
|
|
24
|
-
then: 'Use cursor
|
|
25
|
-
avoid: '
|
|
26
|
-
- when: 'A mutation
|
|
27
|
-
then: '
|
|
28
|
-
avoid: 'Throwing top-level GraphQL errors for expected
|
|
29
|
-
- when: 'A
|
|
30
|
-
then: '
|
|
31
|
-
avoid: '
|
|
32
|
-
- when: '
|
|
33
|
-
then: 'Define
|
|
34
|
-
avoid: 'Accepting
|
|
24
|
+
then: 'Use cursor pagination with a stable cursor'
|
|
25
|
+
avoid: 'Returning unbounded [Node!]! lists'
|
|
26
|
+
- when: 'A mutation must report business failure'
|
|
27
|
+
then: 'Use both a Payload wrapper type AND typed union errors together — Payload carries partial success data, union enables __typename switching; they are complementary, not alternatives'
|
|
28
|
+
avoid: 'Throwing top-level GraphQL errors for expected failures, or using only a bare union without a Payload'
|
|
29
|
+
- when: 'A field is removed or renamed'
|
|
30
|
+
then: 'Deprecate first, migrate clients, then remove in next major'
|
|
31
|
+
avoid: 'Immediate schema removal'
|
|
32
|
+
- when: 'Filtering or sorting is complex'
|
|
33
|
+
then: 'Define typed FilterInput/OrderByInput types'
|
|
34
|
+
avoid: 'Accepting raw JSON or string filters'
|
|
@@ -6,31 +6,30 @@ tags:
|
|
|
6
6
|
priority: 22
|
|
7
7
|
content:
|
|
8
8
|
constraints:
|
|
9
|
-
- 'DO NOT use requirements.txt
|
|
10
|
-
- 'DO NOT use print() for logging. Use
|
|
11
|
-
- 'DO NOT use unittest.TestCase. Use pytest with
|
|
12
|
-
- 'DO NOT
|
|
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
13
|
guidelines:
|
|
14
|
-
- 'uv
|
|
15
|
-
- 'pytest
|
|
16
|
-
- 'httpx
|
|
17
|
-
- 'structlog
|
|
18
|
-
- 'ruff
|
|
19
|
-
- 'mypy
|
|
20
|
-
- 'pydantic-settings
|
|
21
|
-
- 'tenacity
|
|
22
|
-
- '
|
|
23
|
-
- 'polars 1+ / duckdb 1+ — core data processing stack. Works in conjunction with data-pipeline-python rule.'
|
|
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.'
|
|
24
23
|
decision_table:
|
|
25
24
|
- when: 'Package management is needed'
|
|
26
|
-
then: 'Use uv + pyproject.toml +
|
|
27
|
-
avoid: 'pip
|
|
28
|
-
- when: 'Lint
|
|
29
|
-
then: 'Use ruff as the
|
|
30
|
-
avoid: 'flake8
|
|
31
|
-
- when: 'Data quality
|
|
32
|
-
then: '
|
|
33
|
-
avoid: 'Scattered
|
|
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'
|
|
34
33
|
- when: 'HTTP client is needed'
|
|
35
|
-
then: 'Use httpx
|
|
36
|
-
avoid: 'requests
|
|
34
|
+
then: 'Use httpx'
|
|
35
|
+
avoid: 'Mixing requests/aiohttp across services'
|
|
@@ -7,37 +7,32 @@ tags:
|
|
|
7
7
|
priority: 25
|
|
8
8
|
content:
|
|
9
9
|
constraints:
|
|
10
|
-
- 'DO NOT use moment.
|
|
11
|
-
- 'DO NOT use jsonwebtoken. Use jose 6
|
|
12
|
-
- 'DO NOT
|
|
13
|
-
- 'DO NOT import lodash as a full bundle
|
|
14
|
-
- 'DO NOT use node-fetch
|
|
15
|
-
- 'DO NOT use winston
|
|
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
16
|
guidelines:
|
|
17
|
-
- 'class-validator
|
|
18
|
-
- '@nestjs/graphql
|
|
19
|
-
- '
|
|
20
|
-
- '
|
|
21
|
-
- '
|
|
22
|
-
- '
|
|
23
|
-
- '
|
|
24
|
-
- '
|
|
25
|
-
- '
|
|
26
|
-
- 'typescript 5+ with strict: true / @swc/core — type checking and fast transpilation in development and CI.'
|
|
27
|
-
- 'axios via @nestjs/axios HttpModule — outbound HTTP calls that require interceptors, retry logic, or request/response transformation.'
|
|
17
|
+
- 'Use class-validator + class-transformer DTO validation with ValidationPipe({ whitelist: true }).'
|
|
18
|
+
- 'Use @nestjs/graphql + @nestjs/apollo code-first for GraphQL APIs.'
|
|
19
|
+
- 'Use GraphQL Codegen for operation/result type generation.'
|
|
20
|
+
- 'Use jose for JWT sign/verify and JWKS workflows.'
|
|
21
|
+
- 'Use pino + nestjs-pino as the default structured logger.'
|
|
22
|
+
- 'Use rxjs operators for NestJS interceptors, guards, and event streams.'
|
|
23
|
+
- 'Use Vitest + @nestjs/testing + supertest for unit/e2e tests.'
|
|
24
|
+
- 'Use zod for schema validation outside DTOs (env, external payloads).'
|
|
25
|
+
- 'Keep TypeScript strict mode enabled.'
|
|
28
26
|
decision_table:
|
|
29
|
-
- when: 'JWT
|
|
30
|
-
then: 'Use jose
|
|
31
|
-
avoid: 'jsonwebtoken
|
|
32
|
-
- when: 'Date
|
|
33
|
-
then: 'Use date-fns
|
|
34
|
-
avoid: 'moment
|
|
35
|
-
- when: '
|
|
36
|
-
then: 'Use native JS first
|
|
37
|
-
avoid:
|
|
38
|
-
- when: '
|
|
39
|
-
then: 'Use
|
|
40
|
-
avoid: '
|
|
41
|
-
- when: 'Structured application logging is needed'
|
|
42
|
-
then: 'Use pino 9+ via nestjs-pino 4+ (LoggerModule.forRoot)'
|
|
43
|
-
avoid: 'winston (slow JSON serialization), morgan (HTTP-only), console.log (unstructured)'
|
|
27
|
+
- when: 'JWT auth is needed'
|
|
28
|
+
then: 'Use jose (SignJWT, jwtVerify, createRemoteJWKSet)'
|
|
29
|
+
avoid: 'jsonwebtoken'
|
|
30
|
+
- when: 'Date handling is needed'
|
|
31
|
+
then: 'Use date-fns named imports'
|
|
32
|
+
avoid: 'moment/dayjs'
|
|
33
|
+
- when: 'Utility helpers are needed (clone/groupBy)'
|
|
34
|
+
then: 'Use native JS first; fallback to scoped lodash imports only'
|
|
35
|
+
avoid: 'import _ from "lodash"'
|
|
36
|
+
- when: 'Structured logging is needed'
|
|
37
|
+
then: 'Use pino via nestjs-pino LoggerModule.forRoot()'
|
|
38
|
+
avoid: 'console.log or mixed logging stacks'
|