@minko-ai/minko 0.1.0 → 0.1.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 (189) hide show
  1. package/README.md +577 -2
  2. package/assets/mascot-preview.png +0 -0
  3. package/assets/mascot-preview.txt +46 -0
  4. package/assets/mascot-source.png +0 -0
  5. package/assets/skills/README.md +21 -0
  6. package/assets/skills/brainstorming/LICENSE +21 -0
  7. package/assets/skills/brainstorming/SKILL.md +316 -0
  8. package/assets/skills/buddhist-method/LICENSE +21 -0
  9. package/assets/skills/buddhist-method/SKILL.md +137 -0
  10. package/assets/skills/buddhist-method/references/ariyasacca-debug.md +57 -0
  11. package/assets/skills/buddhist-method/references/extended-principles.md +100 -0
  12. package/assets/skills/code-humanizer/LICENSE +21 -0
  13. package/assets/skills/code-humanizer/SKILL.md +174 -0
  14. package/assets/skills/code-review/LICENSE +21 -0
  15. package/assets/skills/code-review/SKILL.md +232 -0
  16. package/assets/skills/code-review/reference/angular.md +768 -0
  17. package/assets/skills/code-review/reference/architecture-review-guide.md +472 -0
  18. package/assets/skills/code-review/reference/c.md +890 -0
  19. package/assets/skills/code-review/reference/code-quality-universal.md +488 -0
  20. package/assets/skills/code-review/reference/code-review-best-practices.md +136 -0
  21. package/assets/skills/code-review/reference/common-bugs-checklist.md +302 -0
  22. package/assets/skills/code-review/reference/cpp.md +893 -0
  23. package/assets/skills/code-review/reference/cross-cutting/async-concurrency-patterns.md +515 -0
  24. package/assets/skills/code-review/reference/cross-cutting/error-handling-principles.md +492 -0
  25. package/assets/skills/code-review/reference/cross-cutting/n-plus-one-queries.md +309 -0
  26. package/assets/skills/code-review/reference/cross-cutting/sql-injection-prevention.md +308 -0
  27. package/assets/skills/code-review/reference/cross-cutting/xss-prevention.md +264 -0
  28. package/assets/skills/code-review/reference/csharp.md +525 -0
  29. package/assets/skills/code-review/reference/css-less-sass.md +661 -0
  30. package/assets/skills/code-review/reference/dart.md +670 -0
  31. package/assets/skills/code-review/reference/django.md +985 -0
  32. package/assets/skills/code-review/reference/fastapi.md +580 -0
  33. package/assets/skills/code-review/reference/go.md +993 -0
  34. package/assets/skills/code-review/reference/java.md +409 -0
  35. package/assets/skills/code-review/reference/java8.md +586 -0
  36. package/assets/skills/code-review/reference/kotlin.md +1018 -0
  37. package/assets/skills/code-review/reference/nestjs.md +593 -0
  38. package/assets/skills/code-review/reference/performance-review-guide.md +816 -0
  39. package/assets/skills/code-review/reference/php.md +684 -0
  40. package/assets/skills/code-review/reference/python.md +1073 -0
  41. package/assets/skills/code-review/reference/qt.md +757 -0
  42. package/assets/skills/code-review/reference/react.md +871 -0
  43. package/assets/skills/code-review/reference/ruby.md +964 -0
  44. package/assets/skills/code-review/reference/rust.md +846 -0
  45. package/assets/skills/code-review/reference/security-review-guide.md +494 -0
  46. package/assets/skills/code-review/reference/svelte.md +1064 -0
  47. package/assets/skills/code-review/reference/swift.md +936 -0
  48. package/assets/skills/code-review/reference/typescript.md +1016 -0
  49. package/assets/skills/code-review/reference/vue.md +924 -0
  50. package/assets/skills/code-review/reference/zig.md +440 -0
  51. package/assets/skills/cyclomatic-complexity/LICENSE +201 -0
  52. package/assets/skills/cyclomatic-complexity/SKILL.md +69 -0
  53. package/assets/skills/five-whys/LICENSE +21 -0
  54. package/assets/skills/five-whys/SKILL.md +247 -0
  55. package/assets/skills/five-whys/examples/performance-regression.md +161 -0
  56. package/assets/skills/five-whys/examples/production-incident.md +134 -0
  57. package/assets/skills/five-whys/references/software-patterns.md +284 -0
  58. package/assets/skills/five-whys/references/toyota-origins.md +257 -0
  59. package/assets/skills/systematic-debugging/LICENSE +21 -0
  60. package/assets/skills/systematic-debugging/SKILL.md +283 -0
  61. package/assets/skills/test-driven-development/LICENSE +21 -0
  62. package/assets/skills/test-driven-development/SKILL.md +330 -0
  63. package/assets/skills/verification-before-completion/LICENSE +21 -0
  64. package/assets/skills/verification-before-completion/SKILL.md +120 -0
  65. package/assets/skills/vibe-sec/LICENSE +201 -0
  66. package/assets/skills/vibe-sec/SKILL.md +758 -0
  67. package/assets/skills/writing-plans/LICENSE +21 -0
  68. package/assets/skills/writing-plans/SKILL.md +204 -0
  69. package/bin/minko.js +2 -2
  70. package/dist/agent/approvalTokens.js +224 -0
  71. package/dist/agent/branchLock.js +315 -0
  72. package/dist/agent/compact.js +182 -0
  73. package/dist/agent/context.js +183 -0
  74. package/dist/agent/cron.js +326 -0
  75. package/dist/agent/hooks.js +211 -0
  76. package/dist/agent/lanes.js +511 -0
  77. package/dist/agent/loop.js +337 -0
  78. package/dist/agent/memory.js +159 -0
  79. package/dist/agent/permissions.js +71 -0
  80. package/dist/agent/plan.js +118 -0
  81. package/dist/agent/prompt.js +120 -0
  82. package/dist/agent/subagent.js +67 -0
  83. package/dist/agent/tasks.js +449 -0
  84. package/dist/agent/transcript.js +62 -0
  85. package/dist/agent/workerStore.js +172 -0
  86. package/dist/agent/workerTypes.js +1 -0
  87. package/dist/agent/workers.js +503 -0
  88. package/dist/cli/app.js +261 -0
  89. package/dist/cli/argv.js +206 -0
  90. package/dist/cli/commandsCommand.js +12 -0
  91. package/dist/cli/configCommand.js +170 -0
  92. package/dist/cli/doctorCommand.js +112 -0
  93. package/dist/cli/exportCommand.js +85 -0
  94. package/dist/cli/forkCommand.js +24 -0
  95. package/dist/cli/linkCommand.js +272 -0
  96. package/dist/cli/loginCommand.js +69 -0
  97. package/dist/cli/mcpLoginCommand.js +68 -0
  98. package/dist/cli/pluginCommand.js +113 -0
  99. package/dist/cli/powerCommand.js +174 -0
  100. package/dist/cli/promptFooter.js +74 -0
  101. package/dist/cli/relayCommand.js +38 -0
  102. package/dist/cli/sandboxCommand.js +31 -0
  103. package/dist/cli/serveCommand.js +104 -0
  104. package/dist/cli/statusCommand.js +120 -0
  105. package/dist/cli/tui.js +1104 -0
  106. package/dist/commands/registry.js +99 -0
  107. package/dist/config/paths.js +81 -0
  108. package/dist/config/store.js +605 -0
  109. package/dist/index.js +199 -0
  110. package/dist/link/protocol.js +159 -0
  111. package/dist/link/relay.js +184 -0
  112. package/dist/link/server.js +566 -0
  113. package/dist/link/tunnel.js +90 -0
  114. package/dist/lsp/client.js +340 -0
  115. package/dist/lsp/tool.js +177 -0
  116. package/dist/mcp/client.js +469 -0
  117. package/dist/mcp/httpClient.js +191 -0
  118. package/dist/mcp/server.js +206 -0
  119. package/dist/mcp/tools.js +173 -0
  120. package/dist/oauth/device.js +111 -0
  121. package/dist/oauth/store.js +56 -0
  122. package/dist/plugins/loader.js +291 -0
  123. package/dist/plugins/market.js +98 -0
  124. package/dist/providers/anthropic.js +279 -0
  125. package/dist/providers/factory.js +109 -0
  126. package/dist/providers/openai.js +182 -0
  127. package/dist/providers/retry.js +95 -0
  128. package/dist/providers/sse.js +67 -0
  129. package/dist/providers/types.js +10 -0
  130. package/dist/rag/embeddings.js +171 -0
  131. package/dist/rag/index.js +373 -0
  132. package/dist/rag/server.js +167 -0
  133. package/dist/rag/tool.js +148 -0
  134. package/dist/sandbox/index.js +55 -0
  135. package/dist/sdk/server.js +150 -0
  136. package/dist/sdk/session.js +104 -0
  137. package/dist/session/liveness.js +148 -0
  138. package/dist/session/recorder.js +49 -0
  139. package/dist/session/store.js +171 -0
  140. package/dist/skills/index.js +428 -0
  141. package/dist/theme.js +30 -0
  142. package/dist/tools/fs.js +195 -0
  143. package/dist/tools/notebook.js +109 -0
  144. package/dist/tools/registry.js +32 -0
  145. package/dist/tools/search.js +130 -0
  146. package/dist/tools/shell.js +200 -0
  147. package/dist/tools/structured.js +83 -0
  148. package/dist/tools/types.js +1 -0
  149. package/dist/ui/ansi.js +135 -0
  150. package/dist/ui/banner.js +103 -0
  151. package/dist/ui/input.js +49 -0
  152. package/dist/ui/inputModel.js +113 -0
  153. package/dist/ui/keyboard.js +142 -0
  154. package/dist/ui/mascot.js +34 -0
  155. package/dist/ui/mascotData.js +96 -0
  156. package/dist/ui/md.js +183 -0
  157. package/dist/ui/screen.js +49 -0
  158. package/dist/ui/spinner.js +52 -0
  159. package/dist/ui/transcript.js +287 -0
  160. package/dist/util/clipboard.js +53 -0
  161. package/dist/util/errors.js +50 -0
  162. package/dist/util/version.js +12 -0
  163. package/dist/web/fetch.js +168 -0
  164. package/dist/web/search.js +97 -0
  165. package/package.json +45 -36
  166. package/src/agent/loop.ts +0 -159
  167. package/src/agent/prompt.ts +0 -45
  168. package/src/cli/app.ts +0 -396
  169. package/src/cli/argv.ts +0 -139
  170. package/src/cli/configCommand.ts +0 -175
  171. package/src/config/paths.ts +0 -20
  172. package/src/config/store.ts +0 -149
  173. package/src/index.ts +0 -120
  174. package/src/providers/anthropic.ts +0 -215
  175. package/src/providers/openai.ts +0 -158
  176. package/src/providers/sse.ts +0 -57
  177. package/src/providers/types.ts +0 -59
  178. package/src/session/store.ts +0 -125
  179. package/src/theme.ts +0 -41
  180. package/src/tools/fs.ts +0 -143
  181. package/src/tools/registry.ts +0 -19
  182. package/src/tools/shell.ts +0 -120
  183. package/src/tools/types.ts +0 -26
  184. package/src/ui/ansi.ts +0 -110
  185. package/src/ui/banner.ts +0 -39
  186. package/src/ui/input.ts +0 -54
  187. package/src/ui/md.ts +0 -160
  188. package/src/ui/spinner.ts +0 -58
  189. package/src/util/errors.ts +0 -48
@@ -0,0 +1,100 @@
1
+ # Extended Principles
2
+
3
+ These are situational disciplines. Read the section that fits your current bind.
4
+
5
+ ---
6
+
7
+ ## Apāyakosalla (อปายโกศล) — Skill in recognizing decline
8
+
9
+ From the *kosalla* triad (*āya* — growth, *apāya* — decline, *upāya* — means), *apāyakosalla* is the specific skill of noticing when you are getting worse, not better.
10
+
11
+ **When to consult:** you have tried the same approach two or three times with adjustments, and the situation isn't improving.
12
+
13
+ The instinct, especially under sunk cost, is to keep adjusting parameters. The discipline is to notice the *trajectory* and stop.
14
+
15
+ **Concrete check:**
16
+ - After every retry, ask: is this attempt closer to working than the last one?
17
+ - If two consecutive attempts are not closer, stop. The next attempt is unlikely to be different in kind.
18
+ - Step back, restate the problem (use *pariññā* from `ariyasacca-debug.md`), and consider that the *approach itself* may be wrong, not just its parameters.
19
+
20
+ **Common failure:** debugging a config issue by trying value after value. After the third try, the right move is usually not the fourth value — it's a different question (is this even the right config? is the config being read at all?).
21
+
22
+ ---
23
+
24
+ ## Appamāda (อัปปมาทะ) — Heedfulness across long tasks
25
+
26
+ The Buddha's last words, in essence: *"appamādena sampādetha"* — "strive on with heedfulness." *Appamāda* is sustained vigilance — the opposite of letting standards drift as a task wears on.
27
+
28
+ **When to consult:** you are deep in a multi-step task. You were careful at step 1. You're now at step 8, and the same checks feel tedious.
29
+
30
+ Long tasks fail at the end, not the beginning. The drift is gradual:
31
+ - Skipping a re-read of the file because you "just looked at it."
32
+ - Skipping verification of a fact because you're tired of checking.
33
+ - Approving your own output because the project is almost done.
34
+
35
+ **Concrete check:** apply the same discipline to step N as to step 1. If a checklist applied at the start, it applies now. The signal that you're drifting is the feeling that "this part doesn't need the check" — that feeling is exactly when the check is needed.
36
+
37
+ ---
38
+
39
+ ## Sappurisadhamma — selected three (สัปปุริสธรรม) — Knowing self, time, audience
40
+
41
+ The full list has seven items. Three of them transfer cleanly to work decisions.
42
+
43
+ ### Attaññutā (อัตตัญญุตา) — knowing oneself
44
+
45
+ Knowing your own state, capacity, and limits. For an LLM:
46
+ - What do I actually know vs. what am I retrieving from pattern? (See *Kalāma* in the main SKILL.md.)
47
+ - Have I done this kind of task before in this conversation, or am I extrapolating?
48
+ - Am I confident, or merely fluent?
49
+
50
+ If the answer is "I don't actually know," say so. The credibility cost of "I'm not sure" is small. The cost of being confidently wrong is large.
51
+
52
+ ### Kālaññutā (กาลัญญุตา) — knowing the time
53
+
54
+ Knowing when to act, when to ask, when to wait. For work:
55
+ - When should I ask the user a clarifying question vs. proceed on a reasonable assumption? Rule of thumb: if a wrong assumption would waste more than a few minutes of the user's review time, ask.
56
+ - When should I commit to an approach vs. keep options open?
57
+ - When is the right moment to surface a concern — now, or after the current step?
58
+
59
+ ### Parisaññutā (ปริสัญญุตา) — knowing the audience
60
+
61
+ Knowing who the work is for. For a piece of code, a comment, an error message:
62
+ - Who reads this? A junior developer? A CI log? An end user under stress?
63
+ - What do they need from this artifact at the moment they encounter it?
64
+ - What is the right register, level of detail, terminology?
65
+
66
+ This shapes everything from variable names to error message verbosity.
67
+
68
+ ---
69
+
70
+ ## Atthatraya — three levels of benefit
71
+
72
+ Three time horizons of benefit, from the *attha* trilogy:
73
+ - **Diṭṭhadhammika-attha** (ทิฏฐธัมมิกัตถะ) — present-life benefit (immediate)
74
+ - **Samparāyika-attha** (สัมปรายิกัตถะ) — future benefit (long-term)
75
+ - **Paramattha** (ปรมัตถะ) — ultimate / highest benefit
76
+
77
+ For coding decisions, the first two map cleanly.
78
+
79
+ **When to consult:** you are choosing between a quick fix and a proper one.
80
+
81
+ The discipline is not to default to either, but to *name the trade-off explicitly*:
82
+ - Which benefit am I optimizing for?
83
+ - Is the user aware of the trade-off?
84
+ - If I'm picking the short-term fix, is there a TODO and a clear note about what's deferred?
85
+
86
+ **Common failure:** silently picking the hack because it's faster, without surfacing the cost. The user discovers the trade-off later, having lost the chance to choose.
87
+
88
+ ---
89
+
90
+ ## Majjhimā Paṭipadā (มัชฌิมาปฏิปทา) — Middle way
91
+
92
+ The path between extremes. For coding: between over-engineering and under-engineering.
93
+
94
+ **When to consult:** you are sketching a solution and you can feel either pull — "I should just hardcode this" or "I should build a framework for this."
95
+
96
+ **Concrete check:** describe two extremes — the minimal hack and the maximally general solution — and pick the simplest thing that handles the cases you actually have, plus one degree of obvious extension. Avoid both:
97
+ - The hack that won't survive contact with a second use case.
98
+ - The framework that solves problems you don't have, at the cost of clarity for the one you do.
99
+
100
+ The middle is not a compromise; it is the precise fit. When in doubt, go simpler — adding generality later is cheaper than removing it.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leonard (Shangao Li)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: code-humanizer
3
+ version: 0.2.0
4
+ description: Use when AI-written code needs structural cleanup or when implementing a change under a guard against AI coding slop — duplicated reimplementations of existing helpers, try-import fallbacks, broad exception swallowing, speculative abstraction layers, _v2 copies, dead "for future use" code, narrating comments — including requests to "deslop", "remove AI slop", "humanize code", review an AI-generated PR beyond tests passing, or prevent these patterns in the current change.
5
+ license: MIT
6
+ compatibility: any-agent
7
+ ---
8
+
9
+ # Code Humanizer
10
+
11
+ Remove signs of AI-generated code from a repository, or prevent the same patterns in the current change with Guard mode. The prose [humanizer](https://github.com/blader/humanizer) removes AI *writing* patterns; this handles AI *coding* patterns — the structural debt agents leave behind when they optimize for "tests pass" instead of "codebase stays healthy."
12
+
13
+ **Core principle:** AI code slop is not ugly code — it is code that *works* but degrades the repository: it reimplements what already exists, adds abstraction nobody asked for, swallows errors it should surface, and hedges against situations that cannot occur. Unlike prose, code has an oracle: **the test suite decides what "meaning-preserving" means. Use it constantly.**
14
+
15
+ ## Iron rules
16
+
17
+ Rules 1–4 govern **cleanup of pre-existing code** in Modes A/B. In Guard mode they apply to any cleanup performed after implementation, not to the requested feature work itself. Rule 5 applies in every mode.
18
+
19
+ 1. **Behavior preservation is absolute.** "Cleanup" that changes behavior is a bug with good intentions. This includes *error types and error timing* — swapping an accidental `AttributeError` for a "nicer" `ValueError` changes behavior for every caller that catches it. If you find a latent bug or an ugly-but-load-bearing behavior: **flag it in the report; never fix it silently as part of cleanup.**
20
+ 2. **No tests → no cleanup edits.** Run the test suite first. If it doesn't exist, doesn't pass, or doesn't cover the pre-existing code you'd clean, you may only **report** that debt (Mode A). Offer to write characterization tests first. This does not forbid implementing a requested change in a project whose tests are incomplete; report the verification gap.
21
+ 3. **Report before rewriting pre-existing code.** Default to Mode A (scan → report). Only enter Mode B (fix) when the maintainer approves, or was explicit that they want fixes. Guard mode may directly avoid or remove slop introduced by the current change.
22
+ 4. **One pattern-class per cleanup commit.** Each commit that removes pre-existing slop handles one kind and passes the full suite. A red test reverts the commit — do not "fix forward" into unrelated code. Ordinary feature commits under Guard mode need not be split by pattern when the prevention is inseparable from the implementation.
23
+ 5. **Search before you judge duplication.** Build a mental index of the repo's existing helpers *before* scanning or implementing (grep `utils`, `helpers`, `common`, validators, existing base classes). You cannot recognize a reimplementation if you don't know what exists.
24
+
25
+ ## Pattern catalog
26
+
27
+ Severity per finding: **0** absent · **1** present but justified (→ exempt, do not touch) · **2** minor debt · **3** clear debt, raises future maintenance cost · **4** severe, breaks semantics or architecture boundaries.
28
+
29
+ ### Tier 1 — Duplication and reinvention
30
+
31
+ **1. Reimplementing an existing helper** *(the signature AI tell)*
32
+ **Signals:** new private function whose body resembles something in `utils`/`helpers`/a sibling module; a regex/validation/parsing/formatting block that the repo already owns; new code that imports nothing from the package it lives in.
33
+ **Problem:** agents write code from the prompt outward, not from the repo inward. Every duplicate forks future fixes.
34
+ ```python
35
+ # Before — repo already has utils.validate_email
36
+ def _is_valid_email(s):
37
+ pattern = r"^[\w.+-]+@[\w-]+\.[\w.]+$"
38
+ if re.match(pattern, s):
39
+ return True
40
+ return False
41
+
42
+ # After
43
+ from .utils import validate_email
44
+ ```
45
+
46
+ **2. `_v2` / `_new` / `_impl` clones**
47
+ **Signals:** `foo` and `foo_v2` both alive; `enhanced_`, `improved_`, `new_` prefixes; copy-pasted body with one branch changed.
48
+ **Problem:** the agent didn't dare modify the original, so now there are two sources of truth. Merge them (a parameter or the newer body), keep one name, unless a documented migration is in progress.
49
+
50
+ **3. Reinventing the standard library / installed deps**
51
+ **Signals:** hand-rolled `groupby`, deep-copy-via-JSON, manual URL parsing, bespoke date math; the equivalent is in `stdlib` or an already-installed dependency.
52
+
53
+ ### Tier 2 — Speculative architecture
54
+
55
+ **4. Single-implementation abstraction**
56
+ **Signals:** ABC / interface / `Protocol` with exactly one concrete class; a registry or factory with exactly one registration; "pluggable backend" used from one call site.
57
+ **Problem:** flexibility for a future that was never requested. Inline it; the abstraction can return *when the second implementation arrives*.
58
+ ```python
59
+ # Before: AbstractReportBackend + BackendRegistry + TextReportBackend (3 classes, 40 lines)
60
+ # After:
61
+ _BACKENDS = {"text": lambda rows: "\n".join(map(str, rows))}
62
+ ```
63
+
64
+ **5. Dead "for future use" code**
65
+ **Signals:** helpers with no call site; parameters no caller passes; `export_*`/`*_to_dict` "provided for extensibility"; docstrings saying *flexible, extensible, seamlessly*.
66
+ **Problem:** unreachable code still costs review, grep hits, and false confidence. Delete it — git remembers. **Grep the whole repo (and scripts, and templates) for usages first.**
67
+
68
+ **6. Wrapper that adds nothing**
69
+ **Signals:** function whose body is a single call with the same arguments; class inheriting only to `super()` everything.
70
+
71
+ **7. Config/API sprawl for a local case**
72
+ **Signals:** new global flag, config field, CLI arg, or public parameter consulted from exactly one place; module-level constant that only one function reads.
73
+ **Problem:** every global knob multiplies the state space forever. Make it local, or a parameter of the one function that cares.
74
+
75
+ ### Tier 3 — Defensive slop
76
+
77
+ **8. Broad exception swallowing**
78
+ **Signals:** `except Exception:`/bare `except` that returns a default, logs nothing, or `pass`es; `.get()` chains that convert bugs into silently-wrong output.
79
+ **Problem:** converts crashes (visible, debuggable) into corruption (invisible). Narrow to the exceptions that can actually occur, or let it raise. **Careful — this is behavior; may need maintainer sign-off (Iron rule 1).**
80
+
81
+ **9. Unjustified try-import fallback**
82
+ **Signals:** `try: import fast_x except ImportError: import x` with no benchmark, no extras entry in packaging metadata, no test covering the fallback path; optional-dependency dances for deps that are not optional.
83
+ **Problem:** two code paths, one tested. If the dependency matters, declare it; if not, drop it.
84
+
85
+ **10. Attribute-probing chains**
86
+ **Signals:** `hasattr`/`getattr`/`isinstance` ladders to accept "dict or object or maybe None"; the same probing expression copy-pasted at every field access.
87
+ **Problem:** the agent didn't check what type actually flows here, so it accepted everything. Find the real type (tests tell you), then write to it.
88
+
89
+ **11. Paranoid re-validation**
90
+ **Signals:** `if x is not None` on values that were just constructed; re-checking invariants the type system or an upstream gate already guarantees.
91
+
92
+ ### Tier 4 — Noise
93
+
94
+ **12. Narrating comments**
95
+ **Signals:** comment restates the next line (`# Join the rows with newlines`); comments addressed to the reviewer (`# This change ensures correctness`); TODO the agent wrote and resolved in the same PR.
96
+ **Rule:** a comment earns its line only by stating something the code *cannot* say (constraint, invariant, why-not-the-obvious-way).
97
+
98
+ **13. Boilerplate docstrings**
99
+ **Signals:** docstring is the function name with spaces (`def get_user(): """Get the user."""`); marketing adjectives (*robust, comprehensive, seamless*).
100
+
101
+ **14. Dead imports, unused variables, decorative banners**
102
+ **Signals:** imports left from deleted attempts; `# ===== SECTION =====` banners; emoji in identifiers/log lines; leftover `print`/debug logging.
103
+
104
+ ### Tier 5 — Test slop (report-only by default)
105
+
106
+ **15. Tests that assert the mock** — every collaborator mocked, the assertion checks the mock was called; the test can never fail for a real reason.
107
+ **16. Trivial or duplicated assertions** — asserting literals, or the same case re-tested under three names to inflate coverage.
108
+
109
+ ## What NOT to flag (false-positive guards)
110
+
111
+ Severity 1 = justified. The pattern's *shape* is not the crime; the *lack of justification* is. Look for justification before flagging:
112
+
113
+ - **Fallbacks/compat shims with a reason** — documented platform differences, packaged extras (`pip install pkg[fast]`), version gates during a migration. The tell is *unjustified*, not *fallback*.
114
+ - **Defensive code at trust boundaries** — parsing user input, network payloads, plugin-supplied objects. Probing and broad-catch are legitimate exactly where data is untrusted (but should still log, not `pass`).
115
+ - **Registries/ABCs in actual plugin systems** — if entry points load implementations dynamically, one *in-repo* implementation doesn't mean single-implementation.
116
+ - **Duplication with a measured reason** — a hot-path copy with a benchmark comment; vendored code kept intentionally in sync.
117
+ - **`_v2` during a documented migration** — check git history / CHANGELOG before merging.
118
+ - **Error swallowing that logs and is commented** — a deliberate resilience decision is the maintainer's to revisit, not yours.
119
+ - **Style you merely dislike.** This skill removes *structural debt*, not formatting opinions — that's the linter's job.
120
+
121
+ When in doubt: report at severity 1–2, don't fix. **Look for clusters** — one narrating comment is nothing; narrating comments + a single-impl registry + a `_v2` + an unused export in the same PR is a confession.
122
+
123
+ ## Workflow
124
+
125
+ **Mode A — Scan (default):**
126
+ 1. **Oracle check:** run the test suite; record pass state and rough coverage of target files.
127
+ 2. **Index:** map the repo's existing helpers/abstractions (this powers pattern 1).
128
+ 3. **Scan:** walk the target (a diff, a PR, a module, or the whole repo) against the catalog. For each finding: `pattern # · file:line · severity · evidence (one line) · proposed fix · behavior risk (none / error-type / needs-maintainer)`.
129
+ 4. **Report:** findings grouped by pattern, severities summed per file, exemptions listed with their justification. End with the proposed fix order (highest severity, lowest behavior-risk first).
130
+
131
+ **Mode B — Fix (on approval):**
132
+ 5. For each pattern-class, in the approved order: fix all instances → run the full suite → commit (`deslop: <pattern> (#N) — <n> instances`). Red tests revert the commit.
133
+ 6. Anything with behavior risk (error types, swallowed exceptions, unknown-key paths) is **proposed as its own clearly-labeled commit or left as a report item** — never mixed into safe cleanups.
134
+ 7. **Audit pass:** re-scan the result and ask *"what would still make a reviewer say an AI wrote this?"* Fix or report the remainder.
135
+ 8. **Summary:** per-pattern counts removed, LOC delta, exemptions honored, behavior-risk items awaiting the maintainer.
136
+
137
+ **Mode C — Guard (while implementing):**
138
+
139
+ Enter Guard mode when the user asks to prevent AI coding slop while implementing a change. It is a thin prevention layer, not a general coding methodology. It applies the same catalog to the implementation decisions and resulting diff of the current task. Do not turn it into a repository-wide cleanup unless the user asks.
140
+
141
+ **Before coding — work from the repository inward:**
142
+ 1. Search existing helpers, utilities, sibling implementations, base classes, validators, and installed dependencies before creating a new one.
143
+ 2. Trace the real types, invariants, and error behavior on the path being changed. Do not compensate for unknowns with probing chains or broad fallbacks.
144
+ 3. Identify the scope: exploratory code, an internal module, or a stable/public boundary. Look for documented migrations, compatibility requirements, and actual plugin loading before judging their shapes.
145
+
146
+ **While coding — use five decision rules:**
147
+ - **Reuse before recreating** (patterns 1–3): extend or call what the repository already owns; do not fork helpers or standard-library behavior.
148
+ - **Concrete before abstract** (patterns 4–7): keep a local need local; wait for a real second implementation before adding an abstraction, registry, global knob, or public API.
149
+ - **Know before defending** (patterns 8–11): write against the actual contract; defensive flexibility belongs at real trust boundaries, not wherever the type was left unexamined.
150
+ - **Explain why, not what** (patterns 12–14): comments record constraints and non-obvious reasons; remove narration, boilerplate, and implementation debris.
151
+ - **Test behavior, not scaffolding** (patterns 15–16): assert externally meaningful behavior and failure cases, not merely that mocks were called.
152
+
153
+ **After coding — audit the diff, index the repo:**
154
+ 1. Run the relevant tests and inspect only the current diff against the catalog. Duplication checks still search the whole repository.
155
+ 2. Fix safe slop introduced by the current change. Do not opportunistically refactor unrelated pre-existing findings; report them separately.
156
+ 3. Record justified exemptions briefly. Expand into a full findings table only when meaningful debt or behavior risk remains.
157
+ 4. End with a compact guard audit, for example: reused existing helper; no new speculative API; one exploratory exemption; tests passed.
158
+
159
+ ### Exploration is not production debt
160
+
161
+ Exploration may justify temporary duplication, hard-coded values, parallel variants, or rough scripts, especially under `experiments/`, `scratch/`, `notebooks/`, and `prototypes/`. Treat these as severity 1 when they are contained and deliberate. The exemption ends when the code moves into a core package, stable API, shared module, or merge-ready path. Guard mode should preserve room to discover; hardening is where temporary branches converge and the normal catalog applies.
162
+
163
+ **Scoping:** for a PR/diff, scan only changed files but check duplication against the *whole* repo. For a whole repo, go module by module; propose the order and let the maintainer prune. In Guard mode, constrain edits and the post-pass to the current task's diff unless broader cleanup was requested.
164
+
165
+ ## Common mistakes (seen in the wild)
166
+
167
+ | Mistake | Reality |
168
+ |---|---|
169
+ | "This error type is clearly accidental — I'll improve it" | That's a behavior change. Callers catch specific exceptions. Report it. |
170
+ | Deleting an "unused" helper that scripts/templates/reflection use | Grep everything, including non-code files, before pattern-5 deletions. |
171
+ | One mega-commit fixing 9 patterns | Un-reviewable and un-revertable. One pattern-class per commit. |
172
+ | Fixing before running the suite once | You can't tell "I broke it" from "it was broken." Oracle first. |
173
+ | Rewriting working defensive code at a trust boundary | Untrusted input is the one place paranoia is correct. |
174
+ | Treating the catalog as a checklist to maximize | The goal is a healthier repo, not a body count. Severity 1 findings stay. |
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 awesome-skills
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,232 @@
1
+ ---
2
+ name: code-review
3
+ description: |
4
+ Provides comprehensive code review guidance for React 19, Vue 3, Angular 17+, Svelte 5,
5
+ Rust, TypeScript, Java, Java 8, PHP, Ruby, Rails, Python, Django, FastAPI, Go, C#/.NET, Kotlin, Swift,
6
+ Dart, Flutter, NestJS, C/C++, Zig, CSS/Less/Sass, Qt, and more.
7
+ Covers architecture review, performance review, security audit, code quality anti-patterns,
8
+ and common bugs across all ecosystems.
9
+ Use when: reviewing pull requests, conducting PR reviews, code review, reviewing code changes,
10
+ establishing review standards, mentoring developers, architecture reviews, security audits,
11
+ performance reviews, checking code quality, finding bugs, giving feedback on code.
12
+ allowed-tools:
13
+ - Read
14
+ - Grep
15
+ - Glob
16
+ - Bash
17
+ - WebFetch
18
+ ---
19
+
20
+ # Code Review Skill
21
+
22
+ Transform code reviews from gatekeeping to knowledge sharing through constructive feedback, systematic analysis, and collaborative improvement.
23
+
24
+ ## When to Use This Skill
25
+
26
+ - Reviewing pull requests and code changes
27
+ - Establishing code review standards for teams
28
+ - Mentoring junior developers through reviews
29
+ - Conducting architecture reviews
30
+ - Creating review checklists and guidelines
31
+ - Improving team collaboration
32
+ - Reducing code review cycle time
33
+ - Maintaining code quality standards
34
+
35
+ ## Core Principles
36
+
37
+ ### 1. The Review Mindset
38
+
39
+ **Goals of Code Review:**
40
+ - Catch bugs and edge cases
41
+ - Ensure code maintainability
42
+ - Share knowledge across team
43
+ - Enforce coding standards
44
+ - Improve design and architecture
45
+ - Build team culture
46
+
47
+ **Not the Goals:**
48
+ - Show off knowledge
49
+ - Nitpick formatting (use linters)
50
+ - Block progress unnecessarily
51
+ - Rewrite to your preference
52
+
53
+ ### 2. Effective Feedback
54
+
55
+ **Good Feedback is:**
56
+ - Specific and actionable
57
+ - Educational, not judgmental
58
+ - Focused on the code, not the person
59
+ - Balanced (praise good work too)
60
+ - Prioritized (critical vs nice-to-have)
61
+
62
+ ```markdown
63
+ ❌ Bad: "This is wrong."
64
+ ✅ Good: "This could cause a race condition when multiple users
65
+ access simultaneously. Consider using a mutex here."
66
+
67
+ ❌ Bad: "Why didn't you use X pattern?"
68
+ ✅ Good: "Have you considered the Repository pattern? It would
69
+ make this easier to test. Here's an example: [link]"
70
+
71
+ ❌ Bad: "Rename this variable."
72
+ ✅ Good: "[nit] Consider `userCount` instead of `uc` for
73
+ clarity. Not blocking if you prefer to keep it."
74
+ ```
75
+
76
+ ### 3. Review Scope
77
+
78
+ **What to Review:**
79
+ - Logic correctness and edge cases
80
+ - Security vulnerabilities
81
+ - Performance implications
82
+ - Test coverage and quality
83
+ - Error handling
84
+ - Documentation and comments
85
+ - API design and naming
86
+ - Architectural fit
87
+
88
+ **What Not to Review Manually:**
89
+ - Code formatting (use Prettier, Black, etc.)
90
+ - Import organization
91
+ - Linting violations
92
+ - Simple typos
93
+
94
+ ## Review Process
95
+
96
+ ### Phase 1: Context Gathering (2-3 minutes)
97
+
98
+ Before diving into code, understand:
99
+ 1. Read PR description and linked issue
100
+ 2. Check PR size (>400 lines? Ask to split)
101
+ 3. Review CI/CD status (tests passing?)
102
+ 4. Understand the business requirement
103
+ 5. Note any relevant architectural decisions
104
+
105
+ > For large diffs, pipe the diff through [`scripts/pr-analyzer.py`](scripts/pr-analyzer.py) (`git diff main...HEAD | python scripts/pr-analyzer.py`) to triage complexity and get a suggested review approach before reading.
106
+
107
+ ### Phase 2: High-Level Review (5-10 minutes)
108
+
109
+ 1. **Architecture & Design** - Does the solution fit the problem?
110
+ - For significant changes, consult [Architecture Review Guide](reference/architecture-review-guide.md)
111
+ - Check: SOLID principles, coupling/cohesion, anti-patterns
112
+ 2. **Performance Assessment** - Are there performance concerns?
113
+ - For performance-critical code, consult [Performance Review Guide](reference/performance-review-guide.md)
114
+ - Check: Algorithm complexity, N+1 queries, memory usage
115
+ 3. **File Organization** - Are new files in the right places?
116
+ 4. **Testing Strategy** - Are there tests covering edge cases?
117
+
118
+ ### Phase 3: Line-by-Line Review (10-20 minutes)
119
+
120
+ For each file, check:
121
+ - **Logic & Correctness** - Edge cases, off-by-one, null checks, race conditions
122
+ - **Security** - Input validation, injection risks, XSS, sensitive data
123
+ - **Performance** - N+1 queries, unnecessary loops, memory leaks
124
+ - **Maintainability** - Clear names, single responsibility, comments
125
+ - **Reuse** - Before accepting new code, search for existing utilities/helpers that could replace it. Check adjacent files and shared modules for similar patterns. See [Universal Quality Guide](reference/code-quality-universal.md) for anti-patterns like parameter sprawl, leaky abstractions, nested conditionals, stringly-typed code, TOCTOU, and no-op updates.
126
+
127
+ ### Phase 4: Summary & Decision (2-3 minutes)
128
+
129
+ 1. Summarize key concerns
130
+ 2. Highlight what you liked
131
+ 3. Make clear decision:
132
+ - ✅ Approve
133
+ - 💬 Comment (minor suggestions)
134
+ - 🔄 Request Changes (must address)
135
+ 4. Offer to pair if complex
136
+
137
+ ## Review Techniques
138
+
139
+ ### Technique 1: The Checklist Method
140
+
141
+ Use checklists for consistent reviews. See [Security Review Guide](reference/security-review-guide.md) for comprehensive security checklist.
142
+
143
+ ### Technique 2: The Question Approach
144
+
145
+ Instead of stating problems, ask questions:
146
+
147
+ ```markdown
148
+ ❌ "This will fail if the list is empty."
149
+ ✅ "What happens if `items` is an empty array?"
150
+
151
+ ❌ "You need error handling here."
152
+ ✅ "How should this behave if the API call fails?"
153
+ ```
154
+
155
+ ### Technique 3: Suggest, Don't Command
156
+
157
+ Use collaborative language:
158
+
159
+ ```markdown
160
+ ❌ "You must change this to use async/await"
161
+ ✅ "Suggestion: async/await might make this more readable. What do you think?"
162
+
163
+ ❌ "Extract this into a function"
164
+ ✅ "This logic appears in 3 places. Would it make sense to extract it?"
165
+ ```
166
+
167
+ ### Technique 4: Differentiate Severity
168
+
169
+ Use labels to indicate priority:
170
+
171
+ - 🔴 `[blocking]` - Must fix before merge
172
+ - 🟡 `[important]` - Should fix, discuss if disagree
173
+ - 🟢 `[nit]` - Nice to have, not blocking
174
+ - 💡 `[suggestion]` - Alternative approach to consider
175
+ - 📚 `[learning]` - Educational comment, no action needed
176
+ - 🎉 `[praise]` - Good work, keep it up!
177
+
178
+ **Severity levels:** 🔴 / 🟡 / 🟢 are the three severity tiers used as the standard across all guides in this skill — 🔴 blocks the merge, 🟡 should be addressed, 🟢 is optional. The remaining markers (💡 / 📚 / 🎉) are non-blocking annotations.
179
+
180
+ ## Language-Specific Guides
181
+
182
+ 根据审查的代码语言,查阅对应的详细指南:
183
+
184
+ | Language/Framework | Reference File | Key Topics |
185
+ |-------------------|----------------|------------|
186
+ | **React** | [React Guide](reference/react.md) | Hooks, useEffect, React 19 Actions, RSC, Suspense, TanStack Query v5 |
187
+ | **Vue 3** | [Vue Guide](reference/vue.md) | Composition API, 响应性系统, Props/Emits, Watchers, Composables |
188
+ | **Angular 17+** | [Angular Guide](reference/angular.md) | Signals, Standalone, RxJS, Zoneless, 模板优化, 测试, 路由守卫, HttpInterceptor |
189
+ | **Rust** | [Rust Guide](reference/rust.md) | 所有权/借用, Unsafe 审查, 异步代码, 取消安全性, 错误处理 |
190
+ | **TypeScript** | [TypeScript Guide](reference/typescript.md) | 类型安全, async/await, 不可变性, 测试, 模块解析, TS 5.x |
191
+ | **Python** | [Python Guide](reference/python.md) | 可变默认参数, 异常处理, 类属性 |
192
+ | **Django / DRF** | [Django Guide](reference/django.md) | 安全审查, N+1 查询, Serializer 反模式, ViewSet, 异步视图 |
193
+ | **FastAPI** | [FastAPI Guide](reference/fastapi.md) | Depends, Pydantic v2 validation, async correctness, sessions/N+1, auth vs authorization, test-driven verification |
194
+ | **Java** | [Java Guide](reference/java.md) | Java 17/21 新特性, Spring Boot 3, 虚拟线程, Stream/Optional |
195
+ | **Java 8 / Legacy** | [Java 8 Guide](reference/java8.md) | Java 8, Spring Boot 2, javax.*, Stream/Optional, java.time, CompletableFuture |
196
+ | **PHP** | [PHP Guide](reference/php.md) | PHP 8.x type system, PDO, security review, Composer, PHPUnit/PHPStan |
197
+ | **Ruby / Rails** | [Ruby Guide](reference/ruby.md) | Ruby semantics, Rails 8, Active Record, Active Job, security, testing |
198
+ | **C# / .NET** | [C# Guide](reference/csharp.md) | C# 12 特性, 异步编程, EF Core 性能, ASP.NET Core, LINQ |
199
+ | **Go** | [Go Guide](reference/go.md) | 错误处理, goroutine/channel, context, 接口设计 |
200
+ | **Kotlin / Android** | [Kotlin Guide](reference/kotlin.md) | 协程, Flow, Jetpack Compose, 空安全, 内存泄漏, 架构模式 |
201
+ | **Swift / SwiftUI** | [Swift Guide](reference/swift.md) | Optionals, Swift Concurrency, Sendable/actors, SwiftUI property wrappers, value vs reference types, API design |
202
+ | **Dart / Flutter** | [Dart Guide](reference/dart.md) | Widget rebuilds, const constructors, null safety, isolates, async in build, Riverpod/Bloc, platform channels, keys, disposal |
203
+ | **NestJS** | [NestJS Guide](reference/nestjs.md) | 依赖注入, 分层架构, DTO 验证, Guard/Interceptor, 循环依赖 |
204
+ | **Svelte / SvelteKit** | [Svelte Guide](reference/svelte.md) | Runes, Load 函数, Form Actions, Store 迁移, SSR/CSR 边界 |
205
+ | **C** | [C Guide](reference/c.md) | 指针/缓冲区, 内存安全, UB, 安全编码, 可移植性, 测试 |
206
+ | **C++** | [C++ Guide](reference/cpp.md) | RAII, 智能指针, C++20/23, constexpr, 测试 |
207
+ | **Zig** | [Zig Guide](reference/zig.md) | Allocators, error unions, defer/errdefer, comptime, C interop |
208
+ | **CSS/Less/Sass** | [CSS Guide](reference/css-less-sass.md) | 变量规范, !important, 性能优化, 响应式, 兼容性 |
209
+ | **Qt** | [Qt Guide](reference/qt.md) | 对象模型, 信号/槽, Model/View, QML, Qt6 迁移, 测试 |
210
+
211
+ ## Cross-Cutting Guides
212
+
213
+ Language-agnostic patterns applicable to all code reviews:
214
+
215
+ | Topic | Reference File | Key Topics |
216
+ |-------|----------------|------------|
217
+ | **Architecture Review** | [Architecture Review Guide](reference/architecture-review-guide.md) | SOLID, anti-patterns, coupling/cohesion, dependency direction |
218
+ | **Performance Review** | [Performance Review Guide](reference/performance-review-guide.md) | Web Vitals, N+1, algorithm complexity, memory leaks, caching |
219
+ | **Security Review** | [Security Review Guide](reference/security-review-guide.md) | SQLi, XSS, CSRF, SSRF, IDOR, 命令注入, 跨语言示例 |
220
+ | **Universal Quality** | [Universal Quality Guide](reference/code-quality-universal.md) | Reuse audit, parameter sprawl, leaky abstractions, nested conditionals, stringly-typed code, TOCTOU, no-op updates, redundant state |
221
+ | **Common Bugs** | [Common Bugs Checklist](reference/common-bugs-checklist.md) | Language-specific bug patterns, common pitfalls |
222
+ | **SQL Injection Prevention** | [SQL Injection Guide](reference/cross-cutting/sql-injection-prevention.md) | Parameterized queries, ORM safety, 6 languages, dynamic identifiers, detection |
223
+ | **XSS Prevention** | [XSS Prevention Guide](reference/cross-cutting/xss-prevention.md) | Output encoding, CSP, 5 frameworks, input validation vs encoding, detection |
224
+ | **N+1 Queries** | [N+1 Queries Guide](reference/cross-cutting/n-plus-one-queries.md) | Eager loading, batch fetching, DataLoader, 5 languages, detection |
225
+ | **Error Handling** | [Error Handling Guide](reference/cross-cutting/error-handling-principles.md) | Fail fast, error hierarchy, 7 languages, anti-patterns, logging |
226
+ | **Async & Concurrency** | [Concurrency Guide](reference/cross-cutting/async-concurrency-patterns.md) | Goroutines, async/await, actors, structured concurrency, 7 languages |
227
+ | **Review Best Practices** | [Code Review Best Practices](reference/code-review-best-practices.md) | Communication, reviewer mindset, giving feedback, severity labels |
228
+
229
+ ## Additional Resources
230
+
231
+ - [PR Review Template](assets/pr-review-template.md) - PR 审查评论模板
232
+ - [Review Checklist](assets/review-checklist.md) - 快速参考清单