rulekeeper 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.
- package/LICENSE +21 -0
- package/README.md +465 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1879 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Adam Collins
|
|
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,465 @@
|
|
|
1
|
+
# RuleKeeper
|
|
2
|
+
|
|
3
|
+
A cross-platform CLI tool for syncing and managing [Claude Code](https://docs.anthropic.com/en/docs/claude-code) rules across multiple projects.
|
|
4
|
+
|
|
5
|
+
> **Note:** Claude Code has [built-in memory features](https://code.claude.com/docs/en/memory) that may meet your needs. RuleKeeper is a community tool for specific use cases like multi-project syncing and divergence tracking that aren't covered by the official solutions.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
RuleKeeper helps teams and multi-project users maintain consistent Claude Code configurations by:
|
|
10
|
+
|
|
11
|
+
- Syncing `.claude/` directory files from a central source (local folder or git repository)
|
|
12
|
+
- Tracking rule states: synced, outdated, diverged, or detached
|
|
13
|
+
- Supporting selective rule installation per project
|
|
14
|
+
- Handling conflicts when local changes exist
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g rulekeeper
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This installs both `rulekeeper` and the shorter `rk` alias.
|
|
23
|
+
|
|
24
|
+
**Requirements:** Node.js 18.0.0 or higher
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# 1. Initialize RuleKeeper with your rules source
|
|
30
|
+
rk init
|
|
31
|
+
|
|
32
|
+
# 2. Navigate to a project and add rules
|
|
33
|
+
cd my-project
|
|
34
|
+
rk add # Interactive selection
|
|
35
|
+
rk add -a # Add all available rules
|
|
36
|
+
rk add coding-style # Add specific rule by name
|
|
37
|
+
|
|
38
|
+
# 3. Check status and keep rules updated
|
|
39
|
+
rk status
|
|
40
|
+
rk pull
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
### Global Configuration
|
|
46
|
+
|
|
47
|
+
RuleKeeper stores its global configuration in a platform-specific location:
|
|
48
|
+
|
|
49
|
+
| Platform | Location |
|
|
50
|
+
|----------|----------|
|
|
51
|
+
| macOS | `~/Library/Preferences/rulekeeper/config.yaml` |
|
|
52
|
+
| Linux | `~/.config/rulekeeper/config.yaml` |
|
|
53
|
+
| Windows | `%APPDATA%\rulekeeper\Config\config.yaml` |
|
|
54
|
+
|
|
55
|
+
Example configuration:
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
version: 1
|
|
59
|
+
source:
|
|
60
|
+
type: git
|
|
61
|
+
path: /Users/you/Documents/claude-rules
|
|
62
|
+
remote: https://github.com/team/claude-rules.git
|
|
63
|
+
settings:
|
|
64
|
+
autoPull: true
|
|
65
|
+
pullFrequency: daily
|
|
66
|
+
lastPull: '2024-01-15T10:30:00.000Z'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Project Configuration
|
|
70
|
+
|
|
71
|
+
Each project using RuleKeeper has a `.rulekeeper/manifest.yaml` file that tracks:
|
|
72
|
+
|
|
73
|
+
- Which rules are installed
|
|
74
|
+
- Their sync status (source and local hashes)
|
|
75
|
+
- Detachment state for intentionally diverged rules
|
|
76
|
+
|
|
77
|
+
Example manifest:
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
version: 1
|
|
81
|
+
rules:
|
|
82
|
+
coding-style:
|
|
83
|
+
file: coding-style.md
|
|
84
|
+
status: synced
|
|
85
|
+
sourceHash: sha256:abc123...
|
|
86
|
+
localHash: sha256:abc123...
|
|
87
|
+
testing:
|
|
88
|
+
file: testing.md
|
|
89
|
+
status: detached
|
|
90
|
+
sourceHash: sha256:def456...
|
|
91
|
+
localHash: sha256:xyz789...
|
|
92
|
+
detachedAt: '2024-01-10T15:00:00.000Z'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Commands
|
|
96
|
+
|
|
97
|
+
### `rk init`
|
|
98
|
+
|
|
99
|
+
Interactive setup wizard to configure your rules source.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
rk init # Start interactive setup
|
|
103
|
+
rk init --force # Overwrite existing configuration
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Options:**
|
|
107
|
+
|
|
108
|
+
| Option | Description |
|
|
109
|
+
|--------|-------------|
|
|
110
|
+
| `-f, --force` | Overwrite existing configuration |
|
|
111
|
+
|
|
112
|
+
**Source Types:**
|
|
113
|
+
- **Local folder** - Path to a folder containing `.md` rule files (auto-detects if it's a git repo with remote)
|
|
114
|
+
- **Git repository** - Clone a repository containing your rules
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `rk add [rules...]`
|
|
119
|
+
|
|
120
|
+
Add rules to the current project.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
rk add # Interactive selection
|
|
124
|
+
rk add coding-style # Add specific rule (case-insensitive)
|
|
125
|
+
rk add style testing api # Add multiple rules
|
|
126
|
+
rk add -a # Add all available rules
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Options:**
|
|
130
|
+
|
|
131
|
+
| Option | Description |
|
|
132
|
+
|--------|-------------|
|
|
133
|
+
| `-a, --all` | Add all available rules from source |
|
|
134
|
+
|
|
135
|
+
**Behavior:**
|
|
136
|
+
- Creates `.claude/` directory if it doesn't exist
|
|
137
|
+
- Rule names are case-insensitive (`Coding-Style` matches `coding-style.md`)
|
|
138
|
+
- Prompts for confirmation if a file already exists with local changes
|
|
139
|
+
- Options when conflict detected: overwrite, skip, or detach
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### `rk remove <rules...>`
|
|
144
|
+
|
|
145
|
+
Remove rules from the project.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
rk remove coding-style # Remove rule and delete file
|
|
149
|
+
rk remove style testing # Remove multiple rules
|
|
150
|
+
rk remove coding-style -k # Remove from manifest but keep file
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Options:**
|
|
154
|
+
|
|
155
|
+
| Option | Description |
|
|
156
|
+
|--------|-------------|
|
|
157
|
+
| `-k, --keep-file` | Keep the local file, only remove from manifest |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### `rk status`
|
|
162
|
+
|
|
163
|
+
Show the sync status of all tracked rules in the current project.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
rk status
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Status indicators:**
|
|
170
|
+
|
|
171
|
+
| Status | Description |
|
|
172
|
+
|--------|-------------|
|
|
173
|
+
| `synced` | Local file matches source |
|
|
174
|
+
| `outdated` | Source has newer version |
|
|
175
|
+
| `diverged` | Local changes detected (different from source) |
|
|
176
|
+
| `detached` | Intentionally diverged, won't prompt for updates |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### `rk pull [rules...]`
|
|
181
|
+
|
|
182
|
+
Update rules from source.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
rk pull # Update all outdated rules
|
|
186
|
+
rk pull coding-style # Update specific rule
|
|
187
|
+
rk pull -f # Force overwrite diverged rules
|
|
188
|
+
rk pull --include-detached # Include detached rules in update
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Options:**
|
|
192
|
+
|
|
193
|
+
| Option | Description |
|
|
194
|
+
|--------|-------------|
|
|
195
|
+
| `-f, --force` | Overwrite diverged rules without prompting |
|
|
196
|
+
| `--include-detached` | Include detached rules in the update |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### `rk diff [rule]`
|
|
201
|
+
|
|
202
|
+
Show differences between local and source versions.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
rk diff # Show diff for all diverged rules
|
|
206
|
+
rk diff coding-style # Show diff for specific rule
|
|
207
|
+
rk diff -a # Show diff for all rules (including synced)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Options:**
|
|
211
|
+
|
|
212
|
+
| Option | Description |
|
|
213
|
+
|--------|-------------|
|
|
214
|
+
| `-a, --all` | Show diff for all rules, not just diverged ones |
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### `rk list`
|
|
219
|
+
|
|
220
|
+
List available rules from your configured source.
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
rk list # List all available rules
|
|
224
|
+
rk list -i # List only installed rules in current project
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Options:**
|
|
228
|
+
|
|
229
|
+
| Option | Description |
|
|
230
|
+
|--------|-------------|
|
|
231
|
+
| `-i, --installed` | Show only rules installed in current project |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### `rk detach <rule>`
|
|
236
|
+
|
|
237
|
+
Mark a rule as intentionally diverged. Detached rules won't trigger update prompts.
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
rk detach coding-style
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Use this when you've made intentional local customizations that should be preserved.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
### `rk attach <rule>`
|
|
248
|
+
|
|
249
|
+
Resume tracking a previously detached rule.
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
rk attach coding-style
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
After attaching, the rule will be included in status checks and pull operations.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### `rk source`
|
|
260
|
+
|
|
261
|
+
Manage your rules source configuration.
|
|
262
|
+
|
|
263
|
+
#### `rk source show`
|
|
264
|
+
|
|
265
|
+
Display current source configuration.
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
rk source show
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Shows: source type, path, remote URL (if git), auto-pull settings, and last pull time.
|
|
272
|
+
|
|
273
|
+
#### `rk source set <path-or-url>`
|
|
274
|
+
|
|
275
|
+
Change the source location.
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
rk source set /path/to/rules # Local folder
|
|
279
|
+
rk source set ~/Documents/my-rules # Supports tilde expansion
|
|
280
|
+
rk source set https://github.com/org/rules.git # Git URL (will clone)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### `rk source pull`
|
|
284
|
+
|
|
285
|
+
Manually pull latest changes from git remote.
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
rk source pull
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Only works if source is a git repository with a configured remote.
|
|
292
|
+
|
|
293
|
+
#### `rk source config`
|
|
294
|
+
|
|
295
|
+
View or update pull settings.
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
rk source config # View current settings
|
|
299
|
+
rk source config --auto-pull on # Enable auto-pull
|
|
300
|
+
rk source config --auto-pull off # Disable auto-pull
|
|
301
|
+
rk source config --frequency daily # Set pull frequency
|
|
302
|
+
rk source config --auto-pull on --frequency weekly # Update both
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Options:**
|
|
306
|
+
|
|
307
|
+
| Option | Values | Description |
|
|
308
|
+
|--------|--------|-------------|
|
|
309
|
+
| `--auto-pull` | `on`, `off`, `true`, `false` | Enable or disable automatic pulling |
|
|
310
|
+
| `--frequency` | `always`, `daily`, `weekly` | How often to check for updates |
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### `rk doctor`
|
|
315
|
+
|
|
316
|
+
Diagnose setup issues and verify configuration.
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
rk doctor
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Checks performed:**
|
|
323
|
+
- Global configuration exists and is valid
|
|
324
|
+
- Source path exists and is accessible
|
|
325
|
+
- Git remote is reachable (if applicable)
|
|
326
|
+
- Current project has valid manifest (if in a project)
|
|
327
|
+
|
|
328
|
+
## Rule States
|
|
329
|
+
|
|
330
|
+
| State | Description | Behavior |
|
|
331
|
+
|-------|-------------|----------|
|
|
332
|
+
| `synced` | Local file matches source exactly | No action needed |
|
|
333
|
+
| `outdated` | Source has been updated, local is behind | `rk pull` will update |
|
|
334
|
+
| `diverged` | Local changes exist that differ from source | Prompted to overwrite or detach |
|
|
335
|
+
| `detached` | Intentionally diverged, excluded from updates | Ignored by `rk pull` unless `--include-detached` |
|
|
336
|
+
|
|
337
|
+
## Handling Existing `.claude` Directories
|
|
338
|
+
|
|
339
|
+
When adding rules to a project that already has a `.claude` directory with existing files:
|
|
340
|
+
|
|
341
|
+
1. **New rules** - Files that don't exist locally are copied from source
|
|
342
|
+
2. **Existing untracked files** - You're prompted to: overwrite, skip, or detach
|
|
343
|
+
3. **Existing tracked files** - Updated if unchanged locally, prompted if diverged
|
|
344
|
+
|
|
345
|
+
This allows you to:
|
|
346
|
+
- Adopt RuleKeeper in projects with existing Claude configurations
|
|
347
|
+
- Selectively sync some rules while keeping local customizations
|
|
348
|
+
- Gradually migrate to centralized rule management
|
|
349
|
+
|
|
350
|
+
## Cross-Platform Support
|
|
351
|
+
|
|
352
|
+
RuleKeeper works on:
|
|
353
|
+
|
|
354
|
+
| Platform | Shells |
|
|
355
|
+
|----------|--------|
|
|
356
|
+
| macOS | Terminal, iTerm, etc. |
|
|
357
|
+
| Linux | Bash, Zsh, etc. |
|
|
358
|
+
| Windows | CMD, PowerShell, Git Bash, WSL |
|
|
359
|
+
|
|
360
|
+
On Windows, RuleKeeper auto-detects your shell environment for optimal path handling.
|
|
361
|
+
|
|
362
|
+
> **PowerShell Users:** Windows security policy blocks npm global package scripts by default. Run this once to enable:
|
|
363
|
+
> ```powershell
|
|
364
|
+
> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
365
|
+
> ```
|
|
366
|
+
> This affects all npm global packages, not just RuleKeeper. CMD and Git Bash work without this step.
|
|
367
|
+
|
|
368
|
+
## Source Repository Structure
|
|
369
|
+
|
|
370
|
+
Your rules source should contain `.md` files at the root level:
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
rules-repo/
|
|
374
|
+
├── coding-style.md
|
|
375
|
+
├── testing.md
|
|
376
|
+
├── api-guidelines.md
|
|
377
|
+
└── security.md
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Each `.md` file becomes an available rule that can be added to projects.
|
|
381
|
+
|
|
382
|
+
## Example Workflows
|
|
383
|
+
|
|
384
|
+
### Team Setup
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
# Team lead sets up shared rules repository
|
|
388
|
+
mkdir team-rules && cd team-rules
|
|
389
|
+
git init
|
|
390
|
+
echo "# Coding Standards" > coding-style.md
|
|
391
|
+
echo "# Testing Guidelines" > testing.md
|
|
392
|
+
git add . && git commit -m "Initial rules"
|
|
393
|
+
git remote add origin https://github.com/team/claude-rules.git
|
|
394
|
+
git push -u origin main
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Developer Setup
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
# Developer configures RuleKeeper
|
|
401
|
+
rk init
|
|
402
|
+
# Select "Git repository" and enter the team's URL
|
|
403
|
+
|
|
404
|
+
# In each project
|
|
405
|
+
cd my-project
|
|
406
|
+
rk add -a # Add all team rules
|
|
407
|
+
rk status # Check sync status
|
|
408
|
+
|
|
409
|
+
# When team rules are updated
|
|
410
|
+
rk pull # Get latest changes
|
|
411
|
+
|
|
412
|
+
# For project-specific customizations
|
|
413
|
+
rk detach coding-style # Keep local changes for this rule
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Checking and Updating
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# See what's changed
|
|
420
|
+
rk status
|
|
421
|
+
rk diff
|
|
422
|
+
|
|
423
|
+
# Update everything
|
|
424
|
+
rk pull
|
|
425
|
+
|
|
426
|
+
# Update specific rule
|
|
427
|
+
rk pull testing
|
|
428
|
+
|
|
429
|
+
# Force update (overwrite local changes)
|
|
430
|
+
rk pull -f
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Managing Settings
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
# View current source and settings
|
|
437
|
+
rk source show
|
|
438
|
+
|
|
439
|
+
# Change source location
|
|
440
|
+
rk source set ~/new-rules-location
|
|
441
|
+
|
|
442
|
+
# Adjust auto-pull behavior
|
|
443
|
+
rk source config --auto-pull off
|
|
444
|
+
rk source config --frequency weekly
|
|
445
|
+
|
|
446
|
+
# Manually update source repo
|
|
447
|
+
rk source pull
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
## When to Use RuleKeeper
|
|
451
|
+
|
|
452
|
+
First, check Claude Code's [official memory features](https://code.claude.com/docs/en/memory) - they may be all you need.
|
|
453
|
+
|
|
454
|
+
RuleKeeper fills gaps not covered by official solutions:
|
|
455
|
+
|
|
456
|
+
- **Multiple projects, same rules** - Manage once, distribute everywhere
|
|
457
|
+
- **Multiple machines** - Source of truth in a git repo syncs across machines
|
|
458
|
+
- **Small teams** - Share standards without enterprise infrastructure
|
|
459
|
+
- **Claude Code web** - Rules must be real files (symlinks don't work)
|
|
460
|
+
- **Divergence tracking** - Know when local rules have drifted
|
|
461
|
+
- **Intentional variations** - Track that a project has deliberately different rules
|
|
462
|
+
|
|
463
|
+
## License
|
|
464
|
+
|
|
465
|
+
MIT
|
package/dist/index.d.ts
ADDED