@zenspc/pi-pstack 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/agents/comment-sicko.md +34 -0
  4. package/agents/poteto-agent.md +13 -0
  5. package/extensions/pstack/config.ts +228 -0
  6. package/extensions/pstack/index.ts +211 -0
  7. package/package.json +57 -0
  8. package/skills/architect/SKILL.md +82 -0
  9. package/skills/architect/references/design-red-flags.md +33 -0
  10. package/skills/architect/references/rationale-template.md +35 -0
  11. package/skills/architect/references/runner-prompt.md +20 -0
  12. package/skills/arena/SKILL.md +70 -0
  13. package/skills/automate-me/SKILL.md +114 -0
  14. package/skills/blast-radius/SKILL.md +49 -0
  15. package/skills/bro/SKILL.md +6 -0
  16. package/skills/create-verification-skill/SKILL.md +43 -0
  17. package/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
  18. package/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
  19. package/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
  20. package/skills/figure-it-out/SKILL.md +54 -0
  21. package/skills/how/SKILL.md +134 -0
  22. package/skills/how/references/critic-prompt.md +59 -0
  23. package/skills/how/references/critique-rubric.md +58 -0
  24. package/skills/how/references/explainer-prompt.md +55 -0
  25. package/skills/how/references/explorer-prompt.md +52 -0
  26. package/skills/interrogate/SKILL.md +109 -0
  27. package/skills/interrogate/references/code-quality-review.md +47 -0
  28. package/skills/interrogate/references/lead-judgment.md +58 -0
  29. package/skills/interrogate/references/reviewer-prompt.md +72 -0
  30. package/skills/interrogate/references/rubric.md +77 -0
  31. package/skills/maintain-verification-skill/SKILL.md +38 -0
  32. package/skills/no-comments/SKILL.md +23 -0
  33. package/skills/poteto-mode/SKILL.md +140 -0
  34. package/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
  35. package/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
  36. package/skills/poteto-mode/playbooks/autopilot-full.md +13 -0
  37. package/skills/poteto-mode/playbooks/autopilot-stack.md +31 -0
  38. package/skills/poteto-mode/playbooks/babysit.md +27 -0
  39. package/skills/poteto-mode/playbooks/bug-fix.md +17 -0
  40. package/skills/poteto-mode/playbooks/eval.md +27 -0
  41. package/skills/poteto-mode/playbooks/feature.md +21 -0
  42. package/skills/poteto-mode/playbooks/hillclimb.md +21 -0
  43. package/skills/poteto-mode/playbooks/investigation.md +14 -0
  44. package/skills/poteto-mode/playbooks/multi-phase-plan.md +3 -0
  45. package/skills/poteto-mode/playbooks/opening-a-pr.md +35 -0
  46. package/skills/poteto-mode/playbooks/orchestrate.md +113 -0
  47. package/skills/poteto-mode/playbooks/pause-safely.md +10 -0
  48. package/skills/poteto-mode/playbooks/perf-issue.md +24 -0
  49. package/skills/poteto-mode/playbooks/prototype.md +14 -0
  50. package/skills/poteto-mode/playbooks/refactoring.md +16 -0
  51. package/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
  52. package/skills/poteto-mode/playbooks/session-pickup.md +13 -0
  53. package/skills/poteto-mode/playbooks/shipping.md +40 -0
  54. package/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
  55. package/skills/poteto-mode/playbooks/visual-parity.md +11 -0
  56. package/skills/poteto-mode/playbooks/worktree-cleanup.md +14 -0
  57. package/skills/poteto-mode/references/bugbot-triage.md +142 -0
  58. package/skills/poteto-mode/references/plan.md +105 -0
  59. package/skills/poteto-mode/scripts/bootstrap.ts +62 -0
  60. package/skills/poteto-mode/scripts/bun.lock +67 -0
  61. package/skills/poteto-mode/scripts/orch/orch.test.ts +634 -0
  62. package/skills/poteto-mode/scripts/orch/orch.ts +578 -0
  63. package/skills/poteto-mode/scripts/orch/store.ts +1607 -0
  64. package/skills/poteto-mode/scripts/package.json +16 -0
  65. package/skills/poteto-mode/scripts/watch-pr/cli.test.ts +224 -0
  66. package/skills/poteto-mode/scripts/watch-pr/cli.ts +223 -0
  67. package/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +118 -0
  68. package/skills/poteto-mode/scripts/watch-pr/github.test.ts +306 -0
  69. package/skills/poteto-mode/scripts/watch-pr/github.ts +699 -0
  70. package/skills/poteto-mode/scripts/watch-pr/policy.test.ts +420 -0
  71. package/skills/poteto-mode/scripts/watch-pr/policy.ts +832 -0
  72. package/skills/poteto-mode/scripts/watch-pr/render.ts +169 -0
  73. package/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
  74. package/skills/poteto-mode/scripts/watch-pr/types.compile.ts +93 -0
  75. package/skills/poteto-mode/scripts/watch-pr/types.ts +401 -0
  76. package/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
  77. package/skills/poteto-mode/scripts/worktree-audit.sh +85 -0
  78. package/skills/principle-boundary-discipline/SKILL.md +33 -0
  79. package/skills/principle-build-the-lever/SKILL.md +22 -0
  80. package/skills/principle-encode-lessons-in-structure/SKILL.md +30 -0
  81. package/skills/principle-exhaust-the-design-space/SKILL.md +20 -0
  82. package/skills/principle-experience-first/SKILL.md +18 -0
  83. package/skills/principle-fix-root-causes/SKILL.md +22 -0
  84. package/skills/principle-foundational-thinking/SKILL.md +20 -0
  85. package/skills/principle-guard-the-context-window/SKILL.md +16 -0
  86. package/skills/principle-laziness-protocol/SKILL.md +17 -0
  87. package/skills/principle-make-operations-idempotent/SKILL.md +23 -0
  88. package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +21 -0
  89. package/skills/principle-minimize-reader-load/SKILL.md +22 -0
  90. package/skills/principle-model-the-domain/SKILL.md +25 -0
  91. package/skills/principle-never-block-on-the-human/SKILL.md +22 -0
  92. package/skills/principle-outcome-oriented-execution/SKILL.md +21 -0
  93. package/skills/principle-prove-it-works/SKILL.md +32 -0
  94. package/skills/principle-redesign-from-first-principles/SKILL.md +15 -0
  95. package/skills/principle-separate-before-serializing-shared-state/SKILL.md +15 -0
  96. package/skills/principle-sequence-verifiable-units/SKILL.md +21 -0
  97. package/skills/principle-subtract-before-you-add/SKILL.md +21 -0
  98. package/skills/principle-type-system-discipline/SKILL.md +30 -0
  99. package/skills/recall/SKILL.md +40 -0
  100. package/skills/reflect/SKILL.md +77 -0
  101. package/skills/reflect/references/divergent-reviewer.md +43 -0
  102. package/skills/reflect/references/judgment-reviewer.md +42 -0
  103. package/skills/reflect/references/synthesizer.md +56 -0
  104. package/skills/reflect/references/tooling-reviewer.md +57 -0
  105. package/skills/setup-pstack/SKILL.md +28 -0
  106. package/skills/show-me-your-work/SKILL.md +89 -0
  107. package/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
  108. package/skills/show-me-your-work/scripts/log.sh +40 -0
  109. package/skills/swarm/SKILL.md +45 -0
  110. package/skills/tdd/SKILL.md +43 -0
  111. package/skills/teach/SKILL.md +20 -0
  112. package/skills/technical-writing/SKILL.md +129 -0
  113. package/skills/typescript-best-practices/SKILL.md +28 -0
  114. package/skills/typescript-best-practices/references/patterns.md +292 -0
  115. package/skills/unslop/SKILL.md +80 -0
  116. package/skills/why/SKILL.md +229 -0
  117. package/skills/why/references/epistemics.md +144 -0
  118. package/skills/why/references/investigator-prompt.md +103 -0
  119. package/skills/why/references/source-playbook.md +17 -0
  120. package/skills/why/references/sources/code-archaeology.md +88 -0
  121. package/skills/why/references/sources/databricks.md +70 -0
  122. package/skills/why/references/sources/datadog.md +99 -0
  123. package/skills/why/references/sources/incident-postmortem.md +15 -0
  124. package/skills/why/references/sources/linear.md +48 -0
  125. package/skills/why/references/sources/notion.md +55 -0
  126. package/skills/why/references/sources/sentry.md +100 -0
  127. package/skills/why/references/sources/slack.md +54 -0
  128. package/skills/why/references/synthesizer-prompt.md +135 -0
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: technical-writing
3
+ description: "Layered technical-writing standard: Diátaxis structure, Google developer style sentences, STE instruction rules, Global English syntax. Use for /skill:technical-writing or when writing or reviewing docs, RFCs, readmes, PR descriptions, or commit messages."
4
+ ---
5
+
6
+ # Technical writing
7
+
8
+ The goal is writing a tired engineer understands on the first read. Four layers get you there, one question each: what kind of document is this, how do sentences address the reader, how much does each sentence carry, and can any sentence be read two ways. Apply all four.
9
+
10
+ Three rules sit above the layers:
11
+
12
+ - **Cut every word that does no work.** If the sentence survives without a word, the word goes. "In order to" is "to". "It is important to note that" is nothing.
13
+ - **Use the short, everyday word.** "Use", not "utilize". "Help", not "facilitate". "Do", not "perform". A long word has to buy its length with precision.
14
+ - **When a rule makes a sentence worse, fix the sentence another way or leave it alone.** The rules serve the reader. A sentence that follows every rule and sounds like a machine wrote it has failed.
15
+
16
+ The codebase is the word list. Write the real symbol, file, flag, or command name, not a synonym or a description of it.
17
+
18
+ Don't invent jargon. Use the words a developer would say out loud: "move", "delete", "a budget that only decreases", not "evacuate", "ratchet", or "endgame". A named pattern is fine when the doc says what it means the first time. Add new offenders to `unslop`'s abstract-metaphor rule with their replacement.
19
+
20
+ ## Vary the rhythm
21
+
22
+ The layers decide what a document says and how much each sentence carries. A doc can obey all of them and still read machine-written: every sentence clipped short, no view anywhere, nothing specific.
23
+
24
+ - Mix sentence lengths on purpose. Short sentences land a point. Longer ones that take their time carry a fact with its condition or consequence.
25
+ - One thought per sentence does not mean one length per sentence. Split the sentence that carries two thoughts. Keep the long sentence that carries one.
26
+ - Have a view where the mode allows it. Explanation weighs trade-offs, so say what you make of them instead of listing pros and cons. Reference stays dry.
27
+ - Be specific over sterile. Not "schema changes can cause issues" but "a column rename fails the build".
28
+
29
+ ## Pick the mode first (Diátaxis)
30
+
31
+ One document, one mode. Two questions pick it: does the content inform action (doing) or understanding (thinking), and does it serve learning or work?
32
+
33
+ - Action + learning: **tutorial**.
34
+ - Action + work: **how-to**.
35
+ - Understanding + work: **reference**.
36
+ - Understanding + learning: **explanation**.
37
+
38
+ Use the compass on a whole document or on one sentence. Reach for it whenever you feel unsure what you are writing. Gut feel is often wrong here.
39
+
40
+ **Tutorial: learning by doing.** You are the teacher. The learner's success is your job, not theirs. Open by saying what the learner will build, not what they will "learn". Every step produces a visible result, early and often. Tell them what they should see: the expected output, the prompt change, the log line. Cut explanation to one clause and a link. Teaching pauses break the lesson. Stay concrete. Write as "we", in commands: "First, do x. Now, do y."
41
+
42
+ **How-to: steps to a goal.** Solve a problem a person has, not an operation the machine can perform. Assume competence. Skip teaching. Action only: no digressions, no background, no completeness for its own sake. Link those instead. Allow forks and judgment: "If you want x, do y." Name the guide by the task: "How to calibrate the radar array", not "Radar array calibration".
43
+
44
+ **Reference: facts for lookup.** Describe. Only describe. No instruction, no persuasion, no opinion. Be dry, complete, and sure: state facts, options, limits, and errors with no hedging. Mirror the structure of the thing described, so code and docs can be navigated together. Put material where readers expect it. Generate from code where possible, so it stays true.
45
+
46
+ **Explanation: understanding and why.** One bounded topic, readable away from the product. Each title should tolerate an implicit "About..." in front. Anchor on a real why question. Give context: design decisions, history, constraints, alternatives. Opinion is allowed here and nowhere else.
47
+
48
+ Don't mix modes: no reference tables inside a tutorial, no tutorial hand-holding inside reference, no arguing inside a how-to. Split and link instead.
49
+
50
+ Source: diataxis.fr, fetched 2026-07-18.
51
+
52
+ ## Write sentences to the reader (Google developer style)
53
+
54
+ - Talk to the reader as "you", in the present tense. "Will" only for things that genuinely happen later.
55
+ - Say who does what: "the compiler checks", not "is checked". Passive is fine only when the actor is unknown or beside the point.
56
+ - Write instructions as commands: "Click Submit." State facts plainly. Never "should be done".
57
+ - Put the condition before the instruction: "To delete the document, click Delete." The reader skips what does not apply.
58
+ - Put the common case first. Exceptions after.
59
+ - Sound like a knowledgeable friend. No buzzwords, no figurative language, no "please" in instructions, and never "simply", "easy", or "quickly" in a procedure. If it were simple, the reader would not be here.
60
+ - Don't pre-announce ("we will soon support...") and don't start consecutive sentences with the same phrase.
61
+ - Read the awkward sentence aloud. If it stays awkward, rewrite it.
62
+ - Link with words that say where the link goes: the page title or a short description. Never "click here". Prefer a sentence of context on the page over a link off it.
63
+ - Headings carry the point, not just the topic ("Pick the mode first", not "Modes"). Sentence case. A task heading is a bare verb phrase ("Create an instance"). A concept heading is a noun phrase. One h1 per page, no skipped levels.
64
+ - Numbered lists for sequences, bullets for everything else. Introduce a list with a complete sentence. Keep items parallel.
65
+ - Code goes in code font. UI elements go in bold. Use serial commas. Drop "etc." and say up front that a list is partial.
66
+
67
+ Source: developers.google.com/style, fetched 2026-07-18.
68
+
69
+ ## Make statements load one at a time (STE rules)
70
+
71
+ - One instruction per sentence. One thought per sentence everywhere else.
72
+ - Split instructions longer than about 20 words and other sentences longer than about 25.
73
+ - Put the warning or condition before the step it guards: "If hot oil touches your skin, injuries can occur."
74
+ - Keep "the" and "a": "Remove backup file" reads two ways. "Remove the backup file" reads one.
75
+ - Give each word one meaning and one job, then keep it. If "check" means inspect, don't also use it for restrain.
76
+ - Pick one word per action and stick to it: "start", not "start" here and "initiate" there.
77
+ - Write procedures as direct commands, never as narration and never in the passive: "Install the component", not "the component must be installed".
78
+ - Avoid "-ing" words where you can. They take too many grammatical jobs and breed misreadings.
79
+
80
+ Source: asd-ste100.org (Issue 9, 2025), fetched 2026-07-18. The numbered rules and dictionary live in the spec PDF. The principles above are the transferable core.
81
+
82
+ ## Leave no sentence open to two readings (Global English)
83
+
84
+ - Keep words like "only" and "not" next to the word they change: "only fails on growth" and "fails only on growth" say different things.
85
+ - Break up long noun strings: "the proto import budget check script" becomes "the script that checks the proto-import budget".
86
+ - Make every "it", "they", and "this" point at one obvious thing. Repeat the noun when in doubt. Never use "this" or "which" to point at a whole clause.
87
+ - Don't drop verbs: "Phase 1 moves the converters and Phase 2 the runtime" leaves Phase 2 without one. Give it one.
88
+ - Keep the small words that show structure. "Ensure that the switch is off" keeps "that" because it makes the sentence parse one way. Never trade clarity for word count.
89
+ - Repeat the article in a series when it prevents a misread: "the client and the host", not "the client and host", when they are two things.
90
+ - Say which parts "and" or "or" joins when a sentence can group two ways. "Both...and", "either...or", and "if...then" are free disambiguators.
91
+ - Use periods, not semicolons. Replace an em dash with a new sentence.
92
+ - Make text in parentheses a full grammatical unit or its own sentence. Never form plurals with "(s)".
93
+ - No slashes: write "a, b, or both" instead of "a/b" or "and/or".
94
+ - Call each thing by one name, everywhere. A doc that says "the gate", "the ratchet", and "the budget check" for one thing teaches three things. Rewording an unchanged sentence between edits costs the same way: don't churn what didn't change.
95
+ - Skip idioms, colloquialisms, Latin abbreviations, and metaphors. A non-native reader, a translator, and an agent all parse plain constructions best.
96
+
97
+ Source: Kohl, The Global English Style Guide (SAS Press). Guideline text fetched from the Internet Archive and the SAS sample chapter, 2026-07-18.
98
+
99
+ ## Voice and repo specifics
100
+
101
+ - Apply the **unslop** skill to every doc this skill touches. That skill owns the slop-pattern catalog: AI vocabulary, filler, hedging, formatting tells.
102
+ - PR descriptions and commit messages are writing too. Every layer except Diátaxis applies to them.
103
+ - Product UI strings are not documentation. Use your product's copy guidelines for those.
104
+ - Indent code snippets with tabs. Write real paths and real symbols. Make every count or tree claim true at the commit that lands it, and include the command that regenerates it.
105
+
106
+ ## Worked example
107
+
108
+ Before:
109
+
110
+ > Configuration of the proto import ratchet budget script parameters is performed via budget.json. Note that it's important to remember that running with --write, which updates the committed budget to reflect the current count, should only be done when lowering it. If exceeded, CI fails.
111
+
112
+ After:
113
+
114
+ > `budget.mjs` reads the committed budget from `budget.json` and counts the files that import protos. If the count exceeds the budget, CI fails. Run `budget.mjs --write` only to lower the budget.
115
+
116
+ The fixes, by layer: "configuration is performed" becomes "`budget.mjs` reads", so someone does something (Google). "Ratchet" goes away. The script's real filename does the naming (jargon rule). The five-noun string breaks up into plain clauses (Global English). The hedge "note that it's important to remember" is deleted (cut every word that does no work). The failure condition moves ahead of the step it explains (STE). The buried "should only be done when lowering" becomes a command with "only" next to its verb (STE). "If exceeded" gets a subject: the count (Global English).
117
+
118
+ ## Review checklist
119
+
120
+ Apply to any prose this skill covers. Item 1 applies only to document sets:
121
+
122
+ 1. Is each file one Diátaxis mode, with links where modes meet?
123
+ 2. Is every instruction written as a command, with its condition in front?
124
+ 3. Does any sentence carry two instructions or two thoughts? Split it.
125
+ 4. Can any word be cut without losing meaning? Cut it.
126
+ 5. Is "only" next to the word it changes? Does every "it" point at one thing? Does every clause keep its verb?
127
+ 6. Does each thing have exactly one name across the docs?
128
+ 7. Would a developer say these words out loud? Replace invented metaphors and fancy synonyms with the plain word or the real symbol name.
129
+ 8. Are all symbols, paths, and counts real at this commit, with the commands that regenerate the counts?
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: typescript-best-practices
3
+ description: TypeScript best practices. Use when reading or editing any .ts or .tsx file.
4
+ ---
5
+
6
+ # TypeScript best practices
7
+
8
+ Apply the **type-system-discipline** principle skill first; this skill grounds it in TypeScript syntax.
9
+
10
+ | Rule | Summary |
11
+ |------|---------|
12
+ | Discriminated unions | Model variants with a `kind` literal discriminant so impossible states can't be represented. No optional-field bags. |
13
+ | Branded types | Brand primitives with `& { readonly __brand: "X" }` so they can't be mixed up. Validate once at creation. |
14
+ | Constructive modeling | Build the shape so the illegal value can't be constructed. `[T, ...T[]]` for non-empty, `[T, T][]` for even length, `start` plus `duration` for a range. Not a runtime guard, not a wish for refinement types. |
15
+ | Simplest total type | Keep `T[]` while every operation on it stays total. Strengthen to `NonEmpty<T>` only where the loose type forces `!`, a cast, or a "should never happen" throw. |
16
+ | `unknown` over `any` | External data is `unknown`. `any` disables type checking everywhere it touches. |
17
+ | No `as` casts | Every `as` is a runtime crash waiting. Cast only after validation. |
18
+ | Narrowing hierarchy | Discriminant switch > `in` operator > `typeof`/`instanceof` > user-defined type guard > `as`. |
19
+ | Type guards | Must verify the claim. A lying guard is worse than `as` because the bug hides behind a name that says it's safe. Name them `isX` or `hasX`. |
20
+ | Exhaustiveness | Inline `const _exhaustive: never = x;` in default arms so the compiler errors when a new variant is added. |
21
+ | `satisfies` over `as` | Validates the value without widening literal types. |
22
+ | Boundary validation | Parse where data crosses in, into a named domain type. `Record<string, unknown>` (however spelled) stops at that parse. Trust types inside. See the **boundary-discipline** principle skill. |
23
+ | Schema-derived types | Reach for `Pick`/`Omit`/`Parameters`/`ReturnType`/`Awaited`/`typeof` before declaring a new interface. |
24
+ | Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
25
+ | Real tests | Don't mock what you can run. Prefer the framework's real test primitives with leak/disposable checks, and verify UI in a running build. Mock only what you can't run locally. |
26
+ | Structured telemetry | Prefer structured logger diagnostics with enough context to debug from an id. No `console.log` in shipped code. |
27
+
28
+ Examples: `references/patterns.md`.
@@ -0,0 +1,292 @@
1
+ # TypeScript patterns
2
+
3
+ Code examples for each rule in `SKILL.md`. The underlying principles are language-agnostic; see the **type-system-discipline** and **boundary-discipline** principle skills.
4
+
5
+ ## Branded types
6
+
7
+ Brand primitives so they can't be mixed up. Validate once at creation; downstream code trusts the type.
8
+
9
+ ```ts
10
+ type AgentId = string & { readonly __brand: "AgentId" };
11
+
12
+ function parseAgentId(input: string): AgentId {
13
+ if (!isUUID(input)) throw new Error(`Invalid agent id: ${input}`);
14
+ return input as AgentId;
15
+ }
16
+
17
+ function focusAgent(id: AgentId): void {
18
+ /* input is trusted */
19
+ }
20
+ ```
21
+
22
+ Match the `readonly __brand: 'X'` shape; don't invent a new convention.
23
+
24
+ ## Discriminated unions
25
+
26
+ If a bug forces the question "wait, can this combination actually happen?", the type is too loose. Model variants with a literal discriminant: every variant shares the field name and each variant's value is unique, so impossible combos can't be represented.
27
+
28
+ ```ts
29
+ // Don't. Boolean + optionals lets contradictory states exist.
30
+ type DiffState = { loading: boolean; diff?: GitDiff; error?: string };
31
+
32
+ // Do. Only valid states exist.
33
+ type DiffState =
34
+ | { kind: "loading" }
35
+ | { kind: "ready"; diff: GitDiff }
36
+ | { kind: "error"; error: string };
37
+ ```
38
+
39
+ Pick one discriminant name (`kind`, `type`, `tag`) and stick to it.
40
+
41
+ ## Constructive modeling
42
+
43
+ Build the type from parts that are all legal instead of restricting a loose type with runtime checks. Adding is easier than subtracting.
44
+
45
+ Non-empty, via a variadic tuple:
46
+
47
+ ```ts
48
+ type NonEmpty<T> = [T, ...T[]];
49
+
50
+ // Don't: T[] plus a length check every caller must repeat
51
+ function pickWinner(entries: string[]): string {
52
+ if (entries.length === 0) throw new Error("no entries");
53
+ return entries[Math.floor(Math.random() * entries.length)];
54
+ }
55
+
56
+ // Do: an empty value of the type can't exist
57
+ function pickWinner(entries: NonEmpty<string>): string {
58
+ return entries[Math.floor(Math.random() * entries.length)];
59
+ }
60
+ ```
61
+
62
+ Where a plain `T[]` arrives, narrow once with a guard. The fact then travels in the type:
63
+
64
+ ```ts
65
+ const isNonEmpty = <T>(arr: T[]): arr is NonEmpty<T> => arr.length > 0;
66
+ ```
67
+
68
+ Even length, as pairs. TypeScript has no refinement types (no `arr.length % 2 === 0` at the type level); you don't need one:
69
+
70
+ ```ts
71
+ type Pairs<T> = [T, T][];
72
+ ```
73
+
74
+ A time range, as start plus duration:
75
+
76
+ ```ts
77
+ // Don't: a comment holds the invariant
78
+ type TimeRange = { start: Date; end: Date }; // start <= end
79
+
80
+ // Do: a negative range can't be written; derive end when needed
81
+ type TimeRange = { start: Date; durationMs: number };
82
+ ```
83
+
84
+ Keep `durationMs` a plain number. Brand it (per Branded types) only if a raw number could be passed where a duration is expected, not by reflex. A `Pairs<T>` is an even-length list under the interpretation you give it, the same way `{ start, durationMs }` is a range. Pick the representation that makes the bad state unconstructable, then expose the reading you need on top (`pairs.flat()`, a `rangeEnd()` helper).
85
+
86
+ ## Simplest total type
87
+
88
+ Don't strengthen everything. Keep `T[]` when every operation on it is total:
89
+
90
+ ```ts
91
+ const sum = (xs: number[]) => xs.reduce((a, b) => a + b, 0); // [] is 0, fine
92
+ ```
93
+
94
+ Strengthen when the loose type forces a lie at a use site. The tells are `!`, `arr[0] as T`, and a "should never happen" throw:
95
+
96
+ ```ts
97
+ // Don't: partiality smuggled past the compiler
98
+ function newestSession(sessions: Session[]): Session {
99
+ return sessions.at(0)!;
100
+ }
101
+
102
+ // Do: strengthen the input; the assertion disappears
103
+ function newestSession(sessions: NonEmpty<Session>): Session {
104
+ return sessions[0];
105
+ }
106
+ ```
107
+
108
+ Weakening the result to `Session | undefined` is the other total signature. Either way the empty case lands at the call site, the one place that knows what empty means.
109
+
110
+ ## `unknown` over `any`
111
+
112
+ `any` disables type checking for everything it touches. External data is always `unknown`. Narrow before use.
113
+
114
+ ```ts
115
+ // Don't
116
+ function handle(input: any) {
117
+ return input.foo.bar;
118
+ }
119
+
120
+ // Do
121
+ function handle(input: unknown) {
122
+ if (typeof input === "object" && input !== null && "foo" in input) {
123
+ // narrowed; compiler verifies access
124
+ }
125
+ }
126
+ ```
127
+
128
+ External sources include RPC payloads, `JSON.parse`, `postMessage`, IPC, file contents, environment variables, database results.
129
+
130
+ ## No `as` casts
131
+
132
+ Every `as` is a potential runtime crash. Cast only after the type system has verified the claim.
133
+
134
+ ```ts
135
+ // Don't
136
+ const user = data as User;
137
+
138
+ // Do. Earn the cast at the boundary.
139
+ function parseUser(data: unknown): User {
140
+ if (typeof data !== "object" || data === null) {
141
+ throw new Error("expected object");
142
+ }
143
+ if (!("id" in data) || typeof (data as Record<string, unknown>).id !== "string") {
144
+ throw new Error("expected id");
145
+ }
146
+ // ... validate all fields
147
+ return data as User; // OK, earned cast after full validation
148
+ }
149
+ ```
150
+
151
+ When refactoring an `as` out of existing code, identify why TypeScript can't infer:
152
+
153
+ - Missing discriminant: add one, switch to a discriminated union.
154
+ - Overly wide source type (e.g. `Record<string, unknown>`): narrow it.
155
+ - Untyped boundary: add a parse function or schema.
156
+ - Genuinely inexpressible: use a branded type or `satisfies`.
157
+
158
+ ## Narrowing hierarchy
159
+
160
+ From best to last-resort:
161
+
162
+ 1. **Discriminated union switch / if.** Compiler narrows automatically.
163
+ 2. **`in` operator.** `"key" in obj` narrows to variants containing that key.
164
+ 3. **`typeof` / `instanceof`.** For primitives and class instances.
165
+ 4. **User-defined type guard.** When the above aren't enough.
166
+ 5. **`as` cast.** Only after validation.
167
+
168
+ ```ts
169
+ function area(s: Shape): number {
170
+ if ("radius" in s) return Math.PI * s.radius ** 2; // narrowed to circle
171
+ return s.width * s.height; // narrowed to rect
172
+ }
173
+ ```
174
+
175
+ ## Type guards
176
+
177
+ A guard must actually verify the claim. A lying guard is worse than `as` because the bug hides behind a name that says it's safe.
178
+
179
+ ```ts
180
+ function isCircle(s: Shape): s is Shape & { kind: "circle" } {
181
+ return s.kind === "circle";
182
+ }
183
+ ```
184
+
185
+ Prefer discriminant narrowing when possible. The guard adds a layer the reader has to follow.
186
+
187
+ ## Exhaustiveness
188
+
189
+ In default arms, assign the discriminant to a `never`-typed local. The compiler errors if a new variant is added without handling.
190
+
191
+ ```ts
192
+ // Value-returning switch
193
+ function area(s: Shape): number {
194
+ switch (s.kind) {
195
+ case "circle":
196
+ return Math.PI * s.radius ** 2;
197
+ case "rect":
198
+ return s.width * s.height;
199
+ default: {
200
+ const _exhaustive: never = s;
201
+ return _exhaustive;
202
+ }
203
+ }
204
+ }
205
+
206
+ // Void switch
207
+ function handle(s: Shape): void {
208
+ switch (s.kind) {
209
+ case "circle":
210
+ drawCircle(s);
211
+ break;
212
+ case "rect":
213
+ drawRect(s);
214
+ break;
215
+ default: {
216
+ const _exhaustive: never = s;
217
+ void _exhaustive;
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ Return-style in value-returning switches; void-style in statement switches.
224
+
225
+ ## `satisfies` over `as`
226
+
227
+ `satisfies` validates without widening literal types.
228
+
229
+ ```ts
230
+ // Don't. Widens, loses literal types.
231
+ const config = { theme: "dark", cols: 3 } as Config;
232
+
233
+ // Do. Validates AND preserves literal types.
234
+ const config = { theme: "dark", cols: 3 } satisfies Config;
235
+ // config.theme is "dark" (literal), not string
236
+ ```
237
+
238
+ ## Boundary validation
239
+
240
+ Validate once where data crosses in; trust types inside. See the **boundary-discipline** principle skill.
241
+
242
+ - **Wire formats** (proto, JSON-RPC): parse with `ignoreUnknownFields` so forward-compatible changes don't break old clients.
243
+ - **Persisted JSON:** versioned blob with a try/catch around the parse.
244
+ - **Don't re-validate** deep in call chains.
245
+
246
+ ## Schema-derived types
247
+
248
+ When a `.proto`, OpenAPI spec, GraphQL schema, or database migration already defines a shape, derive from the generated types instead of duplicating them.
249
+
250
+ ```ts
251
+ // Don't. Duplicate shape, drifts when the schema changes.
252
+ type CheckSummary = {
253
+ totalCount: number;
254
+ checks: { name: string; status: string }[];
255
+ };
256
+ function renderChecks(s: CheckSummary) {
257
+ /* ... */
258
+ }
259
+
260
+ // Do. Derive from the generated schema type.
261
+ import type { ChecksMessage } from "<generated module>";
262
+ function renderChecks(s: Pick<ChecksMessage, "totalCount" | "checks">) {
263
+ /* ... */
264
+ }
265
+ ```
266
+
267
+ Reach for `Pick`, `Omit`, `Parameters`, `ReturnType`, `Awaited`, `typeof` before writing a new interface.
268
+
269
+ ## Object args
270
+
271
+ ```ts
272
+ // Don't. Swap two args, still compiles.
273
+ openFile(uri, {
274
+ startLineNumber: 10,
275
+ startColumn: 1,
276
+ endLineNumber: 10,
277
+ endColumn: 1,
278
+ });
279
+
280
+ // Do. Order-independent, self-documenting.
281
+ openFile({
282
+ uri,
283
+ selection: {
284
+ startLineNumber: 10,
285
+ startColumn: 1,
286
+ endLineNumber: 10,
287
+ endColumn: 1,
288
+ },
289
+ });
290
+ ```
291
+
292
+ Skip on hot paths: per-frame render, tokenizers, parsers, anything in a tight loop where the allocation cost matters.
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: unslop
3
+ description: Cut AI tells from any writing. Must always apply.
4
+ ---
5
+
6
+ # Unslop
7
+
8
+ Edit text to remove AI patterns and add human voice.
9
+
10
+ ## Process
11
+
12
+ 1. Scan for the patterns below.
13
+ 2. Rewrite. Preserve meaning, match intended tone.
14
+ 3. Add soul (see next section).
15
+ 4. Self-audit: "What makes this obviously AI generated?" Fix remaining tells.
16
+
17
+ ## Adding soul
18
+
19
+ Removing patterns is half the job. Sterile, voiceless writing is just as obvious.
20
+
21
+ - **Have opinions.** React to facts instead of neutrally listing pros and cons.
22
+ - **Vary rhythm.** Short sentences. Then longer ones that take their time. Mix it up.
23
+ - **Acknowledge complexity.** "Impressive but also kind of unsettling" beats "impressive."
24
+ - **Use "I" when it fits.** First person isn't unprofessional.
25
+ - **Let some mess in.** Perfect structure looks machine-made.
26
+ - **Be specific.** Not "this is concerning" but "there's something unsettling about agents churning away at 3am."
27
+
28
+ ## Patterns to detect and fix
29
+
30
+ ### Content
31
+
32
+ 1. **Puffery.** "pivotal moment", "testament to", "evolving landscape", "setting the stage for", "indelible mark", "deeply rooted". Cut puffery, state what happened.
33
+ 2. **Name-dropping.** Listing media outlets without context. Pick one, say what was said.
34
+ 3. **Superficial -ing phrases.** "highlighting...", "ensuring...", "reflecting...", "showcasing...", "fostering...". Delete or expand with real sources.
35
+ 4. **Promotional language.** "nestled", "vibrant", "breathtaking", "groundbreaking", "renowned", "stunning", "must-visit". Use neutral descriptions.
36
+ 5. **Vague attributions.** "Experts believe", "Industry reports suggest", "Some critics argue". Name the source or delete.
37
+ 6. **Formulaic challenges.** "Despite challenges... continues to thrive." Replace with specific facts.
38
+
39
+ ### Language
40
+
41
+ 7. **AI vocabulary.** Additionally, crucial, delve, enduring, enhance, fostering, garner, interplay, intricate, landscape (abstract), pivotal, showcase, tapestry (abstract), testament, underscore, vibrant. Replace with plain words.
42
+ 8. **Fancy ways to say "is".** "serves as", "stands as", "boasts", "features". Just say "is" or "has".
43
+ 9. **"Not just X, but Y."** State the point directly instead.
44
+ 10. **Rule of three.** Forcing ideas into groups of three. Use the natural number.
45
+ 11. **Synonym cycling.** Protagonist, main character, central figure, hero all in one paragraph. Pick one, repeat it.
46
+ 12. **False ranges.** "from X to Y" where X and Y aren't on a meaningful scale. List topics directly.
47
+
48
+ ### Style
49
+
50
+ 13. **Em dash overuse.** Avoid em dashes entirely. Use periods or commas only (no parentheses, no en dashes, no hyphen-as-dash substitutes). Em dashes are an AI tell, and reaching for parentheses instead just trades one tell for another. If a thought needs separation, end the sentence or use a comma.
51
+ 14. **Colon overuse.** Colons are fine before a list or example. Not as mid-sentence connectors. "If you're coming from traditional automation: instead of registering event handlers, you describe conditions" adds nothing with the colon. Rewrite to let the point stand on its own without comparison framing. "Describing when the scheduler should fire works best as plain English." Same meaning, no crutch punctuation.
52
+ 15. **Boldface overuse.** Don't bold every proper noun or acronym.
53
+ 16. **Inline-header lists.** The tell is a bold label and colon that restates the line: "**Performance:** Performance improved...". Convert those to prose. A bold lead-in that ends in a period, names the item, and is followed by genuinely new detail ("**Schema in TypeScript.** Tables live in one file.") is fine, not a tell.
54
+ 17. **Title case headings.** Use sentence case.
55
+ 18. **Decorative emojis.** Remove from headings and bullets.
56
+ 19. **Curly quotes.** Replace with straight quotes.
57
+
58
+ ### Communication artifacts
59
+
60
+ 20. **Chatbot phrases.** "I hope this helps!", "Let me know if...", "Of course!", "Certainly!", "Found the smoking gun!" Remove.
61
+ 21. **Cutoff disclaimers.** "While specific details are limited..." Find sources or remove.
62
+ 22. **Sycophantic tone.** "Great question! You're absolutely right!" Respond directly.
63
+
64
+ ### Filler
65
+
66
+ 23. **Filler phrases.** "In order to" becomes "To". "Due to the fact that" becomes "Because". "It is important to note that" gets deleted.
67
+ 24. **Excessive hedging.** "could potentially possibly be argued that it might" becomes "may".
68
+ 25. **Generic conclusions.** "The future looks bright." State specific plans or facts.
69
+
70
+ ### Jargon
71
+
72
+ 26. **Abstract metaphor nouns.** Substrate, wedge, vector, locus, vantage, nexus, primitive (as noun), harness (as metaphor), surface (as in "API surface"), bedrock, scaffolding (as metaphor), modality, paradigm, gold-plating, ratchet (as metaphor), evacuate (for moving code), endgame, north star, flywheel. These read as technical but usually have a plainer concrete word. "Substrate" becomes "base". "Wedge in" becomes "add". "Vector" becomes "way" or "method". "Gold-plating" becomes "more than the job needs". "Ratchet" becomes the mechanism's real name or "a limit that only tightens". "Evacuate" becomes "move out". "Endgame" becomes "the last phase". Pick the concrete word.
73
+
74
+ ### Plain speech
75
+
76
+ 27. **Say what it does, not how it feels.** "the database stays close at hand", "SQL you can read", "types that follow your schema" name a feeling. The fix names the mechanism or a number: "`.toSQL()` returns the exact string sent to the database", "a column rename fails the build". Ask what the sentence tells the reader to do or know, then write that. If you can't restate it as a concrete instruction, fact, or number, cut it. One more check: if the sentence could appear unchanged in another project's docs, it says nothing about this one. Cut it.
77
+ 28. **Shorten or split dense sentences.** If the reader has to backtrack to parse a sentence, break it in two or drop clauses. One idea per sentence.
78
+ 29. **Active voice.** Prefer it. Catch "is/are/was/were + past participle" and name the actor: "queries are validated" becomes "the compiler validates queries", "the file is parsed by the loader" becomes "the loader parses the file". Passive is fine only when the actor is unknown or genuinely doesn't matter.
79
+ 30. **Cut adverbs, or use a stronger verb.** "runs quickly" becomes "is fast" or the number. "significantly improves" becomes the measured delta. An adverb propping up a weak verb means the verb is wrong.
80
+ 31. **Prefer the plain word.** "utilize" becomes "use", "leverage" becomes "use", "facilitate" becomes "help", "numerous" becomes "many", "in the event that" becomes "if". The fancier synonym is rarely clearer.