rust-intel-cc 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +887 -0
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +211 -0
- package/bin/install.js +119 -0
- package/commands/rust-intel-cc/audit.md +112 -0
- package/commands/rust-intel-cc/fix.md +137 -0
- package/commands/rust-intel-cc/plan.md +74 -0
- package/package.json +37 -0
- package/skill/SKILL.md +454 -0
- package/skill/async.md +329 -0
- package/skill/audit-project.workflow.js +283 -0
- package/skill/concurrency-and-state.md +186 -0
- package/skill/data-and-types.md +212 -0
- package/skill/deps-macros-ergonomics.md +127 -0
- package/skill/drop-and-raii.md +48 -0
- package/skill/lifetimes-and-api.md +111 -0
- package/skill/security.md +82 -0
- package/skill/semantics-and-conformance.md +127 -0
- package/skill/testing.md +112 -0
- package/skill/unsafe-and-ffi.md +106 -0
package/LICENSE-APACHE
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 reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and 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 choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
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 rust-intel contributors
|
|
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/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 phpcraftdream@gmail.com and contributors
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
בס״ד
|
|
2
|
+
|
|
3
|
+
לכבוד הקדוש ברוך הוא — *for the glory of the Holy One, blessed be He*
|
|
4
|
+
|
|
5
|
+
# rust-intel
|
|
6
|
+
|
|
7
|
+
A living specification that defends against the systematic mistakes LLMs make when writing Rust.
|
|
8
|
+
|
|
9
|
+
## What this is
|
|
10
|
+
|
|
11
|
+
An empirically-grounded ruleset for the Rust mistakes that **survive `cargo build` and `cargo test`** but still wreck things in production or rot the codebase over time. Every category is backed by a specific study, production incident, or systematically observed LLM output pattern — see [`docs/sources.md`](docs/sources.md).
|
|
12
|
+
|
|
13
|
+
> **Per-rule grounding ≠ measured coverage.** Each category is grounded individually (above), but there is no regression corpus yet that measures *what fraction* of real silent-failure bugs the spec catches. Building that corpus — `examples/` with deliberately broken Rust per category, exercised through `/rust-cc-audit` — is the next infrastructure step, tracked in [`docs/roadmap.md`](docs/roadmap.md) §4. Completeness, until then, is author-asserted.
|
|
14
|
+
|
|
15
|
+
The premise: Rust's compiler catches a large class of LLM mistakes (a known empirical finding is that **76.3% of all compilation failures from LLM agents** fall into just two categories — project organization and type/trait semantics, per Rust-SWE-Bench). Categories where the failure mode is a compile error are *deliberately omitted* from this spec — the compiler is sufficient. What this spec covers is what's left after `rustc`, `clippy`, and `cargo test` have all said "fine":
|
|
16
|
+
|
|
17
|
+
- **Silent correctness bugs** — `HashMap` corruption from inconsistent `Hash`/`Eq`, `tokio::sync::Mutex` held across `.await`, lost `JoinHandle`s, `RefCell` runtime panics under contention.
|
|
18
|
+
- **Design hazards** — `Deref` used for inheritance, manual `unsafe impl Send` without invariant, reflexive `Arc<Mutex<HashMap>>` where a single owner exists.
|
|
19
|
+
- **Runtime data corruption** — `serde` "absent" vs "null" conflation, `#[serde(untagged)]` overlap, `select!`-cancelled side effects.
|
|
20
|
+
- **Performance and resource leaks** — async `Drop` that doesn't drop, blocking calls on async runtime, unbounded channels.
|
|
21
|
+
- **Cryptographic and security pitfalls** — non-constant-time comparison, `OsRng` skipped for `thread_rng`, nonce reuse.
|
|
22
|
+
|
|
23
|
+
The exact category count is given in the spec itself; the count is allowed to evolve.
|
|
24
|
+
|
|
25
|
+
## Status
|
|
26
|
+
|
|
27
|
+
**v0.4.5 — substitution catalog + plugin/npm distribution (2026-06-17).** A Tier E appendix in `data-and-types.md`: a pattern → cheaper-representation lookup table (~22 rows, 4 groups — ownership/allocation, lookup/complexity, the hasher ladder, concurrent maps by access shape), every row gated by §E6 measure-first; no new categories (still **58**). Plus two clone-free install paths: the repo is now a Claude Code **plugin + marketplace** (`/plugin marketplace add PHPCraftdream/rust-intel`) and an **npm package** (`npx rust-intel-cc`), published by CI on every release tag. See [`CHANGELOG.md`](CHANGELOG.md).
|
|
28
|
+
|
|
29
|
+
**v0.4.4 — §D1a gains the façade fitted to the test (2026-06-15).** One bullet, no new categories (still **58**). A fourth shape under §D1a oracle validity: where the *circular oracle* writes the test from the code, the *façade fitted to the test* writes the code from the test — given the goal "make this test pass," an agent emits the declaration the test probes (a config key, header, status string) without the behavior behind it; tests are green, the feature is absent. Grounded in Chacon 2026, "Grit" (Rust-Git reimplementation, 360k LOC, 99.3% tests green, "not *tested*"). See [`CHANGELOG.md`](CHANGELOG.md).
|
|
30
|
+
|
|
31
|
+
**v0.4.3 — siblings of safe-looking primitives (2026-06-15).** Three bullets, no new categories (still **58**): §C2 path-traversal recipe gains a TOCTOU caveat (`canonicalize` + `starts_with` defeats the static symlink, not a racing one — CWE-367; use `openat`+`O_NOFOLLOW` / `cap-std` when the tree is attacker-mutable); §B9 gains `std::thread::scope` as the sync mirror of §B21 (auto-join on the closing brace can deadlock; child panic re-panics the parent); §B16 gains a ReDoS sibling-of-HashDoS bullet (`regex` is linear by construction; `fancy-regex`/`onig`/`pcre2` reintroduce catastrophic backtracking — CWE-1333). Plus a README recall-honesty note (per-rule grounding ≠ measured coverage). See [`CHANGELOG.md`](CHANGELOG.md).
|
|
32
|
+
|
|
33
|
+
**v0.4.2 — concurrency/hang/flaky-test patterns (2026-06-14).** Two new numbered categories + a lettered sub-section + three extensions, extracted from real fixes: §B3a (coordinator-loop livelock — release leadership and exit on persistent error), §D4 (filtered test-runner output hides hangs — `pipefail` + nextest SLOW/TIMEOUT), §D5 (Windows LNK1104 from zombie test process, defense-in-depth on top of §D4). Extensions: §B2 (DashMap `Ref` across `.await` is an invisible shard lock), §B21 (periodic task must hold `Weak`, not `Arc`), §D1 (`interval` + `start_paused` tick discipline). **56 → 58 categories.** See [`CHANGELOG.md`](CHANGELOG.md).
|
|
34
|
+
|
|
35
|
+
**v0.4.1 — Tier F semantic conformance (2026-06-10).** Added Tier F (§F1–§F4): defects of *meaning* — code that compiles, passes tests, implements the wrong thing. Plus §D1a (oracle validity) and §D3 (test/prod divergence). **51 → 56 categories, 5 → 6 tiers (A–F).** See [`CHANGELOG.md`](CHANGELOG.md).
|
|
36
|
+
|
|
37
|
+
**v0.4.0 — fan-out audit workflow (2026-06-10).** Shipped `audit-project.workflow.js` — one agent per module, async split into two, runtime slicing of trigger tables (zero duplication), structured findings schema, synthesized `/rust-cc-audit` report. Module headers enriched with tier badges + audit semantics. `audit.md` gains fan-out-preferred note. Installers deliver the workflow. See [`CHANGELOG.md`](CHANGELOG.md).
|
|
38
|
+
|
|
39
|
+
**v0.3.3 — accuracy pass (2026-06-10).** Factual/dating fixes (F1–F4): `clippy::await_holding_lock` group history corrected, MSRV 1.84→1.85, §C7 resolver v1/v2 qualification, `never_type_fallback` dating 1.92→1.85. Three minor clarifications (§B2, §B9, §B12, §B15a). No category changes (still **51**). See [`CHANGELOG.md`](CHANGELOG.md).
|
|
40
|
+
|
|
41
|
+
**v0.3.2 — four content additions (2026-06-09).** From a study of Microsoft's *Rust Patterns & Engineering How-Tos*: §C1a (`#[non_exhaustive]` producer-side semver rule, 🟡), §B18a (variance/`PhantomData` soundness in raw-pointer wrappers, 🔴), expanded §B4 (memory-vs-resource `Drop` at exit, recursive `Drop` stack overflow, drop-order shutdown deadlock), and §B5 (unsafe→safe boundary principle: value-invariant guards vs relational invariants). Still **51** categories (sub-sections counted under parent). See [`CHANGELOG.md`](CHANGELOG.md).
|
|
42
|
+
|
|
43
|
+
**v0.3.1 — structural repackaging (2026-05-31).** The single-file spec is now a **modular skill**: `SKILL.md` (core — protocols, enforcement tiers, the trigger table, and a category→module map) plus nine theme modules under `skill/` holding the category bodies. No rule or category changes (still **51**) — content is byte-complete vs 0.3.0. `SKILL.md` also tells the agent to run a full audit/review by **fanning out one sub-agent per module** (via a workflow) instead of holding all categories in one context. Installers ship the modules; the single-file reference is retired (kept in git history). See [`CHANGELOG.md`](CHANGELOG.md).
|
|
44
|
+
|
|
45
|
+
**v0.3.0 — content release (2026-05-29).** The first tagged release since 0.2.2 — it collapses all interim work (drafted under provisional 0.3.x / 0.4.0 labels, never tagged) into one version. The spec was reframed to cover only bugs that compile and pass tests but still break, then grown from **26 to 51 categories** across **five tiers (A–E)**: silent correctness bugs (async cancellation, `Mutex`-across-`.await`, UB, TOCTOU, crypto, FFI, lossy numeric/`as`-casts, wall-clock vs monotonic, UTF-8 boundaries, iterator/slice adapter traps), architecture/ergonomics, testing/CI gaps, and a top-level **Tier E — Systemic cost** (latency, allocation, complexity, contention; enforced 🟡/🟢, never 🔴). Includes an external multi-agent review pass — evidence-base accuracy fixes, build-time supply-chain coverage (§A1), and anti-dogmatism calibration. Slash commands unchanged. See [`CHANGELOG.md`](CHANGELOG.md) for full notes.
|
|
46
|
+
|
|
47
|
+
## Layout
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
rust-intel/
|
|
51
|
+
├── .claude-plugin/ # Claude Code plugin + marketplace manifests
|
|
52
|
+
│ ├── plugin.json # Plugin manifest (skills/commands paths, version)
|
|
53
|
+
│ └── marketplace.json # This repo is its own marketplace (/plugin marketplace add PHPCraftdream/rust-intel)
|
|
54
|
+
├── skill/ # The skill (this is what installs) — modular
|
|
55
|
+
│ ├── SKILL.md # Core: protocols, enforcement tiers, trigger table, category→module map
|
|
56
|
+
│ ├── <theme>.md # Theme modules (async, unsafe-and-ffi, security, … — the category bodies)
|
|
57
|
+
│ └── audit-project.workflow.js # Fan-out project audit (one agent per module)
|
|
58
|
+
├── bin/install.js # npx installer (npm package: rust-intel-cc)
|
|
59
|
+
├── package.json # npm package manifest (published on release tags by CI)
|
|
60
|
+
├── .github/workflows/npm-publish.yml # Publishes rust-intel-cc to npm on every v* tag
|
|
61
|
+
├── README.md # This file
|
|
62
|
+
├── CHANGELOG.md # Version history
|
|
63
|
+
├── .gitattributes # Line-ending rules (LF for source, CRLF for .ps1/.bat)
|
|
64
|
+
├── .gitignore # Ignores /.claude/ (project-local install target) and target/
|
|
65
|
+
├── rust-cc-install.sh / rust-cc-install.ps1 / rust-cc-install.bat # One-command install (project-local by default; --user for global)
|
|
66
|
+
├── rust-cc-uninstall.sh / rust-cc-uninstall.ps1 / rust-cc-uninstall.bat # Inverse of install
|
|
67
|
+
├── commands/
|
|
68
|
+
│ ├── README.md
|
|
69
|
+
│ └── rust-intel-cc/ # Repo umbrella dir (installer flattens to /rust-cc-* commands)
|
|
70
|
+
│ ├── audit.md # /rust-cc-audit — scan existing code
|
|
71
|
+
│ ├── fix.md # /rust-cc-fix — diagnose an error
|
|
72
|
+
│ └── plan.md # /rust-cc-plan — pre-flight a new task
|
|
73
|
+
└── docs/
|
|
74
|
+
├── roadmap.md # Roadmap: open directions and structural notes
|
|
75
|
+
└── sources.md # Empirical sources and citations
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## How to use it
|
|
79
|
+
|
|
80
|
+
### Install — three ways
|
|
81
|
+
|
|
82
|
+
#### 1. Claude Code plugin (recommended — one command, auto-updates)
|
|
83
|
+
|
|
84
|
+
Inside any Claude Code session:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
/plugin marketplace add PHPCraftdream/rust-intel
|
|
88
|
+
/plugin install rust-intel@rust-intel
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
That's it — no clone, cross-platform, and updates arrive via `/plugin` (or `claude plugin update rust-intel`). The plugin ships the skill (auto-activates on Rust tasks) plus the commands under the plugin namespace: `/rust-intel:audit`, `/rust-intel:fix`, `/rust-intel:plan`.
|
|
92
|
+
|
|
93
|
+
#### 2. npx (no clone, flat `/rust-cc-*` command names)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx rust-intel-cc # project-local: ./.claude/
|
|
97
|
+
npx rust-intel-cc --user # user-global: ~/.claude/
|
|
98
|
+
npx rust-intel-cc --uninstall # inverse (add --user for global)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Same layout as the shell installers below: skill in `<target>/skills/rust-intel/`, commands flattened to `/rust-cc-audit`, `/rust-cc-fix`, `/rust-cc-plan`. Published to npm automatically on every release tag.
|
|
102
|
+
|
|
103
|
+
#### 3. Shell installers (from a clone; `--symlink` for development)
|
|
104
|
+
|
|
105
|
+
**Default is project-local** — files land in `./.claude/` of whatever directory you ran the installer from. Pass `--user` (or `-User` on PowerShell) to install to the user-global `~/.claude/` instead.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# macOS / Linux
|
|
109
|
+
./rust-cc-install.sh # project-local: $PWD/.claude/
|
|
110
|
+
./rust-cc-install.sh --user # user-global: $HOME/.claude/
|
|
111
|
+
./rust-cc-install.sh --symlink # symlink instead of copy (tracks repo updates)
|
|
112
|
+
|
|
113
|
+
# Windows (PowerShell)
|
|
114
|
+
.\rust-cc-install.ps1 # project-local
|
|
115
|
+
.\rust-cc-install.ps1 -User # user-global
|
|
116
|
+
|
|
117
|
+
# Windows (cmd.exe)
|
|
118
|
+
rust-cc-install.bat # project-local
|
|
119
|
+
rust-cc-install.bat -User # user-global
|
|
120
|
+
|
|
121
|
+
# Note: --symlink is bash-only. PowerShell and cmd.exe installers always copy.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`CLAUDE_CONFIG_DIR` env var overrides the target for the npx and shell installers if set.
|
|
125
|
+
|
|
126
|
+
The installer copies:
|
|
127
|
+
- `skill/*.md` → `<target>/skills/rust-intel/` (the modular skill — `SKILL.md` core plus theme modules; Claude Code activates it automatically on Rust tasks)
|
|
128
|
+
- `commands/rust-intel-cc/{audit,fix,plan}.md` → `<target>/commands/rust-cc-{audit,fix,plan}.md` (the three slash commands; installer flattens with a `rust-cc-` prefix on copy)
|
|
129
|
+
|
|
130
|
+
It also sweeps any prior install at the same target — including the legacy v0.1.x flat layout (`commands/rust-audit.md`, `commands/rust-fix.md`, `commands/rust-plan.md`, and the very early `commands/rust-intel.md`) — so re-running it cleanly migrates from any older version.
|
|
131
|
+
|
|
132
|
+
### Uninstall
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# macOS / Linux
|
|
136
|
+
./rust-cc-uninstall.sh # project-local
|
|
137
|
+
./rust-cc-uninstall.sh --user # user-global
|
|
138
|
+
|
|
139
|
+
# Windows (PowerShell)
|
|
140
|
+
.\rust-cc-uninstall.ps1
|
|
141
|
+
.\rust-cc-uninstall.ps1 -User
|
|
142
|
+
|
|
143
|
+
# Windows (cmd.exe)
|
|
144
|
+
rust-cc-uninstall.bat
|
|
145
|
+
rust-cc-uninstall.bat -User
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Only touches the paths the installer creates. Other skills and commands under the target `.claude/` are not touched.
|
|
149
|
+
|
|
150
|
+
### Verify
|
|
151
|
+
|
|
152
|
+
Start `claude` inside the directory you installed to (or anywhere if you used `--user`), ask for any Rust task, and the assistant should reference rules from §A1–§F4 unprompted. Try:
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
/rust-cc-audit src/
|
|
156
|
+
/rust-cc-fix E0277: the trait bound `T: Send` is not satisfied
|
|
157
|
+
/rust-cc-plan write a tokio task that consumes a sqlx stream and pushes to a websocket
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### As a checklist for humans
|
|
161
|
+
|
|
162
|
+
The document reads top-to-bottom. The minimum bar before committing any non-trivial Rust: walk the **Pre-flight checklist** (7 questions at the end of the spec) and the **Post-flight checklist** (the list of things to surface in a summary).
|
|
163
|
+
|
|
164
|
+
### Commands
|
|
165
|
+
|
|
166
|
+
Three commands live under [`commands/rust-intel-cc/`](commands/rust-intel-cc/) and share a single source of truth — the skill itself, never a copy:
|
|
167
|
+
|
|
168
|
+
| Command | Trigger | Use case |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| [`audit`](commands/rust-intel-cc/audit.md) | `/rust-cc-audit [path]` | Scan existing Rust against all categories from the spec, return a triaged report with concrete fixes. |
|
|
171
|
+
| [`fix`](commands/rust-intel-cc/fix.md) | `/rust-cc-fix <error>` | Map a compiler / clippy / panic / runtime symptom onto a category, propose a root-cause fix. |
|
|
172
|
+
| [`plan`](commands/rust-intel-cc/plan.md) | `/rust-cc-plan <task>` | Run a task description through the trigger table and Pre-flight checklist before any code is written. |
|
|
173
|
+
|
|
174
|
+
Details: [`commands/README.md`](commands/README.md).
|
|
175
|
+
|
|
176
|
+
## Spec architecture
|
|
177
|
+
|
|
178
|
+
Six tiers plus a meta-layer:
|
|
179
|
+
|
|
180
|
+
| Tier | Coverage | Categories |
|
|
181
|
+
|---|---|---|
|
|
182
|
+
| Self-monitoring | Prompt-trigger table (phrase- *and* code-pattern-based) → activates relevant categories | top of spec |
|
|
183
|
+
| **Tier A** | Compile-fix reflexes that leave silent residue — the LLM "fixes" the red squiggle in a way that compiles while leaving a real defect behind | §A1–§A3 |
|
|
184
|
+
| **Tier B** | Silent correctness bugs, caught only in production | §B1–§B29 |
|
|
185
|
+
| **Tier C** | Architecture and ergonomics, expensive to undo | §C1–§C11 |
|
|
186
|
+
| **Tier D** | Testing and CI gaps — tests pass not because the code is correct but because the tests are blind | §D1–§D5 |
|
|
187
|
+
| **Tier E** | Systemic cost (performance / scale / contention) — correct in the small, wrong at scale — cost that survives correctness; enforced 🟡/🟢, never 🔴 | §E1–§E6 |
|
|
188
|
+
| **Tier F** | Semantic conformance — defects of *meaning*: spec/reference divergence, violated documented guarantees, boundary/error-path resource lifecycle, missing round-trip obligations. Found by reading the *claim*, not by pattern-matching | §F1–§F4 |
|
|
189
|
+
|
|
190
|
+
The A/B/C/D/F tiers classify *what kind* of bug a category targets. Orthogonally, the spec's **Enforcement tiers** (🔴 surface-always / may block · 🟡 apply silently while writing · 🟢 delegate to clippy) say *how strictly* to act on each — so a post-flight summary stays short and every line is worth acting on, instead of flagging every cast and clone. See the "Enforcement tiers" section in the spec.
|
|
191
|
+
|
|
192
|
+
A Tier A category for trait bounds / type mismatches (E0277/E0308) was present in earlier drafts and retired in v0.3.0: compile-only failures are out of scope, the compiler is sufficient. The remaining Tier A categories were renumbered to close the gap.
|
|
193
|
+
|
|
194
|
+
Tier B is the centre of the spec: silent correctness bugs that survive `rustc`, `clippy`, and `cargo test`. Each category cites a published study, production incident, or systematically observed LLM output pattern.
|
|
195
|
+
|
|
196
|
+
## Principles for evolving the spec
|
|
197
|
+
|
|
198
|
+
1. **Every category must be grounded.** No rule lands without one of (a) a published study with numbers, (b) a documented production incident, or (c) a systematically observed LLM output pattern.
|
|
199
|
+
2. **The spec defends against LLMs, not humans.** Categories where LLMs don't err more often than humans don't belong here — that's just Rust style.
|
|
200
|
+
3. **Proof before rule.** If a category lacks a sharp BANNED/REQUIRED formulation, it stays in the roadmap, not the main spec.
|
|
201
|
+
4. **Sources are transparent.** Every number in the spec maps to an entry in `docs/sources.md`.
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
See [`docs/roadmap.md`](docs/roadmap.md) for open directions. A new category is accepted if it meets the principles above and ships with a source.
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
Dual-licensed under either **MIT** ([`LICENSE-MIT`](LICENSE-MIT)) or **Apache License 2.0** ([`LICENSE-APACHE`](LICENSE-APACHE)), at your option — the standard Rust-ecosystem convention. SPDX-License-Identifier: `MIT OR Apache-2.0`.
|
|
210
|
+
|
|
211
|
+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// rust-intel installer for npx — mirrors rust-cc-install.sh / .ps1.
|
|
3
|
+
// Zero dependencies; Node >= 16.
|
|
4
|
+
//
|
|
5
|
+
// npx rust-intel-cc install into ./.claude (project-local)
|
|
6
|
+
// npx rust-intel-cc --user install into ~/.claude (global; honors CLAUDE_CONFIG_DIR)
|
|
7
|
+
// npx rust-intel-cc --uninstall [--user]
|
|
8
|
+
// npx rust-intel-cc --help
|
|
9
|
+
//
|
|
10
|
+
// Prefer the native Claude Code plugin instead when possible:
|
|
11
|
+
// /plugin marketplace add PHPCraftdream/rust-intel
|
|
12
|
+
// /plugin install rust-intel@rust-intel
|
|
13
|
+
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const os = require('os');
|
|
19
|
+
|
|
20
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
21
|
+
const SKILL_SRC = path.join(PKG_ROOT, 'skill');
|
|
22
|
+
const COMMANDS_SRC = path.join(PKG_ROOT, 'commands', 'rust-intel-cc');
|
|
23
|
+
const COMMANDS = ['audit', 'fix', 'plan']; // -> rust-cc-<name>.md (flattened, same as the shell installers)
|
|
24
|
+
|
|
25
|
+
function usage() {
|
|
26
|
+
console.log(`rust-intel installer
|
|
27
|
+
|
|
28
|
+
Usage:
|
|
29
|
+
npx rust-intel-cc install into ./.claude (project-local)
|
|
30
|
+
npx rust-intel-cc --user install into ~/.claude (global; honors CLAUDE_CONFIG_DIR)
|
|
31
|
+
npx rust-intel-cc --uninstall remove a project-local install (add --user for global)
|
|
32
|
+
npx rust-intel-cc --help this text
|
|
33
|
+
|
|
34
|
+
Installs:
|
|
35
|
+
<target>/skills/rust-intel/ the skill (SKILL.md + theme modules + audit workflow)
|
|
36
|
+
<target>/commands/rust-cc-audit.md /rust-cc-audit
|
|
37
|
+
<target>/commands/rust-cc-fix.md /rust-cc-fix
|
|
38
|
+
<target>/commands/rust-cc-plan.md /rust-cc-plan
|
|
39
|
+
|
|
40
|
+
Tip: the native Claude Code plugin is the recommended install (auto-updates):
|
|
41
|
+
/plugin marketplace add PHPCraftdream/rust-intel
|
|
42
|
+
/plugin install rust-intel@rust-intel`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function fail(msg) {
|
|
46
|
+
console.error(`error: ${msg}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function targetDir(user) {
|
|
51
|
+
if (user) return process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
|
|
52
|
+
return path.join(process.cwd(), '.claude');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function rmrf(p) {
|
|
56
|
+
fs.rmSync(p, { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function main() {
|
|
60
|
+
const args = process.argv.slice(2);
|
|
61
|
+
if (args.includes('--help') || args.includes('-h')) return usage();
|
|
62
|
+
const user = args.includes('--user');
|
|
63
|
+
const uninstall = args.includes('--uninstall');
|
|
64
|
+
const unknown = args.filter((a) => !['--user', '--uninstall'].includes(a));
|
|
65
|
+
if (unknown.length) fail(`unknown argument(s): ${unknown.join(' ')} (see --help)`);
|
|
66
|
+
|
|
67
|
+
const target = targetDir(user);
|
|
68
|
+
const skillDst = path.join(target, 'skills', 'rust-intel');
|
|
69
|
+
const commandsDst = path.join(target, 'commands');
|
|
70
|
+
|
|
71
|
+
if (uninstall) {
|
|
72
|
+
console.log(`Uninstalling rust-intel from ${target} ...`);
|
|
73
|
+
rmrf(skillDst);
|
|
74
|
+
for (const c of COMMANDS) rmrf(path.join(commandsDst, `rust-cc-${c}.md`));
|
|
75
|
+
console.log('Done.');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!fs.existsSync(SKILL_SRC) || !fs.existsSync(path.join(SKILL_SRC, 'SKILL.md'))) {
|
|
80
|
+
fail(`package is missing skill/SKILL.md (looked in ${SKILL_SRC})`);
|
|
81
|
+
}
|
|
82
|
+
if (!fs.existsSync(COMMANDS_SRC)) {
|
|
83
|
+
fail(`package is missing commands/rust-intel-cc/ (looked in ${COMMANDS_SRC})`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log(`Installing rust-intel into ${target} ...`);
|
|
87
|
+
|
|
88
|
+
// Clean previous install (mirrors the shell installers).
|
|
89
|
+
if (fs.existsSync(skillDst)) {
|
|
90
|
+
console.log(` cleaning ${skillDst} (previous install)`);
|
|
91
|
+
rmrf(skillDst);
|
|
92
|
+
}
|
|
93
|
+
fs.mkdirSync(skillDst, { recursive: true });
|
|
94
|
+
fs.mkdirSync(commandsDst, { recursive: true });
|
|
95
|
+
|
|
96
|
+
for (const entry of fs.readdirSync(SKILL_SRC)) {
|
|
97
|
+
if (!entry.endsWith('.md') && !entry.endsWith('.js')) continue;
|
|
98
|
+
fs.copyFileSync(path.join(SKILL_SRC, entry), path.join(skillDst, entry));
|
|
99
|
+
console.log(` copied ${path.join(skillDst, entry)}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
for (const c of COMMANDS) {
|
|
103
|
+
const src = path.join(COMMANDS_SRC, `${c}.md`);
|
|
104
|
+
if (!fs.existsSync(src)) fail(`package is missing ${src}`);
|
|
105
|
+
const dst = path.join(commandsDst, `rust-cc-${c}.md`);
|
|
106
|
+
fs.copyFileSync(src, dst);
|
|
107
|
+
console.log(` copied ${dst}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log(`
|
|
111
|
+
Done. Verify by starting 'claude' ${user ? 'anywhere' : 'in this directory'} and trying:
|
|
112
|
+
/rust-cc-audit
|
|
113
|
+
/rust-cc-fix <error message>
|
|
114
|
+
/rust-cc-plan <task description>
|
|
115
|
+
|
|
116
|
+
The skill 'rust-intel' will activate automatically on any Rust task.`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
main();
|