lemmaly 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 (97) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +238 -0
  3. package/cli/gen-agents-md.js +60 -0
  4. package/cli/gen-rule-docs.js +885 -0
  5. package/cli/lemmaly.js +162 -0
  6. package/commands/benchmark.md +40 -0
  7. package/commands/budget.md +53 -0
  8. package/commands/complexity.md +26 -0
  9. package/commands/cut.md +27 -0
  10. package/commands/hotpath.md +22 -0
  11. package/commands/invariant.md +22 -0
  12. package/commands/n-plus-one.md +20 -0
  13. package/commands/profile.md +34 -0
  14. package/commands/regress.md +43 -0
  15. package/commands/scale-check.md +37 -0
  16. package/commands/ship-check.md +26 -0
  17. package/package.json +48 -0
  18. package/rules/cpp.json +46 -0
  19. package/rules/csharp.json +38 -0
  20. package/rules/go.json +46 -0
  21. package/rules/java.json +38 -0
  22. package/rules/javascript.json +102 -0
  23. package/rules/php.json +38 -0
  24. package/rules/python.json +62 -0
  25. package/rules/ruby.json +38 -0
  26. package/rules/rust.json +38 -0
  27. package/rules/shell.json +38 -0
  28. package/rules/sql.json +54 -0
  29. package/skills/complexity-cuts/SKILL.md +259 -0
  30. package/skills/invariant-guard/SKILL.md +310 -0
  31. package/skills/lemmaly/AGENTS.md +1869 -0
  32. package/skills/lemmaly/SKILL.md +365 -0
  33. package/skills/lemmaly/references/async.md +135 -0
  34. package/skills/lemmaly/references/complexity.md +66 -0
  35. package/skills/lemmaly/references/hot-paths.md +87 -0
  36. package/skills/lemmaly/references/memory.md +118 -0
  37. package/skills/lemmaly/references/n-plus-one.md +139 -0
  38. package/skills/lemmaly/rules/cpp-map-double-lookup.md +38 -0
  39. package/skills/lemmaly/rules/cpp-range-loop-copy.md +33 -0
  40. package/skills/lemmaly/rules/cpp-raw-new.md +36 -0
  41. package/skills/lemmaly/rules/cpp-string-concat-in-loop.md +45 -0
  42. package/skills/lemmaly/rules/cpp-vector-push-no-reserve.md +40 -0
  43. package/skills/lemmaly/rules/cs-async-void.md +45 -0
  44. package/skills/lemmaly/rules/cs-disposable-no-using.md +32 -0
  45. package/skills/lemmaly/rules/cs-list-contains-in-loop.md +36 -0
  46. package/skills/lemmaly/rules/cs-string-concat-in-loop.md +42 -0
  47. package/skills/lemmaly/rules/go-defer-in-loop.md +39 -0
  48. package/skills/lemmaly/rules/go-err-not-checked.md +38 -0
  49. package/skills/lemmaly/rules/go-loop-var-capture.md +47 -0
  50. package/skills/lemmaly/rules/go-slice-append-no-cap.md +39 -0
  51. package/skills/lemmaly/rules/go-string-concat-in-loop.md +44 -0
  52. package/skills/lemmaly/rules/java-arraylist-remove-in-for-i.md +44 -0
  53. package/skills/lemmaly/rules/java-bare-catch-exception.md +42 -0
  54. package/skills/lemmaly/rules/java-list-contains-in-loop.md +40 -0
  55. package/skills/lemmaly/rules/java-string-concat-in-loop.md +42 -0
  56. package/skills/lemmaly/rules/js-anonymous-handler-jsx.md +31 -0
  57. package/skills/lemmaly/rules/js-array-key-index.md +29 -0
  58. package/skills/lemmaly/rules/js-async-in-foreach.md +43 -0
  59. package/skills/lemmaly/rules/js-await-in-for-loop.md +41 -0
  60. package/skills/lemmaly/rules/js-deep-clone-via-json.md +33 -0
  61. package/skills/lemmaly/rules/js-helper-call-in-iterator.md +41 -0
  62. package/skills/lemmaly/rules/js-includes-in-iterator.md +37 -0
  63. package/skills/lemmaly/rules/js-inline-object-jsx-prop.md +35 -0
  64. package/skills/lemmaly/rules/js-nested-for-loops.md +45 -0
  65. package/skills/lemmaly/rules/js-spread-in-reduce.md +38 -0
  66. package/skills/lemmaly/rules/js-unique-via-indexof.md +35 -0
  67. package/skills/lemmaly/rules/js-useeffect-missing-deps.md +33 -0
  68. package/skills/lemmaly/rules/php-count-in-for-condition.md +45 -0
  69. package/skills/lemmaly/rules/php-in-array-in-loop.md +42 -0
  70. package/skills/lemmaly/rules/php-loose-equality.md +35 -0
  71. package/skills/lemmaly/rules/php-query-in-loop.md +47 -0
  72. package/skills/lemmaly/rules/py-bare-except.md +39 -0
  73. package/skills/lemmaly/rules/py-django-loop-without-eager.md +42 -0
  74. package/skills/lemmaly/rules/py-in-list-literal.md +37 -0
  75. package/skills/lemmaly/rules/py-mutable-default-arg.md +39 -0
  76. package/skills/lemmaly/rules/py-open-without-with.md +33 -0
  77. package/skills/lemmaly/rules/py-range-len.md +35 -0
  78. package/skills/lemmaly/rules/py-string-concat-in-loop.md +43 -0
  79. package/skills/lemmaly/rules/rb-bare-rescue.md +41 -0
  80. package/skills/lemmaly/rules/rb-include-in-iterator.md +37 -0
  81. package/skills/lemmaly/rules/rb-n-plus-one-activerecord.md +39 -0
  82. package/skills/lemmaly/rules/rb-string-concat-in-loop.md +39 -0
  83. package/skills/lemmaly/rules/rs-clone-in-loop.md +38 -0
  84. package/skills/lemmaly/rules/rs-string-push-no-capacity.md +43 -0
  85. package/skills/lemmaly/rules/rs-unwrap-in-prod.md +36 -0
  86. package/skills/lemmaly/rules/rs-vec-push-no-capacity.md +42 -0
  87. package/skills/lemmaly/rules/sh-for-ls.md +41 -0
  88. package/skills/lemmaly/rules/sh-set-e-no-pipefail.md +37 -0
  89. package/skills/lemmaly/rules/sh-unquoted-var.md +35 -0
  90. package/skills/lemmaly/rules/sh-useless-cat-pipe.md +32 -0
  91. package/skills/lemmaly/rules/sql-leading-wildcard-like.md +34 -0
  92. package/skills/lemmaly/rules/sql-not-in-subquery.md +38 -0
  93. package/skills/lemmaly/rules/sql-or-in-where.md +35 -0
  94. package/skills/lemmaly/rules/sql-select-no-limit.md +37 -0
  95. package/skills/lemmaly/rules/sql-select-star.md +29 -0
  96. package/skills/lemmaly/rules/sql-update-no-where.md +35 -0
  97. package/skills/mathguard/SKILL.md +277 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept liability
167
+ and/or offer to charge a fee for, or to provide support, warranty,
168
+ indemnity, or other liability obligations and/or rights consistent
169
+ with this License. However, in accepting such obligations, You may
170
+ act only on Your own behalf and on Your sole responsibility, not on
171
+ behalf of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Morse Chimwai
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # lemmaly
2
+
3
+ [![skills.sh](https://skills.sh/b/morsechimwai/lemmaly)](https://skills.sh/morsechimwai/lemmaly)
4
+
5
+ **A deterministic CI scanner for algorithmically lazy code, plus a codified four-skill methodology that teams can adopt as their reviewing standard.**
6
+
7
+ Every AI coding assistant writes code that works. Few write code that scales, terminates correctly on every edge case, or reaches for the right algorithm. The same handful of failures ship in nearly every AI-generated codebase: **O(n²) loops where a hash would do, N+1 queries, missed base cases, off-by-one bugs, brute force when a known algorithm exists, and "should be O(log n)" claims that were never derived.**
8
+
9
+ lemmaly ships two things:
10
+
11
+ 1. **A CLI scanner** with 59 deterministic rules across 11 languages that catches these patterns in CI without an LLM, without an API key, and without a network call. This is the validated, measurable value.
12
+ 2. **A four-skill methodology** (gateway + correctness + math + corrective) with hand-authored Incorrect/Correct examples per rule. Use it as a team standard, a reviewer checklist, or as Claude Code / Cursor skills for projects where you want explicit complexity statements in code comments.
13
+
14
+ ---
15
+
16
+ ## The suite — four skills
17
+
18
+ lemmaly is not one skill; it is a small family that covers the whole CS surface AI assistants typically skip.
19
+
20
+ | Skill | Triggers on | What it forces |
21
+ | --- | --- | --- |
22
+ | **`lemmaly`** (gateway) | any loop, collection, lookup, recursion, query | state Big-O, name the data structure, pick the algorithm family, justify repeated work |
23
+ | **`mathguard`** | large-n problems, similarity, dedupe, top-K, streaming, embeddings, signal/poly, geometry | reach for probabilistic structures (Bloom, HLL, Count-Min, MinHash/LSH), FFT/NTT, JL projection, sweep line, kd-tree — and declare ε/δ when approximate |
24
+ | **`invariant-guard`** | loops, recursion, mutating state | state loop invariants, base cases, termination measure, edge case table — before code |
25
+ | **`complexity-cuts`** | "this is slow", "times out", "OOM", existing code with bad Big-O | corrective playbook: nested loop → hash, repeated scan → index, materialize → stream, naive → memoized, brute-force → sort+sweep |
26
+
27
+ The skills compose. `lemmaly` picks the algorithm; `invariant-guard` proves it works; `mathguard` reaches further when classical hits its floor; `complexity-cuts` fixes what already shipped.
28
+
29
+ ## What it ships
30
+
31
+ - **Four Claude Code / Cursor skills** in `skills/` — drop into `~/.claude/skills/` or commit per-project under `.claude/skills/`. Each skill has frontmatter `metadata` (pathPatterns, importPatterns, chainTo) so the agent loads the right one automatically.
32
+ - **Per-rule documentation** in `skills/lemmaly/rules/<rule-id>.md` — one file per CLI rule with hand-authored Incorrect/Correct examples and an escalation path. CLI and skills share the same rule IDs.
33
+ - **Compiled rule catalog** in `skills/lemmaly/AGENTS.md` — single-document batch-load view of all 59 rules.
34
+ - **Slash commands** as the vocabulary: `/complexity`, `/hotpath`, `/n-plus-one`, `/invariant`, `/cut`, `/benchmark`, `/ship-check`, `/scale-check`.
35
+ - **Reference modules** loaded on demand — complexity tables, N+1 patterns, hot-path recognition, memory & async pitfalls. Small context cost.
36
+ - **A deterministic CLI** (`lemmaly scan`) — no API key, no LLM, no network. **59 rules across 11 languages**: JavaScript / TypeScript, Python, SQL, Java, C#, Go, Rust, C++, PHP, Ruby, Shell / Bash. Runs in CI in seconds.
37
+ - **Self-consistency tests** (`npm test`) — rule-pattern tests plus a checker that verifies CLI rules, per-rule docs, AGENTS.md, and the gateway catalog stay in sync.
38
+ - **Generators** (`npm run gen`) — regenerate per-rule docs and the compiled catalog from `rules/*.json` whenever new rules are added.
39
+ - **A GitHub Actions workflow** ready to drop into any repo — runs both the scan and the self-test, fails CI on doc/rule drift.
40
+
41
+ ## Install
42
+
43
+ ### As a Claude Code / Cursor skill suite
44
+
45
+ ```bash
46
+ # Via the skills CLI (works with Claude Code, Codex, Cursor, OpenCode, and 50+ agents)
47
+ npx skills add morsechimwai/lemmaly # project-local
48
+ npx skills add morsechimwai/lemmaly -g # global (~/.claude/skills/)
49
+ npx skills add morsechimwai/lemmaly --list # see all 4 skills first
50
+ ```
51
+
52
+ Or copy directly:
53
+
54
+ ```bash
55
+ # Personal (every project picks them up)
56
+ cp -r skills/lemmaly skills/mathguard skills/invariant-guard skills/complexity-cuts ~/.claude/skills/
57
+ cp commands/*.md ~/.claude/commands/
58
+
59
+ # Or project-local (commit it with the repo)
60
+ mkdir -p .claude/skills .claude/commands
61
+ cp -r skills/lemmaly skills/mathguard skills/invariant-guard skills/complexity-cuts .claude/skills/
62
+ cp commands/*.md .claude/commands/
63
+ ```
64
+
65
+ ### Hermes Agent (Nous Research)
66
+
67
+ Hermes uses the `SKILL.md` standard from [agentskills.io](https://agentskills.io). The `npx skills` CLI ships an `hermes-agent` target — verified in `skills` v0.x against `~/.hermes/skills/`.
68
+
69
+ ```bash
70
+ # Project-scoped — drops the four skills into ./.hermes/skills/
71
+ npx skills add morsechimwai/lemmaly --agent hermes-agent \
72
+ --skill lemmaly mathguard invariant-guard complexity-cuts -y --copy
73
+
74
+ # User-global — drops them into ~/.hermes/skills/
75
+ npx skills add morsechimwai/lemmaly --agent hermes-agent -g \
76
+ --skill lemmaly mathguard invariant-guard complexity-cuts -y --copy
77
+ ```
78
+
79
+ Manual equivalent (if you don't want the CLI):
80
+
81
+ ```bash
82
+ mkdir -p ~/.hermes/skills
83
+ cp -r skills/lemmaly skills/mathguard skills/invariant-guard skills/complexity-cuts ~/.hermes/skills/
84
+ ```
85
+
86
+ ### OpenClaw
87
+
88
+ OpenClaw also reads `SKILL.md` (see [docs.openclaw.ai/clawhub/skill-format](https://docs.openclaw.ai/clawhub/skill-format)). The `npx skills` CLI ships an `openclaw` target — verified to write to `./skills/` (project) and `~/.openclaw/skills/` (global).
89
+
90
+ ```bash
91
+ # Project-scoped — drops the four skills into ./skills/
92
+ npx skills add morsechimwai/lemmaly --agent openclaw \
93
+ --skill lemmaly mathguard invariant-guard complexity-cuts -y --copy
94
+
95
+ # User-global — drops them into ~/.openclaw/skills/
96
+ npx skills add morsechimwai/lemmaly --agent openclaw -g \
97
+ --skill lemmaly mathguard invariant-guard complexity-cuts -y --copy
98
+ ```
99
+
100
+ Manual equivalent:
101
+
102
+ ```bash
103
+ mkdir -p ~/.openclaw/skills
104
+ cp -r skills/lemmaly skills/mathguard skills/invariant-guard skills/complexity-cuts ~/.openclaw/skills/
105
+ ```
106
+
107
+ The four skills declare no `requires.env` or external `bins`, so OpenClaw's security scan passes them as-is — no extra `metadata.openclaw` block needed. The CLI scanner is optional; install it separately if you want CI gating (see below).
108
+
109
+ > Targeting both at once: `--agent hermes-agent openclaw` is a single install. List every supported client with `npx skills add <repo> -l`.
110
+
111
+ ### As a CLI scanner
112
+
113
+ ```bash
114
+ # From this repo
115
+ node cli/lemmaly.js scan ./src
116
+
117
+ # Or globally (once published)
118
+ npm i -g lemmaly
119
+ lemmaly scan ./src
120
+ ```
121
+
122
+ ## Try it
123
+
124
+ ```bash
125
+ node cli/lemmaly.js scan examples/before-after/bad.jsx
126
+ ```
127
+
128
+ You should see **2 errors, 5 warnings, 3 info** across 9 distinct rule IDs — every numbered anti-pattern in the demo file flagged with a specific fix. Compare against `examples/before-after/good.jsx`.
129
+
130
+ ## How to use it with an AI agent
131
+
132
+ Once the skills are installed (see above), invoke them by name from Claude Code, Cursor, or any agent that loads `.claude/skills/`. The skill descriptions, `pathPatterns`, and `importPatterns` also let it auto-trigger when you touch loops, queries, or collections — but explicit prompts are the most reliable.
133
+
134
+ | When | Paste this prompt |
135
+ | --- | --- |
136
+ | **First look** — no specific concern, just point it at the code | `Use the lemmaly skill to check src/ for algorithmic risks. State the Big-O of any function over a collection, and call out N+1 queries, repeated scans, and brute-force loops with a named fix.` |
137
+ | **Before writing** a new function | `Use the lemmaly skill: run /complexity on findDuplicates(items: T[]). State Big-O, the data structure choice, and the loop invariant in comments before writing the body.` |
138
+ | **After AI writes** an endpoint that feels slow | `Use the lemmaly skill: run /n-plus-one on src/orders/list.ts. If it finds a repeated query inside a loop, follow up with /cut and rewrite using a single batched IN query.` |
139
+ | **Pre-merge gate** on a diff | `Use the lemmaly skill: run /ship-check on the current diff. Block merge if any new function is O(n²) without a comment justifying it, and flag any recursion without a stated base case.` |
140
+ | **Will it hold at 10×?** | `Use the lemmaly skill: run /scale-check on this dedupe at 10× and 100× today's 50k rows. Name the cliff and the next structure (HLL, MinHash, sweep line) when classical breaks.` |
141
+
142
+ The slash commands (`/complexity`, `/n-plus-one`, `/ship-check`, `/scale-check`, `/hotpath`, `/invariant`, `/cut`, `/benchmark`) are the vocabulary — full list and demos at [lemmaly.dev](https://lemmaly.dev/#prompts).
143
+
144
+ ## What we tested, honestly
145
+
146
+ We ran a live behavioral test: 8 prompts (2 per skill) sent twice to Claude Haiku 4.5 — once with the lemmaly skills installed in `.claude/skills/`, once without. We then scored each response for skill-aligned markers (Big-O claims, named data structures, invariants, ε-bounds for approximate algorithms). [Reproducer here.](./tests/skill-triggering/live.js)
147
+
148
+ **Result on Haiku 4.5: 7 ties, 1 cosmetic regression, 0 strong uplift, $0.40 total spend.**
149
+
150
+ That finding matters. It means:
151
+
152
+ - **Frontier 2026 models (Haiku 4.5 / Sonnet 4.6 / Opus 4.7) already produce skill-aligned code on these prompts by default.** They reach for Set, write `O(1) lookup` in the explanation, and recommend HyperLogLog for cardinality-at-scale — without lemmaly installed.
153
+ - **The skills are not making competent models smarter.** They are codifying the discipline you would want a junior engineer or a less-capable model to follow.
154
+
155
+ Where lemmaly's value is empirically validated:
156
+
157
+ | Layer | Value | Evidence |
158
+ |---|---|---|
159
+ | **CLI scanner** | Catches the named anti-patterns deterministically in CI | 59/59 rule-pattern tests pass; sanity scan flags 21 findings across 8 sample files in 8 languages |
160
+ | **Per-rule docs + AGENTS.md** | Single source of truth for both human reviewers and AI agents | Consistency test verifies CLI ↔ MDs ↔ AGENTS.md ↔ gateway stay in sync |
161
+ | **Skill methodology** | Iron Laws, verification checklists, canonical Good/Bad pairs, escalation paths | Documents a complete reviewing standard a team can adopt |
162
+ | **Behavioral uplift on Haiku 4.5+** | **Not measurably present.** Skills duplicate what the model already knows | Live test: 0/8 strong wins |
163
+
164
+ Where we expect skills to actually move behavior (untested, but plausible): smaller / older models, code-review settings where the Iron Laws force explicit derivations in comments, and contexts where the CLI scanner output is fed back to the model.
165
+
166
+ ## The honest pitch
167
+
168
+ > **For competent models you barely need the skills. For CI gates and team standards, you need the rules.**
169
+
170
+ Install the CLI. Drop the GitHub Actions workflow into your repo. Read the four `SKILL.md` files as a reviewing checklist. Install the skills into Claude Code / Cursor if you want every AI-generated commit to carry an explicit complexity comment — that part is discipline, not knowledge.
171
+
172
+ ## The rules
173
+
174
+ **59 deterministic rules across 11 languages** — JavaScript / TypeScript, Python, SQL, Java, C#, Go, Rust, C++, PHP, Ruby, Shell / Bash. Run `lemmaly rules` to see the full list, or read `skills/lemmaly/AGENTS.md` for every rule with its Incorrect / Correct example.
175
+
176
+ | Severity | Rule | Why it matters |
177
+ | --- | --- | --- |
178
+ | error | `js-await-in-for-loop` | N+1 over network |
179
+ | error | `js-async-in-foreach` | dropped promises |
180
+ | error | `py-mutable-default-arg` | shared default state |
181
+ | error | `sql-update-no-where` | touches every row |
182
+ | error | `java-arraylist-remove-in-for-i` | index shifts; CMException risk |
183
+ | error | `cs-async-void` | unobserved exceptions crash the process |
184
+ | error | `go-loop-var-capture` | pre-1.22 race on the last value |
185
+ | error | `php-query-in-loop` | N+1 against the database |
186
+ | warning | `js-helper-call-in-iterator` | N round-trips inside a loop |
187
+ | warning | `js-deep-clone-via-json` | `JSON.parse(JSON.stringify(x))` |
188
+ | warning | `sql-select-star` | blocks index-only scans |
189
+ | warning | `java-string-concat-in-loop` | use `StringBuilder` |
190
+ | warning | `cs-disposable-no-using` | leak on exception |
191
+ | warning | `go-defer-in-loop` | defers accumulate to function exit |
192
+ | warning | `rs-unwrap-in-prod` | panics on `None`/`Err` |
193
+ | warning | `cpp-raw-new` | manual delete; exception-unsafe |
194
+ | warning | `rb-bare-rescue` | catches `StandardError`; hides bugs |
195
+ | warning | `sh-set-e-no-pipefail` | pipe failures masked |
196
+ | warning | `sh-unquoted-var` | word-splitting / glob expansion |
197
+ | info | `js-nested-for-loops` | O(n×m) — hash one side |
198
+ | info | `cpp-range-loop-copy` | use `const auto&` |
199
+ | info | `php-loose-equality` | use `===` |
200
+ | info | `sh-useless-cat-pipe` | pass file directly |
201
+ | … 35 more across 11 languages | (see `lemmaly rules` or `skills/lemmaly/AGENTS.md`) | |
202
+
203
+ ## CI integration
204
+
205
+ ```yaml
206
+ # .github/workflows/lemmaly.yml
207
+ - run: npm i -g lemmaly
208
+ - run: lemmaly scan .
209
+ ```
210
+
211
+ Exit code `1` on any `error`-severity finding. Warnings and info do not fail the build.
212
+
213
+ ## Status
214
+
215
+ **v0.2 — multi-language CI scanner + codified methodology.**
216
+
217
+ - ✅ 59 rules across 11 languages, all with positive + negative test cases.
218
+ - ✅ Per-rule documentation aligned with CLI rule IDs.
219
+ - ✅ Self-consistency tests prevent rule / doc / catalog drift.
220
+ - ✅ GitHub Actions workflow: scan + self-test + regenerate-and-diff.
221
+ - ✅ Static skill-triggering test (42 prompts) confirms prompt vocabulary matches skill descriptions.
222
+ - ✅ Live behavioral test scaffolding (`tests/skill-triggering/live.js`) and findings (above).
223
+
224
+ The case study in `case-studies/` describes a measured 22.8× speedup on a real production app — predating this release's multi-language and live-test work.
225
+
226
+ ## Roadmap
227
+
228
+ - v0.2 — multi-language CI scanner + codified methodology + honest live-test findings. **You are here.**
229
+ - v0.3 — framework rule packs (Next.js, FastAPI, Rails) and broader sampling of the live behavioral test against weaker / older models where we expect the skills to actually move behavior.
230
+ - v0.4 — VS Code extension that surfaces CLI findings inline; CLI emits invariant-stub comments for `invariant-guard`.
231
+
232
+ ## Contributing
233
+
234
+ See [CONTRIBUTING.md](./CONTRIBUTING.md). Especially welcome: new rule proposals with both a positive and a negative test case, and new playbook entries for `complexity-cuts` and `mathguard` with derivations.
235
+
236
+ ## License
237
+
238
+ [Apache 2.0](./LICENSE). Use it commercially, modify it, fork it. If you are an enterprise looking for custom rule packs or codebase-specific tuning, reach out — that is the support model.
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ // Generates skills/lemmaly/AGENTS.md — full compiled rule catalog for batch loading.
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const ROOT = path.resolve(__dirname, '..');
7
+ const RULES_DIR = path.join(ROOT, 'skills', 'lemmaly', 'rules');
8
+ const OUT = path.join(ROOT, 'skills', 'lemmaly', 'AGENTS.md');
9
+
10
+ const SEV_ORDER = { error: 0, warning: 1, info: 2 };
11
+ const SEV_HEADER = {
12
+ error: '## CRITICAL — will break or scale-fail in production',
13
+ warning: '## HIGH — hot-path or correctness risk at realistic n',
14
+ info: '## MEDIUM — suboptimal; flag when n is large or hot path',
15
+ };
16
+
17
+ const files = fs
18
+ .readdirSync(RULES_DIR)
19
+ .filter((f) => f.endsWith('.md'))
20
+ .map((f) => {
21
+ const raw = fs.readFileSync(path.join(RULES_DIR, f), 'utf8');
22
+ const m = raw.match(/^---\n([\s\S]+?)\n---\n([\s\S]*)$/);
23
+ if (!m) throw new Error('No frontmatter: ' + f);
24
+ const fm = {};
25
+ for (const line of m[1].split('\n')) {
26
+ const i = line.indexOf(':');
27
+ if (i < 0) continue;
28
+ const k = line.slice(0, i).trim();
29
+ const v = line.slice(i + 1).trim();
30
+ if (k) fm[k] = v;
31
+ }
32
+ return { fm, body: m[2].trimStart() };
33
+ });
34
+
35
+ files.sort((a, b) => {
36
+ const s = SEV_ORDER[a.fm.severity] - SEV_ORDER[b.fm.severity];
37
+ if (s !== 0) return s;
38
+ return a.fm.id.localeCompare(b.fm.id);
39
+ });
40
+
41
+ const parts = [
42
+ '# Lemmaly Rule Catalog (compiled)',
43
+ '',
44
+ 'Full compiled view of every CLI rule with hand-authored Incorrect/Correct examples and escalation path. Generated from `rules/*.json` and `skills/lemmaly/rules/*.md`.',
45
+ '',
46
+ 'For per-rule documents, load `skills/lemmaly/rules/<rule-id>.md`. For the deterministic CLI, run `node cli/lemmaly.js scan <path>`.',
47
+ '',
48
+ ];
49
+
50
+ let currentSev = null;
51
+ for (const { fm, body } of files) {
52
+ if (fm.severity !== currentSev) {
53
+ currentSev = fm.severity;
54
+ parts.push('', SEV_HEADER[currentSev], '');
55
+ }
56
+ parts.push(`### \`${fm.id}\` — ${fm.language}`, '', body.trim(), '');
57
+ }
58
+
59
+ fs.writeFileSync(OUT, parts.join('\n'));
60
+ console.log('Wrote', OUT, '(' + files.length + ' rules)');