@thebassclef/lite 0.1.0 → 0.1.3
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/dist/cli.cjs +40 -6
- package/dist/cli.js +40 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/substrate/.bassclef/lite-manifest.json +999 -92
- package/substrate/.claude/hooks/longrun-prep-compounding-axis-check.sh +492 -0
- package/substrate/.claude/hooks/longrun-prep-compounding-sequence-check.sh +492 -0
- package/substrate/.claude/hooks/pre-commit-gate.sh +1 -2
- package/substrate/.claude/hooks/turn-prose-kiss-check.sh +30 -1
- package/substrate/.claude/luminaries/glenford-myers.md +230 -0
- package/substrate/.claude/luminaries/hunt-thomas.md +115 -0
- package/substrate/.claude/luminaries/hyrum-wright.md +94 -0
- package/substrate/.claude/luminaries/michael-feathers.md +2 -2
- package/substrate/.claude/luminaries/tony-hoare.md +170 -0
- package/substrate/.claude/luminaries/vaughn-vernon.md +50 -0
- package/substrate/.claude/luminaries/w-edwards-deming.md +158 -0
- package/substrate/.claude/rules/accessor-library-discipline.md +138 -0
- package/substrate/.claude/rules/adr-discipline.md +120 -0
- package/substrate/.claude/rules/api-conventions.md +125 -0
- package/substrate/.claude/rules/bootstrap-pair-discipline.md +141 -0
- package/substrate/.claude/rules/cold-adopter-harness-discipline.md +129 -0
- package/substrate/.claude/rules/compounding-axis-fresh-analysis.md +188 -0
- package/substrate/.claude/rules/compounding-sequence-fresh-analysis.md +188 -0
- package/substrate/.claude/rules/defensive-bash.md +68 -0
- package/substrate/.claude/rules/deferred-actions.md +233 -0
- package/substrate/.claude/rules/github-issue-flash-tweet.md +156 -0
- package/substrate/.claude/rules/hook-wire-on-author.md +103 -0
- package/substrate/.claude/rules/iteration-bet-brief-completeness.md +54 -0
- package/substrate/.claude/rules/lite-manifest-schema-change-discipline.md +3 -3
- package/substrate/.claude/rules/longrun-prep-plan-doc-compression.md +89 -0
- package/substrate/.claude/rules/loop-discipline.md +81 -0
- package/substrate/.claude/rules/manual-prod-approval.md +100 -0
- package/substrate/.claude/rules/marker-enrichment-discipline.md +99 -0
- package/substrate/.claude/rules/mobile-ephemeral-session.md +109 -0
- package/substrate/.claude/rules/new-dependency-check.md +51 -0
- package/substrate/.claude/rules/option-label-discipline.md +108 -0
- package/substrate/.claude/rules/pattern-annotation.md +100 -0
- package/substrate/.claude/rules/plain-english-discipline.md +11 -9
- package/substrate/.claude/rules/plan-enumeration-needs-value-props.md +211 -0
- package/substrate/.claude/rules/pr-title-shape.md +161 -0
- package/substrate/.claude/rules/prototype-workflow.md +65 -0
- package/substrate/.claude/rules/reserved-skill-names.md +123 -0
- package/substrate/.claude/rules/schema-management.md +49 -0
- package/substrate/.claude/rules/security.md +37 -0
- package/substrate/.claude/rules/skill-composition-declarations.md +124 -0
- package/substrate/.claude/rules/skill-description-clarity.md +247 -0
- package/substrate/.claude/rules/skill-procedure-step-list.md +137 -0
- package/substrate/.claude/rules/stuck-signal-diagnostic.md +140 -0
- package/substrate/.claude/rules/substrate-config-schema.md +98 -0
- package/substrate/.claude/rules/test-list-discipline.md +175 -0
- package/substrate/.claude/rules/test-sufficiency.md +210 -0
- package/substrate/.claude/rules/testing-tier-config.md +145 -0
- package/substrate/.claude/rules/testing.md +38 -0
- package/substrate/.claude/rules/turn-estimate-grounding.md +134 -0
- package/substrate/.claude/rules/visual-hierarchy.md +437 -0
- package/substrate/.claude/rules/we-dont-break-adopters.md +126 -0
- package/substrate/.claude/rules/wu-sequencing-compounds.md +145 -0
- package/substrate/.claude/skills/build/SKILL.md +1 -1
- package/substrate/.claude/skills/chronicle/SKILL.md +55 -0
- package/substrate/.claude/skills/clean-artifacts/SKILL.md +249 -0
- package/substrate/.claude/skills/decompose/SKILL.md +1 -1
- package/substrate/.claude/skills/diagnose/SKILL.md +1 -1
- package/substrate/.claude/skills/feynman/SKILL.md +90 -0
- package/substrate/.claude/skills/howdoi/SKILL.md +1 -1
- package/substrate/.claude/skills/ia-model/SKILL.md +1 -1
- package/substrate/.claude/skills/interaction-design/SKILL.md +1 -1
- package/substrate/.claude/skills/interpret-input/SKILL.md +8 -8
- package/substrate/.claude/skills/journal/SKILL.md +209 -0
- package/substrate/.claude/skills/kiss/SKILL.md +1 -1
- package/substrate/.claude/skills/launch/SKILL.md +14 -23
- package/substrate/.claude/skills/lean-canvas/SKILL.md +1 -1
- package/substrate/.claude/skills/longrun/SKILL.md +45 -8
- package/substrate/.claude/skills/luminary/SKILL.md +1 -1
- package/substrate/.claude/skills/ogilvy-writing-audit/SKILL.md +1 -1
- package/substrate/.claude/skills/onboard-repo/SKILL.md +143 -709
- package/substrate/.claude/skills/pattern-review/SKILL.md +1 -1
- package/substrate/.claude/skills/personas/SKILL.md +5 -5
- package/substrate/.claude/skills/promote/SKILL.md +1 -1
- package/substrate/.claude/skills/requirement/SKILL.md +1 -1
- package/substrate/.claude/skills/retro/SKILL.md +1 -1
- package/substrate/.claude/skills/riff/SKILL.md +1 -1
- package/substrate/.claude/skills/roadmap-reconcile/SKILL.md +1 -1
- package/substrate/.claude/skills/session-end/SKILL.md +1 -1
- package/substrate/.claude/skills/session-log/SKILL.md +3 -3
- package/substrate/.claude/skills/skills/SKILL.md +1 -1
- package/substrate/.claude/skills/spec/SKILL.md +1 -1
- package/substrate/.claude/skills/sprint/SKILL.md +1 -1
- package/substrate/.claude/skills/stage/SKILL.md +1 -1
- package/substrate/.claude/skills/state-a-problem/SKILL.md +1 -1
- package/substrate/.claude/skills/temperance/SKILL.md +1 -1
- package/substrate/.claude/skills/use-case/SKILL.md +1 -1
- package/substrate/.claude/skills/user-stories/SKILL.md +1 -1
- package/substrate/.claude/skills/value-prop/SKILL.md +1 -1
- package/substrate/.claude/skills/verify/SKILL.md +1 -1
- package/substrate/.claude/skills/visual-review/SKILL.md +503 -0
- package/substrate/.claude/skills/whats-the-plan/SKILL.md +202 -0
- package/substrate/.claude/skills/whereami/SKILL.md +2 -2
- package/substrate/CONTRIBUTING.md +1 -1
- package/substrate/README.md +5 -5
- package/substrate/lib/prose-scan-boundary.sh +171 -0
- package/substrate/lib/tier-check.sh +50 -1
- package/substrate/lib/tier-dependency-audit.sh +159 -4
- package/substrate/presence/install/bassclef-sync.template.sh +1 -1
- package/substrate/scripts/generate-lite-manifest.sh +21 -5
- package/substrate/standards/adr-template.md +86 -0
- package/substrate/standards/api-conventions/nextjs.md +84 -0
- package/substrate/standards/artifact-composition.md +209 -0
- package/substrate/standards/bash-hook-safety.md +246 -0
- package/substrate/standards/branch-stacking.md +408 -0
- package/substrate/standards/code-safety-principles.md +176 -0
- package/substrate/standards/composer-prerequisites.md +155 -0
- package/substrate/standards/dependency-discipline/cargo.md +39 -0
- package/substrate/standards/dependency-discipline/gem.md +43 -0
- package/substrate/standards/dependency-discipline/go-mod.md +41 -0
- package/substrate/standards/dependency-discipline/npm.md +42 -0
- package/substrate/standards/dependency-discipline/pip.md +42 -0
- package/substrate/standards/deployment-topology/ec2-tailscale.md +225 -0
- package/substrate/standards/deployment-topology.md +69 -0
- package/substrate/standards/docs-sync-allowlist.md +4 -4
- package/substrate/standards/domain-and-dns.md +145 -0
- package/substrate/standards/frontend-stack.md +67 -0
- package/substrate/standards/frontmatter-schema.md +154 -0
- package/substrate/standards/hook-injection-discipline.md +202 -0
- package/substrate/standards/hook-install-class.md +215 -0
- package/substrate/standards/input-handler-interface.md +152 -0
- package/substrate/standards/lite-manifest-schema-changes.md +60 -0
- package/substrate/standards/luminary-matching.md +105 -0
- package/substrate/standards/migration-discipline/active-record.md +50 -0
- package/substrate/standards/migration-discipline/alembic.md +43 -0
- package/substrate/standards/migration-discipline/gorm.md +50 -0
- package/substrate/standards/migration-discipline/prisma.md +53 -0
- package/substrate/standards/migration-discipline/sqlalchemy.md +51 -0
- package/substrate/standards/mobile-ephemeral-session.md +167 -0
- package/substrate/standards/model-routing-discipline.md +160 -0
- package/substrate/standards/persona-schema.md +229 -0
- package/substrate/standards/pluggable-luminaries.md +323 -0
- package/substrate/standards/pr-body-discipline.md +115 -0
- package/substrate/standards/preview-state-schema.md +189 -0
- package/substrate/standards/reserved-skill-names.md +120 -0
- package/substrate/standards/scannable-multi-option-output.md +261 -0
- package/substrate/standards/sdlc-gates/typescript.md +57 -0
- package/substrate/standards/session-board.md +256 -0
- package/substrate/standards/state-spine-contract.md +255 -0
- package/substrate/standards/steering-hints/kiss-words.md +11 -0
- package/substrate/standards/substrate-config-schema.md +267 -0
- package/substrate/standards/tier-dependency-analysis.md +1 -1
- package/substrate/standards/tier-tag-schema.md +1 -1
- package/substrate/standards/two-layer-config.md +99 -0
- package/substrate/standards/use-case-format.md +292 -0
- package/substrate/standards/user-story-invest.md +268 -0
- package/substrate/standards/velocity-and-appetite.md +229 -0
- package/substrate/standards/voice-input-pattern.md +119 -0
- package/substrate/standards/worktree-management.md +211 -0
- package/substrate/templates/chronicle-template.md +75 -0
- package/substrate/templates/memory-proposal-template.md +77 -0
- package/substrate/templates/persona-template.md +200 -0
- package/substrate/templates/pr-faq.md +45 -0
- package/substrate/templates/secret-rotation-template.md +162 -0
- package/substrate/templates/spec-template.md +131 -0
- package/substrate/templates/use-case-template.md +194 -0
- package/substrate/templates/user-story-template.md +107 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: "This standard codifies language-agnostic principles for writing safer code across bassclef's supported stacks (TypeScript, Python, Ruby, Java, Go, bash)."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Safety Principles — Language-Agnostic
|
|
7
|
+
|
|
8
|
+
This standard codifies language-agnostic principles for writing safer code across bassclef's supported stacks (TypeScript, Python, Ruby, Java, Go, bash). It is the substrate-internal companion to the Saltzer & Schroeder luminary — the luminary names WHY each principle matters at the protection-mechanism design level; this standard names WHAT the principle looks like in source code.
|
|
9
|
+
|
|
10
|
+
## Why this standard exists
|
|
11
|
+
|
|
12
|
+
Bassclef's `.claude/rules/security.md` is scoped to web-application source files (`.ts`, `.tsx`, `.json`, `.env`, `Dockerfile`). It catches the OWASP-top-10 surface for the web layer. It does not cover:
|
|
13
|
+
|
|
14
|
+
- Bash hooks (bassclef's own implementation language for `.claude/hooks/*.sh`)
|
|
15
|
+
- Backend daemons (Python, Go, Java, Ruby — any language an adopter ships)
|
|
16
|
+
- Code review of cross-cutting concerns (default-behavior choices, scope choices, override-path design)
|
|
17
|
+
|
|
18
|
+
The principles in this standard apply to ALL six languages because they are about the *shape* of code, not language-specific syntax. The downstream stack-specific guides (Phase X-3 `bash-hook-safety.md`; Phase Y reference configs per stack) instantiate these principles in the language idiom of the day.
|
|
19
|
+
|
|
20
|
+
## Anchor luminary
|
|
21
|
+
|
|
22
|
+
`@luminary saltzer-schroeder` is the authority. Their 1975 paper articulated the 8 principles for protection-mechanism design that this standard implements at the source-code level.
|
|
23
|
+
|
|
24
|
+
INSTEAD of inventing bassclef-specific principles: this standard maps Saltzer & Schroeder's 8 principles into 6 source-code disciplines that any language can express. The 1975 framing predates every modern attack class and still holds.
|
|
25
|
+
|
|
26
|
+
## The six source-code disciplines
|
|
27
|
+
|
|
28
|
+
### 1. Validate at boundaries
|
|
29
|
+
|
|
30
|
+
Every value entering the system from an external source must be validated at the boundary. After validation, internal code treats the value as trusted.
|
|
31
|
+
|
|
32
|
+
INSTEAD of validating at every call site: validate once at the entry boundary; pass typed values to internal code that trusts them.
|
|
33
|
+
|
|
34
|
+
**Boundaries to validate at:**
|
|
35
|
+
|
|
36
|
+
- HTTP request handlers (parse + validate body, query, headers, path params before any business logic)
|
|
37
|
+
- CLI argument parsers (validate flag values before dispatch)
|
|
38
|
+
- File parsers (validate schema/structure before consuming content)
|
|
39
|
+
- Foreign-key dereferences across service boundaries (validate the referenced object's shape before use)
|
|
40
|
+
- Environment variable reads at process startup (validate types + ranges before runtime use)
|
|
41
|
+
|
|
42
|
+
**Per language idiom:**
|
|
43
|
+
|
|
44
|
+
| Stack | Validation primitive |
|
|
45
|
+
|---|---|
|
|
46
|
+
| TypeScript | Zod / Yup / io-ts schema at handler entry |
|
|
47
|
+
| Python | Pydantic model at handler entry; argparse with custom types for CLI |
|
|
48
|
+
| Ruby | dry-validation or ActiveModel validation at controller boundary |
|
|
49
|
+
| Java | Jakarta Bean Validation (JSR 380) annotations; manual validators for non-bean inputs |
|
|
50
|
+
| Go | github.com/go-playground/validator at handler entry; validate.Var for ad-hoc |
|
|
51
|
+
| Bash | argparse-style validation in helper functions; `[[ -n "${var:?}" ]]` for required values |
|
|
52
|
+
|
|
53
|
+
### 2. Fail-safe defaults
|
|
54
|
+
|
|
55
|
+
Default behavior denies / refuses / rejects unless an explicit signal permits. The author of a new code path is forced to make the permission decision visible.
|
|
56
|
+
|
|
57
|
+
INSTEAD of "permit by default, deny on exclusion list": deny by default, permit on explicit allowlist. The allowlist makes new permissions visible; the exclusion list makes new denials invisible.
|
|
58
|
+
|
|
59
|
+
**Examples by domain:**
|
|
60
|
+
|
|
61
|
+
- **HTTP routes** — middleware denies all paths by default; routes opt in via explicit definitions. Catch-all 404 vs catch-all 200.
|
|
62
|
+
- **Feature flags** — new flag defaults to OFF; opt-in turns on. INSTEAD of new flag default ON (silently activating in every environment).
|
|
63
|
+
- **CORS** — empty origin list rejects; explicit origins permit. INSTEAD of `*` wildcard.
|
|
64
|
+
- **DB row visibility** — multi-tenant query starts with tenant filter; opt in to cross-tenant only with explicit annotation. INSTEAD of unfiltered base query + per-call tenant filter (easy to forget).
|
|
65
|
+
- **Bash auto-save** — refuse all branches; allowlist enables. INSTEAD of allow all branches; refuse list excludes (PR #1058 anti-pattern).
|
|
66
|
+
|
|
67
|
+
### 3. Least privilege
|
|
68
|
+
|
|
69
|
+
Each operation runs with the minimum privileges needed to complete its job. Tokens, credentials, file modes, network access, database permissions — all scoped to the narrowest grant.
|
|
70
|
+
|
|
71
|
+
INSTEAD of granting broad permissions because tightening is annoying: grant narrow permissions at creation; broaden only with explicit justification.
|
|
72
|
+
|
|
73
|
+
**Per language idiom:**
|
|
74
|
+
|
|
75
|
+
| Stack | Least-privilege primitive |
|
|
76
|
+
|---|---|
|
|
77
|
+
| TypeScript | scoped Prisma client / scoped fetch credentials / scoped GitHub PAT |
|
|
78
|
+
| Python | scoped boto3 IAM roles; scoped requests session with restricted cookies |
|
|
79
|
+
| Ruby | scoped ActiveRecord connection pool per concern; scoped Net::HTTP credentials |
|
|
80
|
+
| Java | scoped JDBC connection with role-based grants; scoped HttpClient TLS config |
|
|
81
|
+
| Go | scoped HTTP client; scoped database/sql DSN per role |
|
|
82
|
+
| Bash | `--scope=<minimum>` flags on every CLI; `sudo` disallowed by default; file modes 644/755 by default |
|
|
83
|
+
|
|
84
|
+
Token discipline (per memory `feedback_never_paste_tokens_in_chat`) is least privilege applied to authentication.
|
|
85
|
+
INSTEAD of broad-org admin tokens: fine-grained PATs scoped to a single target repo + minimum permission set. INSTEAD of pasting credential values into any chat / log / commit: reference credentials by environment-variable name only.
|
|
86
|
+
|
|
87
|
+
### 4. Complete mediation
|
|
88
|
+
|
|
89
|
+
Every access to every protected resource passes through the protection mechanism. There are no "trusted" internal paths that skip the check.
|
|
90
|
+
|
|
91
|
+
INSTEAD of checking authorization at the boundary and trusting internal callers: check at every access point. The cost of one extra check is small; the cost of one missed check can be the whole system.
|
|
92
|
+
|
|
93
|
+
**Examples by domain:**
|
|
94
|
+
|
|
95
|
+
- **DB queries** — Row-level security at the database is complete mediation; ORM-side filters are bypass-able if a caller uses raw SQL
|
|
96
|
+
- **HTTP middleware** — Apply auth middleware to a route group; selective-skip is a security bug.
|
|
97
|
+
INSTEAD of allowing per-route opt-out: route groups are the granularity; new routes inherit the middleware.
|
|
98
|
+
- **Tenant filtering** — Filter at the query builder layer (every query inherits); not at the controller layer (controllers can forget).
|
|
99
|
+
INSTEAD of controller-layer filtering: query-builder-layer filtering so the tenant context is structurally inseparable from every query.
|
|
100
|
+
- **File access** — Mediate via accessor functions that include the check; raw file handles bypass the check.
|
|
101
|
+
INSTEAD of granting raw handles for performance: accessor functions own the read/write surface; performance optimization lives inside the accessor.
|
|
102
|
+
- **Bash hook PreToolUse** — Hook fires on every matching tool call, not "first call per session"
|
|
103
|
+
|
|
104
|
+
### 5. Defense in depth
|
|
105
|
+
|
|
106
|
+
Multiple independent layers protect the same resource. A single compromise of one layer leaves the resource still protected by the others.
|
|
107
|
+
|
|
108
|
+
INSTEAD of relying on one strong layer: stack multiple layers, each cheap, with no single layer load-bearing.
|
|
109
|
+
|
|
110
|
+
**Example stack for bassclef production deploys:**
|
|
111
|
+
|
|
112
|
+
1. GitHub Environment with `required_reviewers` (separation of privilege)
|
|
113
|
+
2. `deploy-guard.sh` hook BLOCKs without explicit `DEPLOY_PROD=1` env var
|
|
114
|
+
3. `gh pr merge` requires operator account (not agent token)
|
|
115
|
+
4. CI passing gate (test + build + lint + security scan)
|
|
116
|
+
5. Manual smoke-test acknowledgement before traffic shift
|
|
117
|
+
|
|
118
|
+
Five layers. Compromise of any one (e.g., agent token leaked) still leaves four layers protecting the deploy.
|
|
119
|
+
|
|
120
|
+
INSTEAD of "we have CI, that's enough": every layer is cheap; every layer catches a different failure class.
|
|
121
|
+
|
|
122
|
+
### 6. Audit at every layer
|
|
123
|
+
|
|
124
|
+
Every state-modifying action emits an audit record. The record names: who, what, when, from where, with what authority.
|
|
125
|
+
|
|
126
|
+
INSTEAD of audit-only-on-failure: audit on every state change so post-incident reconstruction has the data it needs.
|
|
127
|
+
|
|
128
|
+
**Per language idiom:**
|
|
129
|
+
|
|
130
|
+
| Stack | Audit primitive |
|
|
131
|
+
|---|---|
|
|
132
|
+
| TypeScript | structured logger (pino, winston) + trace ID at handler entry |
|
|
133
|
+
| Python | structlog or loguru + trace ID; opentelemetry for cross-service |
|
|
134
|
+
| Ruby | structured Rails logger + Lograge; trace ID via request middleware |
|
|
135
|
+
| Java | SLF4J + Logback structured layout; OpenTelemetry tracer |
|
|
136
|
+
| Go | zap or zerolog + trace context; OpenTelemetry SDK |
|
|
137
|
+
| Bash | `trace-helper.sh` writes JSONL to `.claude/state/traces/<session>.jsonl` |
|
|
138
|
+
|
|
139
|
+
Bassclef's `lib/trace-helper.sh` is the substrate's audit primitive for bash. Every hook fires `trace_record <hook> <verb> <context>` before exit. Override usage (e.g., `SKIP_*=1`) is logged automatically.
|
|
140
|
+
|
|
141
|
+
## What this standard does NOT do
|
|
142
|
+
|
|
143
|
+
- **Does not specify cryptographic primitives** — algorithm choice, key length, library selection are out of scope. Use the language's standard library + vetted cryptography library (e.g., libsodium binding, Bouncy Castle).
|
|
144
|
+
- **Does not catalog OWASP top-10 mitigations** — `.claude/rules/security.md` covers the web layer; this standard covers the substrate-internal layer that the web layer rests on.
|
|
145
|
+
- **Does not replace `/security-review`** — that skill applies these principles to a specific PR. This standard is the reference the skill cites.
|
|
146
|
+
- **Does not specify threat models** — Schneier-anchored threat-thinking is a separate luminary candidate (deferred per Phase X+Y+Z bet's Out of scope).
|
|
147
|
+
|
|
148
|
+
## When this standard fires
|
|
149
|
+
|
|
150
|
+
| Surface | What to check |
|
|
151
|
+
|---|---|
|
|
152
|
+
| New HTTP handler / route | Boundary validation present? Default behavior fail-safe? |
|
|
153
|
+
| New bash hook | All 8 principles via stack-translation table in `saltzer-schroeder.md` |
|
|
154
|
+
| New CLI tool | Argument validation? Least-privilege credential scope? |
|
|
155
|
+
| New cross-service call | Validation on the response? Audit emit at call site? |
|
|
156
|
+
| Schema migration | Defense in depth via review + dry-run + rollback? |
|
|
157
|
+
| Code review | All 6 disciplines applied? |
|
|
158
|
+
|
|
159
|
+
## Refs
|
|
160
|
+
|
|
161
|
+
- `@luminary saltzer-schroeder` — anchor; 8 principles for protection-mechanism design
|
|
162
|
+
- `.claude/rules/security.md` — web-layer rule (`.ts/.tsx/.json/.env/Dockerfile` scope)
|
|
163
|
+
- `.claude/rules/destructive-operations.md` — agent self-assessment companion
|
|
164
|
+
- `standards/bash-hook-safety.md` (Phase X-3) — bash-specific instantiation of these principles
|
|
165
|
+
- `docs/iteration-bets/2026-06-17a-secure-coding-foundations-longrun.md` — goal authoring this standard
|
|
166
|
+
- bassclef#1058 — concrete failure (auto-save scope hole) that motivated this standard
|
|
167
|
+
|
|
168
|
+
## Composes with
|
|
169
|
+
|
|
170
|
+
- `standards/destructive-operations.md` style → `.claude/rules/destructive-operations.md` (agent self-assessment)
|
|
171
|
+
- `standards/bassclef-configs-schema.md` § Security scanning (Phase Y-2) — adopter-facing scanner-adapter config
|
|
172
|
+
- `standards/security-scanner-adapter.md` (Phase Y-1) — adapter pattern that uses scanner outputs to enforce these disciplines
|
|
173
|
+
|
|
174
|
+
## Retirement
|
|
175
|
+
|
|
176
|
+
This standard retires only if Saltzer & Schroeder's principles are superseded by a fundamentally different protection-mechanism framework. The 8 principles have held for 50 years; retirement is not a near-term concern. The stack-translation tables evolve as bassclef adds support for new languages.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: Composer skills (/preview-build, /build, /shape full, future multi-skill chains) require certain prerequisites to dispatch safely.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Composer Prerequisites
|
|
7
|
+
|
|
8
|
+
Composer skills (`/preview-build`, `/build`, `/shape full`, future
|
|
9
|
+
multi-skill chains) require certain prerequisites to dispatch safely.
|
|
10
|
+
This standard documents the **6 bassclef pre-flight checks**, the
|
|
11
|
+
**auto-prep policy**, and the **signal-and-offer pattern** for
|
|
12
|
+
operator-decisions.
|
|
13
|
+
|
|
14
|
+
Implementation: `lib/composer-preflight.sh`. Per bassclef#408 (scaffold) + bassclef#449/#450 (deploy-host check).
|
|
15
|
+
|
|
16
|
+
## Why this exists
|
|
17
|
+
|
|
18
|
+
Before this standard: composer skills dispatched optimistically and
|
|
19
|
+
failed LATE inside their procedure when prerequisites weren't met.
|
|
20
|
+
Operator typed the dispatch, watched 5+ sequential errors surface,
|
|
21
|
+
manually prepped each, re-dispatched. Friction tax × 5.
|
|
22
|
+
|
|
23
|
+
After this standard: one Phase -1 pre-flight surface lists all
|
|
24
|
+
prerequisites at once. Auto-prep where mechanical and safe.
|
|
25
|
+
Signal-and-offer where operator-decisions. Refuses (with clear
|
|
26
|
+
instruction) where blocking.
|
|
27
|
+
|
|
28
|
+
## The 6 checks
|
|
29
|
+
|
|
30
|
+
| # | Check | Pass condition | Failure handling |
|
|
31
|
+
|---|-------|---------------|-------------------|
|
|
32
|
+
| 1 | **feature-branch** | repo on `feature/*` (or `fix/*`, `spike/*`) branch | refuses on main/master; instructs `git checkout -b feature/<slug>` |
|
|
33
|
+
| 2 | **state-spine** | `lib/state.sh` present in repo | auto-prep available from `$BASSCLEF_DIR/lib/state.sh`; falls back to refuse + /onboard-repo recommendation |
|
|
34
|
+
| 3 | **personas** | ≥1 persona at `docs/personas/*.md` | warn + offer `/personas` dispatch; composers may proceed with operator-as-persona |
|
|
35
|
+
| 4 | **budget** | `iteration_ceiling` (from `substrate.config.md`) ≥ estimated `turns × $0.10` | warn + offer ceiling bump in `substrate.config.md`; sequential mode ($0 burst) passes silently |
|
|
36
|
+
| 5 | **skill-registry** | dispatching skill resolves at `~/.claude/skills/<name>/SKILL.md` (user-level symlink) | warn if only at repo-level (bassclef#271 race); refuse if missing entirely |
|
|
37
|
+
| 6 | **deploy-host** | `hosting_platform` set in `substrate.config.md` AND adapter shipped | refuses on missing/unset; refuses on `none` unless `--no-launch` flag passed; warn on in-enum-but-adapter-not-shipped (vercel/netlify/cf-pages) — closes preview→production gap (bassclef#449/#450) |
|
|
38
|
+
|
|
39
|
+
### Check 6 — `--no-launch` mode
|
|
40
|
+
|
|
41
|
+
Composers receive an optional `--no-launch` flag. When passed, Check 6
|
|
42
|
+
short-circuits to pass with message "variants-only run" — used when the
|
|
43
|
+
dispatch is purely for design exploration (e.g., `/preview light` or
|
|
44
|
+
`/preview-build` invoked without `/launch-preview` chaining). Default is
|
|
45
|
+
full chain (deploy-host required). The flag is logged in pre-flight
|
|
46
|
+
output for audit.
|
|
47
|
+
|
|
48
|
+
## Auto-prep policy
|
|
49
|
+
|
|
50
|
+
**Auto-prep is allowed ONLY when ALL of:**
|
|
51
|
+
|
|
52
|
+
1. The action is mechanical (no operator-judgment input needed)
|
|
53
|
+
2. The action is safe (no destructive side-effects, no hidden state changes)
|
|
54
|
+
3. The action is reversible (operator can `git diff` to see exactly what changed)
|
|
55
|
+
4. The action is documented in this standard (no hidden auto-prep paths)
|
|
56
|
+
|
|
57
|
+
**Today the only auto-prep path is `lib/state.sh` bootstrap from
|
|
58
|
+
bassclef** (mechanical: `cp $BASSCLEF_DIR/lib/state.sh
|
|
59
|
+
$REPO/lib/state.sh`; safe: read-only template; reversible: standard
|
|
60
|
+
git diff).
|
|
61
|
+
|
|
62
|
+
**Forbidden auto-prep** (always operator-decision):
|
|
63
|
+
|
|
64
|
+
- Auto-branch creation (operator chooses naming + scope)
|
|
65
|
+
- Auto-budget changes (operator-economic decision)
|
|
66
|
+
- Auto-persona seeding (operator describes WHO; substrate fills shape)
|
|
67
|
+
- Auto-skill-registry recovery (operator reviews bassclef-sync output)
|
|
68
|
+
|
|
69
|
+
## Signal-and-offer pattern
|
|
70
|
+
|
|
71
|
+
For operator-decisions where the prerequisite isn't met, the composer:
|
|
72
|
+
|
|
73
|
+
1. **Signals** the gap clearly in the pre-flight surface
|
|
74
|
+
2. **Offers** a one-line action the operator can take
|
|
75
|
+
3. **Continues** if the operator confirms proceed (warn-tier) OR refuses if the gap is hard-block (fail-tier)
|
|
76
|
+
|
|
77
|
+
Example surface:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
⚠️ budget iteration_ceiling $5 < estimated $8 (80 turns)
|
|
81
|
+
└─ recommendation: Bump iteration_ceiling in substrate.config.md OR reduce composer tier
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Operator decides:
|
|
85
|
+
- Bump ceiling → re-dispatch
|
|
86
|
+
- Use lower tier (`/preview-build medium` instead of `full`) → re-dispatch
|
|
87
|
+
- Proceed anyway (operator accepts overage risk) → composer proceeds with explicit acknowledgment
|
|
88
|
+
|
|
89
|
+
## When pre-flight fires
|
|
90
|
+
|
|
91
|
+
Phase -1 of the composer's procedure, BEFORE Phase 0:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
PHASE -1: Pre-flight check (NEW, per bassclef#408)
|
|
95
|
+
source $BASSCLEF_DIR/lib/composer-preflight.sh
|
|
96
|
+
composer_preflight_check <skill> <estimated_turns> | composer_preflight_render <skill>
|
|
97
|
+
|
|
98
|
+
PHASE 0: Existing composer setup
|
|
99
|
+
...
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
If pre-flight returns `0` (all pass) → continue to Phase 0.
|
|
103
|
+
If pre-flight returns `1` (warnings) → composer surfaces warnings + asks operator proceed/abort.
|
|
104
|
+
If pre-flight returns `2` (failures) → composer refuses dispatch + exits.
|
|
105
|
+
|
|
106
|
+
## Override
|
|
107
|
+
|
|
108
|
+
Per-call: `SKIP_COMPOSER_PREFLIGHT=1 <command>` (logged via trace-helper).
|
|
109
|
+
|
|
110
|
+
Use sparingly. Override defeats the purpose; intended only for:
|
|
111
|
+
- Substrate-defect rescue (preflight itself broken)
|
|
112
|
+
- Operator-explicit "I know what I'm doing this once"
|
|
113
|
+
- Migration scripts that bootstrap state in odd shapes
|
|
114
|
+
|
|
115
|
+
NOT for:
|
|
116
|
+
- Routine work that fails preflight ("I'll fix the ceiling later")
|
|
117
|
+
- Automated CI dispatches (those should pre-prep, not bypass)
|
|
118
|
+
|
|
119
|
+
## Composer integration checklist
|
|
120
|
+
|
|
121
|
+
When adding pre-flight to a new composer skill:
|
|
122
|
+
|
|
123
|
+
1. Add Phase -1 to skill's procedure (before Phase 0)
|
|
124
|
+
2. Source the helper: `source $BASSCLEF_DIR/lib/composer-preflight.sh`
|
|
125
|
+
3. Call `composer_preflight_check <skill_name> <estimated_turns>`
|
|
126
|
+
4. Pipe through `composer_preflight_render` for operator surface
|
|
127
|
+
5. Branch on exit code (0 / 1 / 2) per the table above
|
|
128
|
+
6. Document `--skip-preflight` in skill's args reference
|
|
129
|
+
7. Test the integration (positive + negative cases)
|
|
130
|
+
|
|
131
|
+
## Composes with
|
|
132
|
+
|
|
133
|
+
- `lib/composer-preflight.sh` — implementation
|
|
134
|
+
- `.claude/rules/sdlc-gates.md` — pre-build gates (existing)
|
|
135
|
+
- `.claude/rules/blocked-items.md` — refuse + signal pattern (existing)
|
|
136
|
+
- `.claude/rules/destructive-operations.md` — auto-prep safety pattern
|
|
137
|
+
- bassclef#271 — skill-registry race (detected by check 5)
|
|
138
|
+
- bassclef#382 — substrate-clarity-gate (sibling write-time gate)
|
|
139
|
+
- bassclef#400 — friction-check (sibling post-skill gate)
|
|
140
|
+
|
|
141
|
+
## What this standard does NOT cover
|
|
142
|
+
|
|
143
|
+
- Pre-flight for `/longrun prep` (already exists in skill itself; this standard doesn't extend)
|
|
144
|
+
- Pre-flight for single-skill dispatches (`/value-prop`, `/kiss`, `/verify`) — overhead exceeds value
|
|
145
|
+
- Mid-composer prerequisites (e.g., spec validation between skills) — different surface; covered by composer's internal Phase 0+ logic
|
|
146
|
+
- Production deploy gates (`/deploy-prod` has its own approval surface)
|
|
147
|
+
|
|
148
|
+
## Sources
|
|
149
|
+
|
|
150
|
+
- bassclef#408 — the bassclef-evolution proposal this standard closes
|
|
151
|
+
- bassclef#400 scenario test (TwoDo /preview-build full surfaced 5 unmet prereqs)
|
|
152
|
+
- bassclef#271 — skill-registry race (check 5 detects)
|
|
153
|
+
- `lib/composer-preflight.sh` — the implementation
|
|
154
|
+
- `.claude/skills/longrun/SKILL.md` — existing pre-flight pattern (mirrors)
|
|
155
|
+
- `.claude/skills/autonomous/SKILL.md` — existing pre-flight pattern (mirrors)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: The Rust package-manager sibling of .claude/rules/new-dependency-check.md.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cargo — dependency discipline
|
|
7
|
+
|
|
8
|
+
The Rust package-manager sibling of `.claude/rules/new-dependency-check.md`. Loads when adopter's `tech_stack.pkg_manager` is `cargo`.
|
|
9
|
+
|
|
10
|
+
## Per-PM checks (beyond the universal concerns)
|
|
11
|
+
|
|
12
|
+
1. **MSRV (Minimum Supported Rust Version)** — does the package's MSRV align with the adopter's Rust version? Bumping Rust to take a new crate is a real cost; check `rust-version` in the crate's Cargo.toml.
|
|
13
|
+
2. **`no_std` compatibility** — for embedded / WASM / kernel use cases, does the crate work without the standard library? Check for `#![no_std]` support in the crate's docs.
|
|
14
|
+
3. **Feature flags** — Rust crates often ship optional features. Default features may pull in heavy transitive deps (e.g., `tokio` with full features). Audit `default-features` and explicitly select features you need.
|
|
15
|
+
4. **Unsafe code surface** — does the crate use `unsafe`? For security-critical paths, prefer crates audited by `cargo-audit` or that publish via `cargo-geiger` reports.
|
|
16
|
+
5. **Compile time** — Rust compile is slow; popular crates with heavy macros (serde, diesel) compound. Check existing Cargo.lock for already-pulled-in deps before adding a new heavyweight.
|
|
17
|
+
|
|
18
|
+
## Lockfile + reproducibility
|
|
19
|
+
|
|
20
|
+
- **Cargo.lock** — always check in for binaries; library crates traditionally don't, though modern practice is moving toward checking in for libraries too (reproducible builds).
|
|
21
|
+
|
|
22
|
+
## Approved Dependencies list location
|
|
23
|
+
|
|
24
|
+
Each adopter repo maintains its own. Typical locations:
|
|
25
|
+
- `CLAUDE.md` § "Approved Dependencies"
|
|
26
|
+
- `standards/approved-dependencies.md`
|
|
27
|
+
- `Cargo.toml` `[dependencies]` (Rust adopters; the manifest IS the approved list)
|
|
28
|
+
|
|
29
|
+
## Process specifics
|
|
30
|
+
|
|
31
|
+
1. State the package name and why.
|
|
32
|
+
2. Run the 5 universal concerns from `new-dependency-check.md`.
|
|
33
|
+
3. Run the 5 per-PM checks above.
|
|
34
|
+
4. Run `cargo add <pkg>` (or `cargo add <pkg> --no-default-features --features ...` for feature selection).
|
|
35
|
+
5. Use `[dev-dependencies]` for build-time-only deps (testing, benchmarking).
|
|
36
|
+
|
|
37
|
+
## Sources
|
|
38
|
+
|
|
39
|
+
- Adapted from operator's npm-rule shape; Rust ecosystem specifics from cargo book + RustSec + cargo-audit.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: The Ruby package-manager sibling of .claude/rules/new-dependency-check.md.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# gem (Bundler) — dependency discipline
|
|
7
|
+
|
|
8
|
+
The Ruby package-manager sibling of `.claude/rules/new-dependency-check.md`. Loads when adopter's `tech_stack.pkg_manager` is `gem`.
|
|
9
|
+
|
|
10
|
+
## Per-PM checks (beyond the universal concerns)
|
|
11
|
+
|
|
12
|
+
1. **Ruby-version compatibility** — does the gem support the adopter's Ruby version? Check `required_ruby_version` in the gem's gemspec.
|
|
13
|
+
2. **Rails-version compatibility** (if applicable) — does the gem support the adopter's Rails major.minor? Gems that lag behind Rails majors are maintenance debt; gems that lead may break.
|
|
14
|
+
3. **C extension** — does the gem include native code (e.g., `nokogiri`, `pg`)? Installation requires platform-specific build tools; multi-platform deployments need precompiled gems or build-env parity.
|
|
15
|
+
4. **Test-mode side effects** — some gems modify global state on require (e.g., monkey-patching standard library, registering autoloaders). Audit for surprise behavior in test isolation.
|
|
16
|
+
5. **License compatibility** — Ruby gems are heterogeneous on license (MIT / Apache / BSD / GPL / proprietary). Audit for compatibility with the adopter's license posture.
|
|
17
|
+
|
|
18
|
+
## Lockfile + reproducibility
|
|
19
|
+
|
|
20
|
+
- **Gemfile.lock** — always check in. Bundler resolves deterministically from the lockfile.
|
|
21
|
+
- **Gemfile** — production vs development vs test groups must be explicit; ungrouped gems install in every environment.
|
|
22
|
+
|
|
23
|
+
## Approved Dependencies list location
|
|
24
|
+
|
|
25
|
+
Each adopter repo maintains its own. Typical locations:
|
|
26
|
+
- `CLAUDE.md` § "Approved Dependencies"
|
|
27
|
+
- `standards/approved-dependencies.md`
|
|
28
|
+
- `Gemfile` (Ruby adopters; the manifest IS the approved list, grouped by environment)
|
|
29
|
+
|
|
30
|
+
## Process specifics
|
|
31
|
+
|
|
32
|
+
1. State the gem name and why.
|
|
33
|
+
2. Run the 5 universal concerns from `new-dependency-check.md`.
|
|
34
|
+
3. Run the 5 per-PM checks above.
|
|
35
|
+
4. Add to `Gemfile`:
|
|
36
|
+
- `gem '<name>'` for production
|
|
37
|
+
- `gem '<name>', group: :development` for dev-only
|
|
38
|
+
- `gem '<name>', group: :test` for test-only
|
|
39
|
+
5. Run `bundle install` to resolve + update Gemfile.lock.
|
|
40
|
+
|
|
41
|
+
## Sources
|
|
42
|
+
|
|
43
|
+
- Adapted from operator's npm-rule shape; Ruby ecosystem specifics from Bundler docs + rubygems.org.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: The Go package-manager sibling of .claude/rules/new-dependency-check.md.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# go-mod — dependency discipline
|
|
7
|
+
|
|
8
|
+
The Go package-manager sibling of `.claude/rules/new-dependency-check.md`. Loads when adopter's `tech_stack.pkg_manager` is `go-mod`.
|
|
9
|
+
|
|
10
|
+
## Per-PM checks (beyond the universal concerns)
|
|
11
|
+
|
|
12
|
+
1. **Go-version compatibility** — does the module's `go.mod` require a newer Go than the adopter? Bumping Go is a real cost; check `go` directive in the module's go.mod.
|
|
13
|
+
2. **Module path stability** — has the module gone through v2+ migrations (the `/v2`, `/v3` suffix dance)? Lock to a stable major; pre-1.0 modules can break minor-version contracts.
|
|
14
|
+
3. **Standard library coverage** — Go's stdlib is rich. Many "obvious" dependency candidates (JSON, HTTP server, logging, crypto, file I/O) are already in stdlib. Check before adding.
|
|
15
|
+
4. **Vendor vs proxy** — `vendor/` directory pins sources in the repo (fully reproducible, large repo); `GOPROXY` relies on external availability. Adopter picks; sibling notes the trade-off.
|
|
16
|
+
5. **CGo usage** — does the module call C code? CGo breaks cross-compilation and complicates Docker multi-stage builds. Pure-Go alternatives often exist; prefer them.
|
|
17
|
+
|
|
18
|
+
## Lockfile + reproducibility
|
|
19
|
+
|
|
20
|
+
- **go.sum** — checksums for every module + dependency. Always check in.
|
|
21
|
+
- **go.mod** — explicit declaration of direct dependencies; transitive deps live in go.sum.
|
|
22
|
+
|
|
23
|
+
## Approved Dependencies list location
|
|
24
|
+
|
|
25
|
+
Each adopter repo maintains its own. Typical locations:
|
|
26
|
+
- `CLAUDE.md` § "Approved Dependencies"
|
|
27
|
+
- `standards/approved-dependencies.md`
|
|
28
|
+
- `go.mod` `require` block (Go adopters; the manifest IS the approved list)
|
|
29
|
+
|
|
30
|
+
## Process specifics
|
|
31
|
+
|
|
32
|
+
1. State the module path and why.
|
|
33
|
+
2. Run the 5 universal concerns from `new-dependency-check.md`.
|
|
34
|
+
3. Run the 5 per-PM checks above.
|
|
35
|
+
4. Run `go get <module>@<version>` to add + pin.
|
|
36
|
+
5. Run `go mod tidy` to clean up unused deps + update go.sum.
|
|
37
|
+
6. Test deps go in `_test.go` files via `import` — no separate dev-dep grouping in Go.
|
|
38
|
+
|
|
39
|
+
## Sources
|
|
40
|
+
|
|
41
|
+
- Adapted from operator's npm-rule shape; Go ecosystem specifics from Go modules reference + golang.org/ref/mod.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: The Node.js package-manager sibling of .claude/rules/new-dependency-check.md.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# npm / pnpm / yarn — dependency discipline
|
|
7
|
+
|
|
8
|
+
The Node.js package-manager sibling of `.claude/rules/new-dependency-check.md`. Loads when adopter's `tech_stack.pkg_manager` is `npm`, `pnpm`, or `yarn`.
|
|
9
|
+
|
|
10
|
+
## Per-PM checks (beyond the universal concerns)
|
|
11
|
+
|
|
12
|
+
1. **Stack compatibility** — does it work with the adopter's framework (Next.js / Vite / Remix / SvelteKit / etc.), TypeScript strict mode, and container build?
|
|
13
|
+
2. **Bundle impact** — check [bundlephobia.com](https://bundlephobia.com) for client-side packages. Anything over 50KB minified+gzipped warrants justification. Server-only packages bypass this check.
|
|
14
|
+
3. **SSR compatibility** — does the package use `window`, `document`, `localStorage`, or other browser-only APIs? Client-only libraries need `"use client"` directive (Next.js App Router) plus lazy loading via `next/dynamic` or equivalent. Server components silently fail when client-only APIs leak through.
|
|
15
|
+
4. **Type definitions** — does the package ship its own TypeScript types? If not, is there a `@types/*` package? Untyped JS dependencies degrade TS strict-mode value.
|
|
16
|
+
5. **Lockfile alignment** — adopter using pnpm? Use `pnpm add`, not `npm install`. Mixed package managers corrupt lockfiles and produce non-reproducible installs.
|
|
17
|
+
|
|
18
|
+
## Approved Dependencies list location
|
|
19
|
+
|
|
20
|
+
Each adopter repo maintains its own. Typical locations:
|
|
21
|
+
- `CLAUDE.md` § "Approved Dependencies"
|
|
22
|
+
- `standards/approved-dependencies.md`
|
|
23
|
+
- `docs/dependencies.md`
|
|
24
|
+
|
|
25
|
+
After installing a new package, add it to the list with a one-line rationale.
|
|
26
|
+
|
|
27
|
+
## Process specifics
|
|
28
|
+
|
|
29
|
+
1. State the package name and why.
|
|
30
|
+
2. Run the 5 universal concerns from `new-dependency-check.md`.
|
|
31
|
+
3. Run the 5 per-PM checks above.
|
|
32
|
+
4. Run the appropriate install:
|
|
33
|
+
- `npm install <pkg>` (npm)
|
|
34
|
+
- `pnpm add <pkg>` (pnpm)
|
|
35
|
+
- `yarn add <pkg>` (yarn)
|
|
36
|
+
5. Use `--save-dev` (npm/yarn) or `-D` (pnpm) for build-time-only dependencies (testing, linting, types).
|
|
37
|
+
6. Add to the Approved Dependencies list.
|
|
38
|
+
|
|
39
|
+
## Sources
|
|
40
|
+
|
|
41
|
+
- Original `new-dependency-check.md` content authored against npm (operator stack).
|
|
42
|
+
- This sibling preserves the npm-specific specifics that don't apply to other ecosystems (bundlephobia, SSR, "use client", @types/*).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
tier: lite
|
|
3
|
+
description: The Python package-manager sibling of .claude/rules/new-dependency-check.md.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# pip / poetry — dependency discipline
|
|
7
|
+
|
|
8
|
+
The Python package-manager sibling of `.claude/rules/new-dependency-check.md`. Loads when adopter's `tech_stack.pkg_manager` is `pip` or `poetry`.
|
|
9
|
+
|
|
10
|
+
## Per-PM checks (beyond the universal concerns)
|
|
11
|
+
|
|
12
|
+
1. **Python-version compatibility** — does the package support the adopter's Python version? Many packages drop old Pythons quickly; some require minimum versions (e.g., 3.10+ for newer typing features).
|
|
13
|
+
2. **C extension / binary wheels** — does the package include native code? If yes, what platforms ship wheels (manylinux, macOS arm64, Windows)? Source-only installs fail without build tools.
|
|
14
|
+
3. **Dependency tree depth** — a dependency that pulls in 50 transitive deps is a maintenance liability. Inspect with `pip show <pkg>` or `poetry show --tree <pkg>`.
|
|
15
|
+
4. **Async / sync model** — does the package match the adopter's runtime model? Sync packages in an async app block the event loop; async packages in a sync app force conversion ceremony.
|
|
16
|
+
5. **Type stubs** — does the package ship `py.typed` marker (PEP 561)? If not, is there a `types-*` stub on PyPI? Untyped deps degrade mypy / pyright strict-mode value.
|
|
17
|
+
|
|
18
|
+
## Lockfile + reproducibility
|
|
19
|
+
|
|
20
|
+
- **pip** — `requirements.txt` + `pip freeze` is brittle; consider `pip-tools` (`pip-compile`) to pin transitive deps deterministically.
|
|
21
|
+
- **poetry** — `poetry.lock` is the bassclef lockfile; check it into version control.
|
|
22
|
+
|
|
23
|
+
## Approved Dependencies list location
|
|
24
|
+
|
|
25
|
+
Each adopter repo maintains its own. Typical locations:
|
|
26
|
+
- `CLAUDE.md` § "Approved Dependencies"
|
|
27
|
+
- `standards/approved-dependencies.md`
|
|
28
|
+
- `pyproject.toml` (poetry adopters; the dependencies list IS the approved list)
|
|
29
|
+
|
|
30
|
+
## Process specifics
|
|
31
|
+
|
|
32
|
+
1. State the package name and why.
|
|
33
|
+
2. Run the 5 universal concerns from `new-dependency-check.md`.
|
|
34
|
+
3. Run the 5 per-PM checks above.
|
|
35
|
+
4. Run the appropriate install:
|
|
36
|
+
- `pip install <pkg>` + update `requirements.txt`
|
|
37
|
+
- `poetry add <pkg>`
|
|
38
|
+
5. Use `--dev` (poetry) or a separate `requirements-dev.txt` (pip) for build-time-only dependencies (testing, linting, stubs).
|
|
39
|
+
|
|
40
|
+
## Sources
|
|
41
|
+
|
|
42
|
+
- Adapted from operator's npm-rule shape; Python ecosystem specifics from PyPA + PEP 561 + poetry docs.
|