ai-nexus 1.0.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.
- package/LICENSE +190 -0
- package/README.md +308 -0
- package/bin/ai-rules.cjs +120 -0
- package/config/agents/code-standards.md +81 -0
- package/config/agents/review-checklist.md +70 -0
- package/config/agents/security-rules.md +51 -0
- package/config/codex/AGENTS.md +69 -0
- package/config/commands/commit.md +34 -0
- package/config/commands/review.md +36 -0
- package/config/contexts/dev.md +20 -0
- package/config/hooks/README.md +110 -0
- package/config/hooks/semantic-router.cjs +236 -0
- package/config/rules/code-thresholds.md +12 -0
- package/config/rules/commit.md +49 -0
- package/config/rules/development-workflow.md +19 -0
- package/config/rules/essential.md +19 -0
- package/config/rules/pr.md +54 -0
- package/config/rules/security.md +19 -0
- package/config/settings.json +15 -0
- package/config/skills/react.md +42 -0
- package/config/skills/review.md +42 -0
- package/config/templates/basic/CLAUDE.md +23 -0
- package/config/templates/node-express/CLAUDE.md +75 -0
- package/config/templates/react-nextjs/CLAUDE.md +59 -0
- package/dist/commands/add.d.ts +5 -0
- package/dist/commands/add.js +69 -0
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +212 -0
- package/dist/commands/init-interactive.d.ts +1 -0
- package/dist/commands/init-interactive.js +397 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +160 -0
- package/dist/commands/list.d.ts +1 -0
- package/dist/commands/list.js +63 -0
- package/dist/commands/remove.d.ts +1 -0
- package/dist/commands/remove.js +59 -0
- package/dist/commands/test.d.ts +5 -0
- package/dist/commands/test.js +94 -0
- package/dist/commands/uninstall.d.ts +6 -0
- package/dist/commands/uninstall.js +87 -0
- package/dist/commands/update.d.ts +6 -0
- package/dist/commands/update.js +163 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/utils/config-scanner.d.ts +20 -0
- package/dist/utils/config-scanner.js +112 -0
- package/dist/utils/files.d.ts +20 -0
- package/dist/utils/files.js +77 -0
- package/dist/utils/git.d.ts +15 -0
- package/dist/utils/git.js +58 -0
- package/dist/utils/semantic-router.d.ts +26 -0
- package/dist/utils/semantic-router.js +316 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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 the 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
|
+
Copyright 2024 JSK9999
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# ai-rules
|
|
2
|
+
|
|
3
|
+
> Stop wasting tokens. Load only the rules you need.
|
|
4
|
+
|
|
5
|
+
AI coding assistant rule manager for **Claude Code**, **Cursor**, and **Codex**.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/ai-rules)
|
|
8
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx ai-rules install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## The Problem
|
|
17
|
+
|
|
18
|
+
Every time you ask Claude Code a question, it loads **all** your rules:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Loading rules... 4,300 lines
|
|
22
|
+
Token cost: ~5,000 tokens per request
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That's tokens wasted on React rules when you're asking about Git commits.
|
|
26
|
+
|
|
27
|
+
## The Solution
|
|
28
|
+
|
|
29
|
+
**ai-rules** uses a semantic router to load only relevant rules:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
You: "Write a commit message"
|
|
33
|
+
|
|
34
|
+
Semantic Router activates:
|
|
35
|
+
✓ commit.md (needed)
|
|
36
|
+
✓ essential.md (always on)
|
|
37
|
+
✗ react.md (skipped)
|
|
38
|
+
✗ security.md (skipped)
|
|
39
|
+
|
|
40
|
+
Token cost: ~800 tokens (84% savings)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Interactive setup (recommended)
|
|
49
|
+
npx ai-rules install -i
|
|
50
|
+
|
|
51
|
+
# Quick install with defaults
|
|
52
|
+
npx ai-rules install
|
|
53
|
+
|
|
54
|
+
# Use your team's rules
|
|
55
|
+
npx ai-rules install --rules github.com/your-org/team-rules
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Supported Tools
|
|
61
|
+
|
|
62
|
+
| Tool | How it works | Token Savings |
|
|
63
|
+
|------|--------------|---------------|
|
|
64
|
+
| **Claude Code** | Semantic Router dynamically swaps rules per prompt | ~84% |
|
|
65
|
+
| **Cursor** | Semantic Search via `.mdc` description fields | ~70% |
|
|
66
|
+
| **Codex** | Static `AGENTS.md` (no dynamic loading) | - |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## How It Works
|
|
71
|
+
|
|
72
|
+
### Claude Code: Semantic Router
|
|
73
|
+
|
|
74
|
+
A hook runs on every prompt, analyzing what rules you actually need:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
~/.claude/
|
|
78
|
+
├── hooks/
|
|
79
|
+
│ └── semantic-router.cjs # Runs on each prompt
|
|
80
|
+
├── settings.json # Hook configuration
|
|
81
|
+
├── rules/ # Active rules
|
|
82
|
+
└── rules-inactive/ # Parked rules (not loaded)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**With AI routing** (recommended):
|
|
86
|
+
```bash
|
|
87
|
+
export OPENAI_API_KEY=sk-xxx # or ANTHROPIC_API_KEY
|
|
88
|
+
export SEMANTIC_ROUTER_ENABLED=true
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
GPT-4o-mini or Claude Haiku analyzes your prompt and picks the right rules. Cost: ~$0.50/month.
|
|
92
|
+
|
|
93
|
+
**Without AI** (fallback):
|
|
94
|
+
Keyword matching activates rules based on words in your prompt.
|
|
95
|
+
|
|
96
|
+
### Cursor: Semantic Search
|
|
97
|
+
|
|
98
|
+
Rules are converted to `.mdc` format with description metadata:
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
---
|
|
102
|
+
description: Git commit message conventions and best practices
|
|
103
|
+
alwaysApply: false
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
# Commit Rules
|
|
107
|
+
...
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Cursor's built-in semantic search loads rules based on relevance.
|
|
111
|
+
|
|
112
|
+
### Codex: Static Rules
|
|
113
|
+
|
|
114
|
+
A single `AGENTS.md` file is loaded at session start. No dynamic loading.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Commands
|
|
119
|
+
|
|
120
|
+
| Command | Description |
|
|
121
|
+
|---------|-------------|
|
|
122
|
+
| `install` | Install rules globally (`~/.claude/`) |
|
|
123
|
+
| `install -i` | Interactive mode - choose tools, rules, template |
|
|
124
|
+
| `init` | Install in current project (`.claude/`) |
|
|
125
|
+
| `update` | Sync latest rules (respects local changes) |
|
|
126
|
+
| `list` | Show installed rules |
|
|
127
|
+
| `test <prompt>` | Preview which rules would load |
|
|
128
|
+
| `add <url>` | Add rules from a Git repository |
|
|
129
|
+
| `remove <name>` | Remove a rule source |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Team Rules
|
|
134
|
+
|
|
135
|
+
Share rules across your team via Git:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Everyone installs from the same source
|
|
139
|
+
npx ai-rules install --rules github.com/acme/team-rules
|
|
140
|
+
|
|
141
|
+
# When rules are updated
|
|
142
|
+
npx ai-rules update
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Creating a Rules Repository
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
team-rules/
|
|
149
|
+
├── config/
|
|
150
|
+
│ ├── rules/ # Core rules (essential.md, security.md)
|
|
151
|
+
│ ├── commands/ # Slash commands (/commit, /review)
|
|
152
|
+
│ ├── skills/ # Domain knowledge (react.md, rust.md)
|
|
153
|
+
│ ├── agents/ # Sub-agents (code-reviewer.md)
|
|
154
|
+
│ ├── contexts/ # Context files (@dev, @research)
|
|
155
|
+
│ ├── hooks/ # semantic-router.cjs
|
|
156
|
+
│ └── settings.json # Claude Code hook config
|
|
157
|
+
└── README.md
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Rule Format
|
|
161
|
+
|
|
162
|
+
```markdown
|
|
163
|
+
---
|
|
164
|
+
description: When to load this rule (used by semantic router)
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
# Rule Title
|
|
168
|
+
|
|
169
|
+
Your rule content...
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Installation Modes
|
|
175
|
+
|
|
176
|
+
### Symlink (default)
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npx ai-rules install
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- Rules link to source → `update` syncs instantly
|
|
183
|
+
- Cannot edit rules directly (edit source instead)
|
|
184
|
+
|
|
185
|
+
### Copy
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npx ai-rules install --copy
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- Rules are independent copies
|
|
192
|
+
- Can edit locally
|
|
193
|
+
- `update` only adds new files, never overwrites
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Local Priority
|
|
198
|
+
|
|
199
|
+
Your customizations are always safe:
|
|
200
|
+
|
|
201
|
+
- **Existing files are never overwritten** during install or update
|
|
202
|
+
- Only new files from source are added
|
|
203
|
+
- Use `--force` to override (backup first!)
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# This will NOT overwrite your custom commit.md
|
|
207
|
+
npx ai-rules update
|
|
208
|
+
|
|
209
|
+
# This WILL overwrite everything
|
|
210
|
+
npx ai-rules update --force
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Directory Structure
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
.ai-rules/ # ai-rules metadata
|
|
219
|
+
├── config/ # Merged rules from all sources
|
|
220
|
+
├── sources/ # Cloned Git repositories
|
|
221
|
+
└── meta.json # Installation info
|
|
222
|
+
|
|
223
|
+
.claude/ # Claude Code
|
|
224
|
+
├── hooks/semantic-router.cjs
|
|
225
|
+
├── settings.json
|
|
226
|
+
├── rules/ → .ai-rules/config/rules
|
|
227
|
+
└── commands/ → .ai-rules/config/commands
|
|
228
|
+
|
|
229
|
+
.cursor/rules/ # Cursor (.mdc files)
|
|
230
|
+
├── essential.mdc
|
|
231
|
+
└── commit.mdc
|
|
232
|
+
|
|
233
|
+
.codex/AGENTS.md # Codex
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Examples
|
|
239
|
+
|
|
240
|
+
### Personal Setup
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
npx ai-rules install -i
|
|
244
|
+
# Select: Claude Code, Cursor
|
|
245
|
+
# Select: rules, commands, hooks, settings
|
|
246
|
+
# Template: React/Next.js
|
|
247
|
+
# Mode: symlink
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Team Setup
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# 1. Create team rules repo on GitHub
|
|
254
|
+
|
|
255
|
+
# 2. Each developer:
|
|
256
|
+
npx ai-rules install --rules github.com/acme/team-rules
|
|
257
|
+
|
|
258
|
+
# 3. Weekly sync:
|
|
259
|
+
npx ai-rules update
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Multi-Source Setup
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Base company rules
|
|
266
|
+
npx ai-rules install --rules github.com/acme/base-rules
|
|
267
|
+
|
|
268
|
+
# Add frontend team rules
|
|
269
|
+
npx ai-rules add github.com/acme/frontend-rules
|
|
270
|
+
|
|
271
|
+
# Add security rules
|
|
272
|
+
npx ai-rules add github.com/acme/security-rules
|
|
273
|
+
|
|
274
|
+
# Update all at once
|
|
275
|
+
npx ai-rules update
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Testing
|
|
281
|
+
|
|
282
|
+
Preview which rules would load for a given prompt:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
$ npx ai-rules test "write a react component with hooks"
|
|
286
|
+
|
|
287
|
+
Selected rules (3):
|
|
288
|
+
• rules/essential.md
|
|
289
|
+
• rules/react.md
|
|
290
|
+
• skills/react.md
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Contributing
|
|
296
|
+
|
|
297
|
+
1. Fork & clone
|
|
298
|
+
2. `npm install`
|
|
299
|
+
3. Edit rules in `config/`
|
|
300
|
+
4. `npm run build`
|
|
301
|
+
5. Test: `node bin/ai-rules.cjs list`
|
|
302
|
+
6. PR!
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
Apache 2.0
|
package/bin/ai-rules.cjs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
const VERSION = require('../package.json').version;
|
|
9
|
+
|
|
10
|
+
program
|
|
11
|
+
.name('ai-rules')
|
|
12
|
+
.description('AI coding assistant rule manager for Claude Code, Codex, and Cursor')
|
|
13
|
+
.version(VERSION);
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.command('init')
|
|
17
|
+
.description('Initialize rules in current project (.claude/, .codex/)')
|
|
18
|
+
.option('--rules <url>', 'Git repository URL for rules (e.g., github.com/org/my-rules)')
|
|
19
|
+
.option('--copy', 'Copy files instead of symlink')
|
|
20
|
+
.option('-i, --interactive', 'Use interactive mode with file selection')
|
|
21
|
+
.option('-y, --yes', 'Skip prompts and use defaults')
|
|
22
|
+
.action(async (options) => {
|
|
23
|
+
if (options.interactive) {
|
|
24
|
+
const { initInteractive } = await import('../dist/commands/init-interactive.js');
|
|
25
|
+
await initInteractive();
|
|
26
|
+
} else {
|
|
27
|
+
const { init } = await import('../dist/commands/init.js');
|
|
28
|
+
await init({ scope: 'project', ...options });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
program
|
|
33
|
+
.command('install')
|
|
34
|
+
.description('Install rules globally (~/.claude/, ~/.codex/)')
|
|
35
|
+
.option('--rules <url>', 'Git repository URL for rules')
|
|
36
|
+
.option('--copy', 'Copy files instead of symlink')
|
|
37
|
+
.option('-i, --interactive', 'Use interactive mode with file selection')
|
|
38
|
+
.action(async (options) => {
|
|
39
|
+
if (options.interactive) {
|
|
40
|
+
const { initInteractive } = await import('../dist/commands/init-interactive.js');
|
|
41
|
+
await initInteractive();
|
|
42
|
+
} else {
|
|
43
|
+
const { init } = await import('../dist/commands/init.js');
|
|
44
|
+
await init({ scope: 'global', ...options });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
program
|
|
49
|
+
.command('update')
|
|
50
|
+
.description('Update installed rules to latest version')
|
|
51
|
+
.option('-f, --force', 'Overwrite all modified files')
|
|
52
|
+
.option('-a, --add-only', 'Only add new files, never overwrite')
|
|
53
|
+
.option('-i, --interactive', 'Choose which files to overwrite')
|
|
54
|
+
.action(async (options) => {
|
|
55
|
+
const { update } = await import('../dist/commands/update.js');
|
|
56
|
+
await update(options);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
program
|
|
60
|
+
.command('list')
|
|
61
|
+
.description('List available rules and keywords')
|
|
62
|
+
.action(async () => {
|
|
63
|
+
const { list } = await import('../dist/commands/list.js');
|
|
64
|
+
await list();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
program
|
|
68
|
+
.command('add <source>')
|
|
69
|
+
.description('Add rules from a git repository')
|
|
70
|
+
.option('--name <name>', 'Custom name for the rule source')
|
|
71
|
+
.action(async (source, options) => {
|
|
72
|
+
const { add } = await import('../dist/commands/add.js');
|
|
73
|
+
await add(source, options);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
program
|
|
77
|
+
.command('remove <name>')
|
|
78
|
+
.description('Remove a rule source')
|
|
79
|
+
.action(async (name) => {
|
|
80
|
+
const { remove } = await import('../dist/commands/remove.js');
|
|
81
|
+
await remove(name);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
program
|
|
85
|
+
.command('test [input]')
|
|
86
|
+
.description('Test which rules will be loaded for given input')
|
|
87
|
+
.option('--keyword', 'Use keyword matching only (skip AI)')
|
|
88
|
+
.option('--list', 'List all registered keywords')
|
|
89
|
+
.action(async (input, options) => {
|
|
90
|
+
const { test, testKeywords } = await import('../dist/commands/test.js');
|
|
91
|
+
if (options.list) {
|
|
92
|
+
await testKeywords();
|
|
93
|
+
} else if (input) {
|
|
94
|
+
await test(input, options);
|
|
95
|
+
} else {
|
|
96
|
+
console.log('Usage: ai-rules test <input> [--keyword]');
|
|
97
|
+
console.log(' ai-rules test --list');
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
program
|
|
102
|
+
.command('uninstall')
|
|
103
|
+
.description('Remove ai-rules installation')
|
|
104
|
+
.option('-f, --force', 'Skip confirmation prompt')
|
|
105
|
+
.option('-g, --global', 'Uninstall global installation only')
|
|
106
|
+
.option('-p, --project', 'Uninstall project installation only')
|
|
107
|
+
.action(async (options) => {
|
|
108
|
+
const { uninstall } = await import('../dist/commands/uninstall.js');
|
|
109
|
+
await uninstall(options);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
program
|
|
113
|
+
.command('doctor')
|
|
114
|
+
.description('Diagnose ai-rules installation')
|
|
115
|
+
.action(async () => {
|
|
116
|
+
const { doctor } = await import('../dist/commands/doctor.js');
|
|
117
|
+
await doctor();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
program.parse();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Code Standards
|
|
3
|
+
description: Code style, clean code, refactoring, and coding standards guidelines
|
|
4
|
+
keywords: [코드 스타일, code style, 린트, lint, 포맷, format, 코딩, coding, 개발, standards, clean code, refactoring, testing]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
AGENTS.md
|
|
8
|
+
|
|
9
|
+
Problem Definition → Small Safe Changes → Change Review → Refactoring — Repeat this loop.
|
|
10
|
+
|
|
11
|
+
Mandatory Rules
|
|
12
|
+
|
|
13
|
+
Read related files from start to finish, including call/reference paths, before changing anything.
|
|
14
|
+
Keep work, commits, and PRs small.
|
|
15
|
+
Record assumptions in Issues/PRs/ADRs.
|
|
16
|
+
Validate all inputs and encode/normalize outputs.
|
|
17
|
+
Avoid premature abstraction and use intention-revealing names.
|
|
18
|
+
Compare at least two alternatives before deciding.
|
|
19
|
+
|
|
20
|
+
Mindset
|
|
21
|
+
|
|
22
|
+
Think like a senior engineer.
|
|
23
|
+
Don't jump to conclusions or rush into assumptions.
|
|
24
|
+
Always evaluate multiple approaches, write one line each for pros/cons/risks, then choose the simplest solution.
|
|
25
|
+
|
|
26
|
+
Code & File Reference Rules
|
|
27
|
+
|
|
28
|
+
Read files thoroughly from start to finish (no partial reading).
|
|
29
|
+
Before changing code, find and read definitions, references, call sites, related tests, docs/config/flags.
|
|
30
|
+
Don't change code without reading the entire file.
|
|
31
|
+
Before modifying symbols, use global search to understand pre/post conditions and document impact in 1-3 lines.
|
|
32
|
+
|
|
33
|
+
Required Coding Rules
|
|
34
|
+
|
|
35
|
+
Write Problem 1-Pager before coding: Background / Problem / Goals / Non-Goals / Constraints.
|
|
36
|
+
Follow limits: File ≤ 300 LOC, Function ≤ 50 LOC, Parameters ≤ 5, Cyclomatic Complexity ≤ 10. Split/refactor if exceeded.
|
|
37
|
+
Prefer explicit code; prohibit hidden "magic".
|
|
38
|
+
Follow DRY but avoid premature abstraction.
|
|
39
|
+
Isolate side effects (I/O, network, global state) to boundary layers.
|
|
40
|
+
Handle only specific exceptions and provide clear messages to users.
|
|
41
|
+
Use structured logging and don't record sensitive data (propagate request/correlation IDs when possible).
|
|
42
|
+
Consider timezones and DST.
|
|
43
|
+
|
|
44
|
+
Testing Rules
|
|
45
|
+
|
|
46
|
+
Add new tests for new code; bug fixes must include regression tests (write to fail first).
|
|
47
|
+
Tests should be deterministic and independent; replace external systems with fakes/contract tests.
|
|
48
|
+
E2E tests must include ≥1 success path and ≥1 failure path.
|
|
49
|
+
Proactively assess risks from concurrency/locks/retries (duplicates, deadlocks, etc.).
|
|
50
|
+
|
|
51
|
+
ABSOLUTE Security Rules
|
|
52
|
+
|
|
53
|
+
NEVER: Leave secrets (passwords/API keys/tokens) in code/logs/tickets/environment variables/.env files.
|
|
54
|
+
NEVER: Log sensitive data (PII/credit cards/SSN) in logs.
|
|
55
|
+
NEVER: Leave SQL injection, XSS, CSRF vulnerabilities.
|
|
56
|
+
ALWAYS: Validate, normalize, and encode all inputs; use parameterized queries.
|
|
57
|
+
ALWAYS: Use HTTPS/TLS and apply principle of least privilege.
|
|
58
|
+
ALWAYS: Apply authentication/authorization to all endpoints.
|
|
59
|
+
ALWAYS: Set security headers (CSP, HSTS, X-Frame-Options).
|
|
60
|
+
ALWAYS: Regularly scan and update dependency vulnerabilities.
|
|
61
|
+
Stop work immediately and request review upon security violations.
|
|
62
|
+
|
|
63
|
+
Clean Code Rules
|
|
64
|
+
|
|
65
|
+
Use intention-revealing names.
|
|
66
|
+
Each function does one thing.
|
|
67
|
+
Isolate side effects to boundary layers.
|
|
68
|
+
Prefer guard clauses.
|
|
69
|
+
Always symbolize constants (no hardcoding).
|
|
70
|
+
Structure code as Input → Processing → Return.
|
|
71
|
+
Report failures with specific errors/messages.
|
|
72
|
+
Make tests work as usage examples and include boundary/failure cases.
|
|
73
|
+
Never add useless emojis.
|
|
74
|
+
|
|
75
|
+
Anti-Pattern Rules
|
|
76
|
+
|
|
77
|
+
Don't modify code without reading full context.
|
|
78
|
+
Don't expose secrets.
|
|
79
|
+
Don't ignore failures or warnings.
|
|
80
|
+
Don't introduce unfounded optimizations or abstractions.
|
|
81
|
+
Don't abuse broad exceptions.
|