pi-rnd 0.2.1

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/agents/rnd-builder.md +98 -0
  4. package/agents/rnd-integrator.md +104 -0
  5. package/agents/rnd-planner.md +208 -0
  6. package/agents/rnd-verifier.md +164 -0
  7. package/dist/doctor.js +166 -0
  8. package/dist/doctor.js.map +1 -0
  9. package/dist/gates/bash-discipline.js +27 -0
  10. package/dist/gates/bash-discipline.js.map +1 -0
  11. package/dist/gates/read-evidence-pack.js +23 -0
  12. package/dist/gates/read-evidence-pack.js.map +1 -0
  13. package/dist/gates/registry.js +24 -0
  14. package/dist/gates/registry.js.map +1 -0
  15. package/dist/gates/rnd-dir-required.js +31 -0
  16. package/dist/gates/rnd-dir-required.js.map +1 -0
  17. package/dist/index.js +20 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/orchestrator/prompts.js +58 -0
  20. package/dist/orchestrator/prompts.js.map +1 -0
  21. package/dist/orchestrator/rnd-dir.js +20 -0
  22. package/dist/orchestrator/rnd-dir.js.map +1 -0
  23. package/dist/orchestrator/spawn.js +67 -0
  24. package/dist/orchestrator/spawn.js.map +1 -0
  25. package/dist/orchestrator/start.js +195 -0
  26. package/dist/orchestrator/start.js.map +1 -0
  27. package/dist/orchestrator/state.js +15 -0
  28. package/dist/orchestrator/state.js.map +1 -0
  29. package/dist/orchestrator/types.js +2 -0
  30. package/dist/orchestrator/types.js.map +1 -0
  31. package/docs/PI-API.md +574 -0
  32. package/docs/PORTING.md +105 -0
  33. package/package.json +57 -0
  34. package/skills/fp-practices/SKILL.md +128 -0
  35. package/skills/fp-practices/bash.md +114 -0
  36. package/skills/fp-practices/duckdb.md +116 -0
  37. package/skills/fp-practices/elixir.md +115 -0
  38. package/skills/fp-practices/javascript.md +119 -0
  39. package/skills/fp-practices/koka.md +120 -0
  40. package/skills/fp-practices/lean.md +120 -0
  41. package/skills/fp-practices/postgresql.md +120 -0
  42. package/skills/fp-practices/python.md +120 -0
  43. package/skills/fp-practices/svelte.md +114 -0
  44. package/skills/kiss-practices/SKILL.md +41 -0
  45. package/skills/kiss-practices/bash.md +70 -0
  46. package/skills/kiss-practices/duckdb.md +30 -0
  47. package/skills/kiss-practices/elixir.md +38 -0
  48. package/skills/kiss-practices/javascript.md +43 -0
  49. package/skills/kiss-practices/koka.md +34 -0
  50. package/skills/kiss-practices/lean.md +45 -0
  51. package/skills/kiss-practices/markdown.md +20 -0
  52. package/skills/kiss-practices/postgresql.md +31 -0
  53. package/skills/kiss-practices/python.md +64 -0
  54. package/skills/kiss-practices/svelte.md +59 -0
  55. package/skills/rnd-building/SKILL.md +256 -0
  56. package/skills/rnd-decomposition/SKILL.md +188 -0
  57. package/skills/rnd-experiments/SKILL.md +197 -0
  58. package/skills/rnd-failure-modes/SKILL.md +222 -0
  59. package/skills/rnd-iteration/SKILL.md +170 -0
  60. package/skills/rnd-orchestration/SKILL.md +314 -0
  61. package/skills/rnd-scaling/SKILL.md +188 -0
  62. package/skills/rnd-verification/SKILL.md +248 -0
  63. package/skills/using-rnd-framework/SKILL.md +65 -0
@@ -0,0 +1,70 @@
1
+ # Bash — KISS Rules
2
+
3
+ ## Script Structure
4
+
5
+ - Start with `set -euo pipefail` — don't add custom error trapping unless you need cleanup beyond what `trap` provides
6
+ - Don't create bash "frameworks" with option parsers, logging libraries, or plugin systems — if the script is that complex, use a real language
7
+ - Don't split a simple script into multiple sourced files — one file is easier to read, copy, and debug
8
+ - Don't add `usage()` functions for scripts with 1-2 arguments — a comment at the top is enough
9
+
10
+ ## Variables and Quoting
11
+
12
+ - Always double-quote variables — `"$var"` not `$var`; the exceptions (glob patterns, intentional splitting) should be commented
13
+ - Use `local` in functions — don't pollute the global scope
14
+ - Don't use `ALLCAPS` for local variables — reserve ALLCAPS for environment variables and constants
15
+ - Use `readonly` for constants instead of `declare -r` — it's shorter and clearer
16
+ - Don't use arrays when a simple loop over arguments or lines works — arrays add complexity in bash
17
+
18
+ ## Conditionals and Control Flow
19
+
20
+ - Use `[[ ]]` not `[ ]` — double brackets handle quoting and patterns better; don't mix styles
21
+ - Don't add `else` branches that just echo an error and exit — let `set -e` handle it
22
+ - Use `&&` and `||` for simple one-liners — don't wrap a single command in `if/then/fi`
23
+ - Don't use `case` for 2 options — `if/elif` is clearer when there are few branches
24
+
25
+ ## Pipelines and Commands
26
+
27
+ - Use `$(command)` not backticks — backticks don't nest and are harder to read
28
+ - Don't pipe to `grep | awk | sed` when a single `awk` or `sed` does the job
29
+ - Don't use `cat file | grep` — use `grep pattern file` directly
30
+ - Don't add `2>/dev/null` to silence errors you should be fixing
31
+ - Use `mktemp` for temp files — don't hardcode `/tmp/myscript.tmp`
32
+ - Don't use `for`/`while`/`until` loops in the Bash tool — they hang. Use the Glob tool to list files by pattern and the Grep tool to search content. For cross-referencing multiple items, use Grep with alternation patterns or multiple parallel tool calls
33
+
34
+ ## Error Handling
35
+
36
+ - Don't wrap every command in `if ! command; then echo "failed"; exit 1; fi` — `set -e` already exits on failure
37
+ - Use `trap 'cleanup' EXIT` for cleanup, not manual cleanup before every exit point
38
+ - Don't add retry loops unless the operation is genuinely transient (network calls, lock contention)
39
+
40
+ ## Naming
41
+
42
+ - Use full words, not abbreviations — `destination` not `dst`, `process_file` not `proc_f`
43
+ - Name functions after what they do, not how — `send_notification` not `run_curl_loop`
44
+ - Don't use magic numbers — assign them to `readonly` variables with descriptive names
45
+
46
+ ## Function Design
47
+
48
+ - Keep functions under ~30 lines — if it's longer, it's doing too much
49
+ - Do one thing per function — if you need "and" to describe what it does, split it
50
+ - Prefer 0–2 parameters; more than 3 is a sign the function needs decomposing
51
+ - Don't use flag parameters (`process_file 1` vs `process_file 0`) — write two named functions instead
52
+
53
+ ## Comments
54
+
55
+ - Write self-explanatory code — a comment that restates what the code does adds no value
56
+ - Explain intent and non-obvious constraints, not mechanism — `# retry: S3 returns 503 during deploys`
57
+ - Remove commented-out code — use git history instead
58
+
59
+ ## Code Smells
60
+
61
+ - Duplication across functions or scripts — extract a shared helper rather than copy-pasting
62
+ - Global mutable state — functions that set globals are hard to test and compose; use `local` and stdout
63
+ - Deep nesting (3+ levels of `if`/`for`) — extract inner blocks into named functions
64
+ - Long parameter lists — group related values or restructure the calling code
65
+
66
+ ## Polish
67
+
68
+ - Order functions by abstraction level: the main entry point first, low-level helpers at the bottom — readers should be able to read top-to-bottom without scrolling back up for context
69
+ - Stick to one naming pattern per script: `verb_noun` (`send_report`, `parse_args`) or `noun_verb` — don't mix conventions mid-file
70
+ - Comment placement: one comment per non-obvious block, placed above the block — don't interleave inline comments with code when a block comment would be clearer
@@ -0,0 +1,30 @@
1
+ # DuckDB — KISS Rules
2
+
3
+ ## Queries
4
+
5
+ - Use `read_csv()`, `read_parquet()`, `read_json()` directly in queries — don't create tables from files unless you need to query them repeatedly
6
+ - Use simple SQL over CTEs when a single `SELECT` with joins and subqueries is clear enough
7
+ - Don't create views for one-off analysis queries — views are for queries reused from multiple places
8
+ - Use `COPY ... TO` for exporting results — don't pipe through application code when DuckDB can write directly
9
+ - Use `duckdb -c 'SQL'` for one-shot queries — don't create persistent databases for throwaway analysis
10
+
11
+ ## Types & Schema
12
+
13
+ - Let DuckDB infer types from files — don't specify column types manually unless inference gets it wrong
14
+ - Use `DESCRIBE` or `SUMMARIZE` to understand data before writing queries — don't guess at column names or types
15
+ - Don't create custom types or macros for single-use transformations
16
+
17
+ ## Analysis Patterns
18
+
19
+ - Use window functions (`OVER`, `PARTITION BY`) for ranking and running calculations — don't self-join
20
+ - Use `GROUP BY ALL` when grouping by all non-aggregated columns — don't list every column
21
+ - Use `EXCLUDE` in `SELECT * EXCLUDE (col)` to drop columns — don't list every column you want to keep
22
+ - Use `UNPIVOT` and `PIVOT` instead of manual `CASE WHEN` for reshaping data
23
+ - Use `QUALIFY` to filter window function results — don't wrap in a subquery
24
+
25
+ ## Polish
26
+
27
+ - Name CTEs and subqueries after what they represent, not how they compute — `monthly_revenue` not `summed_and_grouped`
28
+ - Group queries in a script by logical phase: ingestion, transformation, output — separate phases with a blank line and a comment marker
29
+ - Within a script, pick one alias style (`t1`/`t2` vs. `orders`/`items`) and stick with it throughout — mixed alias conventions make joins hard to scan
30
+ - Comment non-obvious `WHERE` clauses and filter constants: explain the business rule, not the SQL operator
@@ -0,0 +1,38 @@
1
+ # Elixir / Phoenix / Ecto — KISS Rules
2
+
3
+ ## Language & OTP
4
+
5
+ - Use pattern matching over conditionals — `case`/`cond`/`with` chains are a smell if a function head match works
6
+ - Don't add GenServers when a plain module with functions will do — GenServer is for state, not namespacing
7
+ - Don't add supervision trees for processes that don't need restart semantics
8
+ - Don't create Behaviours for a single implementation — extract when the second implementation appears
9
+ - Don't create Protocol implementations for a single type — protocols are for polymorphism across types
10
+ - Use `Enum` pipelines over `Stream` unless you measurably need laziness
11
+ - Don't reach for macros when a function works — macros are for compile-time transformations, not DRY
12
+
13
+ ## Phoenix
14
+
15
+ - Use standard Phoenix generators (`mix phx.gen.html`, `mix phx.gen.json`) and follow their conventions
16
+ - Don't replace standard CRUD controllers with LiveView unless there's a real interactivity need
17
+ - Keep controllers thin — one context call, render response
18
+ - Don't create nested route scopes for simple flat routes
19
+ - Use Phoenix's built-in form helpers and changesets before reaching for custom validation layers
20
+ - Don't add API versioning until you need it
21
+ - Use `Phoenix.Component` for markup reuse — don't build a component library before you have 3+ uses
22
+
23
+ ## Ecto
24
+
25
+ - Keep schemas lean — schemas define data shape, not business logic
26
+ - Use simple `Ecto.Query` — avoid building composable query builder abstractions
27
+ - Don't wrap `Repo` calls in context modules unless the context adds real logic beyond pass-through
28
+ - Write migrations as simple `alter table` / `create table` — don't create migration helper modules
29
+ - Don't add database indexes speculatively — add them when a query is measurably slow
30
+ - Use `Ecto.Changeset` validations over custom validation modules
31
+ - Don't create separate `Repo` functions for every possible query variation — compose queries at the call site
32
+
33
+ ## Polish
34
+
35
+ - Order functions within a module: public interface first (`def`), private helpers last (`defp`) — keep the public contract at the top so callers don't have to scroll past implementation details
36
+ - Within a context module, use one naming convention for the CRUD layer: `get_user` / `create_user` / `update_user` / `delete_user` — don't mix `fetch_`, `load_`, and `get_` for the same concept
37
+ - Comments in Elixir belong in `@doc` and `@moduledoc` — don't add `# ...` comments where a doc attribute would serve; reserve inline comments for non-obvious pattern-match guards or pipeline branch rationale
38
+ - Group related `def` clauses together — don't scatter pattern-match heads for the same function across the module interspersed with unrelated functions
@@ -0,0 +1,43 @@
1
+ # JavaScript / TypeScript / CSS / HTML — KISS Rules
2
+
3
+ ## JavaScript & TypeScript
4
+
5
+ - Use native APIs before reaching for packages — `fetch` over axios, `URL` over uri-parser, `structuredClone` over lodash.cloneDeep
6
+ - Don't add TypeScript generics when concrete types work — `function getUser(id: string): User` over `function get<T>(id: string): T`
7
+ - Don't create utility files for one-time helpers — inline the logic at the call site
8
+ - Don't add abstraction layers over `fetch` — a wrapper adds indirection without value until you need interceptors
9
+ - Don't add state management libraries for local component state — `useState` is enough until you measurably need shared state
10
+ - Don't create custom hooks for trivial effects — `useEffect` with a comment is clearer than `useDataFetcher`
11
+ - Use `async/await` over `.then()` chains — but don't add `try/catch` around every await unless you handle the error differently than letting it propagate
12
+ - Don't add barrel files (`index.ts` re-exports) until imports are genuinely painful
13
+ - Don't type every intermediate variable — let TypeScript infer
14
+
15
+ ## CSS
16
+
17
+ - Use simple selectors — avoid BEM/SMACSS methodology unless the project already uses it
18
+ - Don't create CSS utility classes for one-off styles — inline styles or scoped classes are fine
19
+ - Use CSS custom properties for values used 3+ times, not for every color and spacing
20
+ - Don't add a CSS-in-JS library when a stylesheet works
21
+ - Flexbox and Grid solve most layouts — don't reach for layout libraries
22
+
23
+ ## Tailwind CSS
24
+
25
+ - Use utility classes directly in markup — don't extract to `@apply` unless a pattern repeats 3+ times
26
+ - Don't create custom Tailwind plugins for one-off design tokens — use arbitrary values (`bg-[#1a1a2e]`) instead
27
+ - Don't add `@layer components` abstractions for single-use component styles
28
+ - Use Tailwind's built-in responsive prefixes (`md:`, `lg:`) — don't create custom breakpoint utilities
29
+ - Don't override Tailwind's spacing/color scales unless the project has a design system that conflicts
30
+ - Use `class:` conditional syntax (Svelte) or template literals over `clsx`/`classnames` for simple conditionals — reach for utility libraries only when conditional logic is genuinely complex
31
+
32
+ ## HTML
33
+
34
+ - Use semantic HTML elements (`nav`, `main`, `article`, `section`) over `div` soup
35
+ - Don't add ARIA attributes that duplicate native semantics — a `<button>` doesn't need `role="button"`
36
+ - Don't create component abstractions for simple markup — a `<Card>` component wrapping a `<div>` with a class adds indirection for no reuse benefit until it appears 3+ times
37
+
38
+ ## Polish
39
+
40
+ - Within a module, pick one naming convention for async functions and stick to it: `fetchUser` / `loadUser` — don't mix `fetch*`, `load*`, and `get*` for the same operation type
41
+ - Order exports by public surface first, unexported helpers at the bottom — readers should see the API before implementation details
42
+ - Comments should explain WHY the code makes a non-obvious choice — e.g., `// Safari 16 doesn't support X, so we use Y`; remove comments that just restate what the next line does
43
+ - Keep CSS class naming consistent within a component tree: if the project uses BEM, don't introduce utility-class-style names for one component
@@ -0,0 +1,34 @@
1
+ # Koka — KISS Rules
2
+
3
+ ## Effects
4
+
5
+ - Declare effects explicitly in function signatures — don't use polymorphic effect variables when specific effects are known
6
+ - Don't mask effects to make types look simpler — visible effects are the point; hiding them defeats Koka's design
7
+ - Let implicit handler resolution work — don't create explicit handlers for effects that have obvious default handlers
8
+ - Don't nest handlers without clear semantic intent — prefer flat handler stacking
9
+
10
+ ## Data Types
11
+
12
+ - Use value types (structs) for small immutable data — the compiler eliminates heap allocation automatically
13
+ - Don't wrap everything in reference types — let Perceus reference counting manage memory; unnecessary refs increase GC pressure
14
+ - Use `type` for algebraic data, `struct` for simple records — don't conflate them
15
+
16
+ ## Performance
17
+
18
+ - Write naturally functional code — FBIP analysis optimizes many functional patterns to in-place updates
19
+ - Structure recursive functions for TRMC (tail recursion modulo cons) — prevents stack overflow on large data
20
+ - Don't hand-optimize what the compiler handles — Perceus reuse analysis is better at spotting in-place update opportunities than manual attempts
21
+ - Use `var` blocks explicitly when mutable state is needed — don't mix mutation and functional style implicitly
22
+
23
+ ## Common Pitfalls
24
+
25
+ - Don't assume functional code is slow — FBIP means tree rebalancing and similar algorithms run in-place
26
+ - Don't ignore effect types in signatures — they are the primary tool for reasoning about code behavior
27
+ - Don't create utility modules for one-off effect handlers — inline simple handlers at the call site
28
+
29
+ ## Polish
30
+
31
+ - Group functions by the effect they operate under — functions touching the same effect belong together; don't scatter them across the file
32
+ - Use one naming convention for effect-producing functions: either `verb-noun` (`read-line`) or `noun-verb` — Koka's standard library favors `verb` or `verb-noun`; follow it within a module
33
+ - Comments on effect signatures should explain the observable contract — what callers can expect from the effect, not just what the handler does internally
34
+ - Name handler functions to match their effect type — a handler for `console` effect should read as `console-handler`, not `my-handler`
@@ -0,0 +1,45 @@
1
+ # Lean 4 — KISS Rules
2
+
3
+ ## Proofs and Tactics
4
+
5
+ - Don't use `sorry` as a placeholder — either close the proof or mark the claim as `axiom`
6
+ - Don't use bare `simp` — use `simp [lemma1, lemma2]` with an explicit lemma list so proofs don't break on Mathlib updates
7
+ - Don't nest tactic blocks more than 3 levels deep — extract intermediate results as `have` lemmas
8
+ - Place `by` at the end of the preceding line, never on its own line
9
+ - Use focusing dots `·` for subgoals — one tactic per line, indent everything in the block
10
+ - Don't squeeze terminal `simp` calls — unsqueezed is shorter and survives lemma renames
11
+
12
+ ## Types and Definitions
13
+
14
+ - Always explicitly declare argument types and return types — implicit inference obscures intent on GitHub/docs
15
+ - Use `where` syntax for structure/class instances — not enclosing braces
16
+ - Prefer arguments left of the colon over universal quantifiers
17
+ - Default definitions to semireducible — use `abbrev` for reducible, `irreducible_def` only when profiling justifies it
18
+
19
+ ## Decision Procedures
20
+
21
+ - Don't use `decide` for large finite checks — use `native_decide` for runtime evaluation
22
+ - Don't define custom notation for one-off proofs — notation is for reusable domain language
23
+
24
+ ## Imports
25
+
26
+ - Don't `import Mathlib` — import specific modules (`import Mathlib.Data.List.Basic`) so compile times stay fast and dependencies stay traceable
27
+
28
+ ## Recursion
29
+
30
+ - Don't write recursive functions without `termination_by` when termination is not structurally obvious
31
+ - Don't define `partial` functions to silence termination errors — prove termination or restructure
32
+
33
+ ## Style
34
+
35
+ - Prefer `fun x ↦` over `λ` syntax — and `<|` over `$`
36
+ - Keep lines to 100 characters maximum
37
+ - Don't orphan parentheses — keep them with their arguments
38
+ - Use `<|` and `|>` to reduce parenthesis nesting
39
+
40
+ ## Polish
41
+
42
+ - Order definitions by dependency: helper lemmas and definitions before the theorems that use them — never require a reader to jump forward to understand a proof
43
+ - Name lemmas after the property they establish, not the tactic used — `list_length_positive` not `simp_length_proof`
44
+ - Within a file, pick one naming convention for related theorems: either `noun_property` (e.g., `list_nil_length`) or `property_of_noun` — don't mix both styles
45
+ - Use `-- ` comments to explain non-obvious tactic choices or why a particular lemma is chosen; omit comments that only name the tactic being applied
@@ -0,0 +1,20 @@
1
+ # Markdown — KISS Rules
2
+
3
+ - Use ATX headings (`#`) not Setext (underlines) — pick one style and stick with it
4
+ - Don't nest headings deeper than 3 levels — if you need `####`, restructure into separate sections or files
5
+ - Use `-` for unordered lists, `1.` for ordered — don't mix `*`, `+`, and `-` within a file
6
+ - Don't add HTML when Markdown syntax covers it — use `**bold**` not `<strong>bold</strong>`
7
+ - Don't create elaborate table formatting — simple pipe tables are enough; if the table is too complex for Markdown, use a different format
8
+ - Don't add blank lines between every paragraph for "readability" — one blank line separates blocks, more is noise
9
+ - Use reference-style links `[text][ref]` only when the same URL appears 3+ times — inline links are clearer for one-off references
10
+ - Don't add a table of contents manually — let the renderer or tooling generate it
11
+ - Don't wrap lines at 80 characters in prose — let the editor soft-wrap; hard wraps create noisy diffs
12
+ - Don't use blockquotes (`>`) for emphasis — they're for quotations; use bold or callout syntax for emphasis
13
+ - Keep frontmatter minimal — only fields the system actually reads; don't add metadata nobody consumes
14
+
15
+ ## Polish
16
+
17
+ - Use one list marker style per document (`-` or `*` or `1.`) — don't mix within the same file even across sections
18
+ - Heading hierarchy must be consistent: if top-level concepts use `##`, don't introduce a parallel `##` section that is logically a child of another `##`
19
+ - Code fences must always name the language — ` ```bash `, ` ```json `, never a bare ` ``` ` — so syntax highlighters and linters can apply
20
+ - If a document uses bold for key terms, apply it consistently — don't bold some terms and leave equivalent terms unbolded later in the same file
@@ -0,0 +1,31 @@
1
+ # PostgreSQL — KISS Rules
2
+
3
+ ## Queries
4
+
5
+ - Use simple SQL before reaching for CTEs — a subquery or join is often clearer
6
+ - Don't create database views for one-off queries — views are for queries used from multiple places
7
+ - Don't create stored procedures when application code works — procedures are for database-level reuse, not application logic
8
+ - Use `WHERE` clauses over `HAVING` when filtering non-aggregated columns
9
+ - Don't use `SELECT *` in application queries — list the columns you need
10
+
11
+ ## Schema
12
+
13
+ - Don't normalize beyond what the queries need — a denormalized column that avoids a join is often the right call
14
+ - Don't add indexes speculatively — add them when `EXPLAIN ANALYZE` shows a sequential scan on a query that matters
15
+ - Use `text` over `varchar(n)` unless a length constraint is a business rule — PostgreSQL stores them identically
16
+ - Don't create custom types (domains, enums) for values only used in one table
17
+ - Use simple foreign keys — don't create junction tables for 1:1 relationships
18
+
19
+ ## Migrations
20
+
21
+ - Keep migrations simple: `CREATE TABLE`, `ALTER TABLE`, `CREATE INDEX`
22
+ - Don't create migration helper functions or DSLs — the SQL is the documentation
23
+ - Don't add rollback logic for destructive migrations in production — you'll restore from backup, not roll back
24
+ - One concern per migration — don't combine schema changes with data migrations
25
+
26
+ ## Polish
27
+
28
+ - Name tables and columns consistently: either `snake_case` plural nouns for tables (`user_sessions`) or singular — pick one and don't mix within a schema
29
+ - Comment constraints and indexes that implement non-obvious business rules — `-- enforces one active subscription per account`; don't comment on what `NOT NULL` or `PRIMARY KEY` does
30
+ - Order columns in a `CREATE TABLE` predictably: primary key first, foreign keys next, required columns, nullable columns last — makes schemas scannable across tables
31
+ - Use consistent CTE naming within a query: either descriptive nouns (`monthly_totals`) or verb phrases (`compute_totals`) — don't mix both styles in one WITH clause
@@ -0,0 +1,64 @@
1
+ # Python — KISS Rules
2
+
3
+ ## Package Management
4
+
5
+ - Use `uv` instead of `pip`, `pip3`, or `pipx` — it is faster, handles lockfiles, and manages virtual environments in one tool
6
+ - Use `uv add`/`uv remove` to manage `pyproject.toml` dependencies — don't manually edit dependency lists
7
+ - Use `uvx` to run one-off CLI tools — don't install them globally with `pipx`
8
+ - Use `uv venv` for virtual environments — don't use `python -m venv` or `virtualenv`
9
+ - Use `uv sync` to reproduce environments from lockfiles — don't `pip freeze > requirements.txt`
10
+
11
+ ## Code Quality
12
+
13
+ - Use `ruff` for both linting and formatting — don't install separate tools (flake8, black, isort, pylint)
14
+ - Run `ruff check --fix . && ruff format .` as a single pass — don't chain multiple linters
15
+ - Configure ruff in `pyproject.toml` under `[tool.ruff]` — don't create `.flake8`, `.isort.cfg`, or `setup.cfg` for linter config
16
+
17
+ ## Project Structure
18
+
19
+ - Use `pyproject.toml` as the single project config — don't maintain `setup.py`, `setup.cfg`, and `requirements.txt` separately
20
+ - Don't create `__init__.py` files in every directory — implicit namespace packages work since Python 3.3; add `__init__.py` only when you need to export a public API or run initialization code
21
+ - Don't create a `utils.py` or `helpers.py` catch-all — put functions in the module where they're used
22
+
23
+ ## Type Hints
24
+
25
+ - Use built-in generics (`list[str]`, `dict[str, int]`, `str | None`) — don't import from `typing` for types available as builtins since Python 3.10
26
+ - Don't annotate every local variable — let type checkers infer from assignment
27
+ - Don't create TypedDict for one-off structures — a plain dict or dataclass is clearer
28
+
29
+ ## Data Classes and Models
30
+
31
+ - Use `@dataclass` for simple value objects — don't write `__init__`, `__repr__`, `__eq__` by hand
32
+ - Don't use `@dataclass` when a named tuple or plain tuple suffices — if it's just grouping 2-3 return values, a tuple is simpler
33
+ - Don't add validators, serializers, or factory methods to dataclasses until you need them
34
+
35
+ ## Error Handling
36
+
37
+ - Don't catch `Exception` or `BaseException` without re-raising — catch specific exceptions
38
+ - Don't wrap every function call in try/except — let exceptions propagate to where they can be meaningfully handled
39
+ - Don't create custom exception hierarchies for internal code — use built-in exceptions (ValueError, TypeError, RuntimeError) with descriptive messages
40
+
41
+ ## Imports
42
+
43
+ - Use absolute imports — relative imports (`from . import`) are harder to grep and refactor
44
+ - Don't create barrel modules (`__init__.py` that re-exports everything) until imports are genuinely painful
45
+ - Group imports: stdlib, third-party, local — but let ruff/isort handle the sorting
46
+
47
+ ## Functions
48
+
49
+ - Return early for guard clauses — don't nest the happy path inside `if valid:`
50
+ - Don't use `*args, **kwargs` unless you're genuinely wrapping or forwarding — explicit parameters are self-documenting
51
+ - Don't add default arguments for values that are always passed by callers — defaults signal "optional"
52
+
53
+ ## Testing
54
+
55
+ - Use `pytest` — don't use `unittest.TestCase` classes unless the project already does
56
+ - Don't create test base classes or fixtures for one-off setup — inline the setup in the test
57
+ - Don't mock what you can construct — if a function takes a dict, pass a dict, don't mock a dict
58
+
59
+ ## Polish
60
+
61
+ - Order module contents predictably: constants, then public functions, then private functions (prefixed with `_`) — don't interleave public and private at will
62
+ - Within a module, use one naming style for related operations: `get_user` / `create_user` / `delete_user` — don't mix `fetch_`, `load_`, and `get_` for the same concept across functions in the same file
63
+ - Comments explain WHY, not WHAT — `# S3 returns 503 during rolling deploys, so we retry` is useful; `# call the API` is not; delete comments that restate the code
64
+ - Use docstrings for public functions that are not self-evident from their signature — skip docstrings on private helpers and one-liner utilities where the body is the documentation
@@ -0,0 +1,59 @@
1
+ # Svelte 5 — KISS Rules
2
+
3
+ ## Runes and Reactivity
4
+
5
+ - Use `$state` only for variables that trigger effects, derived values, or template updates — don't make every variable reactive
6
+ - Use `$state.raw` for large objects that are only reassigned (never mutated) — avoids proxy overhead on API responses
7
+ - Use `$derived` for computed values, not `$effect` — derived is cleaner, side-effect-free, and expresses intent
8
+ - `$effect` is an escape hatch — avoid it; put logic in event handlers, use `$derived`, or use `$inspect` for debugging
9
+ - Never update `$state` inside `$effect` — this creates reactive loops; restructure as `$derived` instead
10
+ - Treat `$props` as values that will change — always derive dependent values with `$derived`, don't compute once at init
11
+
12
+ ## Components
13
+
14
+ - Keep components small and flat — extract a child component only when it's used 3+ times or manages independent state
15
+ - Don't create wrapper components that just pass props through — use snippets or direct rendering
16
+ - Use `{#snippet}` and `{@render}` for reusable markup chunks — don't create components for template-only reuse
17
+ - Use keyed `{#each}` blocks — improves performance; key must uniquely identify items, never use array index
18
+ - Don't destructure `{#each}` items if you bind to them — `bind:value={item.count}` needs the reference
19
+
20
+ ## State Sharing
21
+
22
+ - Use `createContext` for state scoped to a component subtree — prevents state leakage during SSR
23
+ - Don't use module-level `$state` for shared state — use context or classes with `$state` fields instead
24
+ - Don't create stores (`writable`/`readable`) — use classes with `$state` fields for shared reactivity in Svelte 5
25
+
26
+ ## Events
27
+
28
+ - Use `onclick={handler}` attribute syntax — not the legacy `on:click={handler}` directive
29
+ - Use `<svelte:window>` and `<svelte:document>` for global listeners — not `onMount` or `$effect`
30
+
31
+ ## Styling
32
+
33
+ - Use Svelte's scoped `<style>` blocks — don't add CSS-in-JS or global stylesheet frameworks unless the project already uses them
34
+ - Use `style:--property={value}` to pass JS variables to CSS — not inline style strings
35
+ - Style child components via CSS custom properties (`<Child --color="red" />`) — use `:global` only as last resort
36
+ - Don't create utility CSS classes within a component — if a style is used once, put it inline in the style block
37
+
38
+ ## SvelteKit
39
+
40
+ - Use standard load functions (`+page.ts`, `+layout.ts`) — don't build custom data fetching abstractions
41
+ - Use form actions for mutations — don't reach for client-side API calls when a form action works
42
+ - Don't add API route wrappers — `+server.ts` files are already simple enough
43
+ - Use the built-in error/redirect helpers — don't create custom response utilities
44
+
45
+ ## Legacy Patterns to Avoid
46
+
47
+ - `$:` reactive declarations → use `$derived` and `$effect`
48
+ - `export let` → use `$props`
49
+ - `<slot>` and `$$slots` → use `{#snippet}` and `{@render}`
50
+ - `on:click` directive → use `onclick` attribute
51
+ - `use:action` → use `{@attach}`
52
+ - `<svelte:component this={X}>` → use dynamic component `<X />`
53
+
54
+ ## Polish
55
+
56
+ - Order a component's script block predictably: `$props` first, `$state` declarations next, `$derived` values, then `$effect` blocks, then event handlers — don't scatter reactive declarations throughout the script
57
+ - Use one naming convention for event handlers within a component: either `handleX` or `onX` — don't mix `handleClick` and `onSubmit` in the same file
58
+ - Comments in `<script>` blocks should explain non-obvious reactive dependencies or browser workarounds — don't comment on what `$derived` or `$state` does; that's self-evident
59
+ - Keep prop names consistent with the component's domain: if sibling components use `user`, don't introduce `currentUser` or `activeUser` for the same concept