claude-anchor 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 +24 -0
- package/README.md +296 -0
- package/bin/init.js +182 -0
- package/package.json +62 -0
- package/templates/CLAUDE.md +182 -0
- package/templates/_CONVERSATION-PREFERENCES.md +161 -0
- package/templates/_GOLDEN-RULES.md +84 -0
- package/templates/_LESSONS-LEARNED.md +100 -0
- package/templates/_LONG-TERM-MEMORY.md +274 -0
- package/templates/_SHORT-TERM-MEMORY.md +214 -0
- package/templates/_SYSTEM_ARCHITECTURE.md +321 -0
- package/templates/_TODOS.md +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Super Basic Studio, LLC
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>Claude Anchor</strong>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Claude Anchor</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>for Claude Code command line</em>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<em>A persistent memory, rules, and behavioral context framework for AI-assisted development with Claude Code.</em>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://www.npmjs.com/package/claude-anchor">
|
|
17
|
+
<img src="https://img.shields.io/npm/v/claude-anchor.svg" alt="npm version">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://www.npmjs.com/package/claude-anchor">
|
|
20
|
+
<img src="https://img.shields.io/npm/dm/claude-anchor.svg" alt="npm downloads">
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://github.com/superbasicstudio/claude-anchor/blob/main/LICENSE">
|
|
23
|
+
<img src="https://img.shields.io/npm/l/claude-anchor.svg" alt="license">
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
> [!IMPORTANT]
|
|
30
|
+
> ## Open Source Project Notice
|
|
31
|
+
>
|
|
32
|
+
> **This is open source software maintained by ONE individual in their free time.**
|
|
33
|
+
>
|
|
34
|
+
> While the templates are tested and reviewed before releases, you should **ALWAYS** have:
|
|
35
|
+
> - A proper GitHub/Git strategy in place
|
|
36
|
+
> - Regular backups of your work
|
|
37
|
+
> - Version control before running ANY script from the internet
|
|
38
|
+
>
|
|
39
|
+
> **DISCLAIMER**: This software is provided "as is" without warranty of any kind. Super Basic Studio and the maintainers of Claude Anchor are not responsible for any issues, data loss, or damages that may occur from using this tool. By using Claude Anchor, you acknowledge that you run it at your own risk.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
Give Claude persistent memory, enforceable rules, and behavioral consistency across sessions. Claude Anchor is the **behavioral brain** — it tells Claude *how to think and behave* in your project.
|
|
44
|
+
|
|
45
|
+
## Table of Contents
|
|
46
|
+
|
|
47
|
+
- [Quick Start](#quick-start)
|
|
48
|
+
- [What It Does](#what-it-does)
|
|
49
|
+
- [Templates](#templates)
|
|
50
|
+
- [Minimal Setup](#minimal-setup-simple-projects)
|
|
51
|
+
- [Full Setup](#full-setup-complex-projects)
|
|
52
|
+
- [Session Load Order](#session-load-order)
|
|
53
|
+
- [Template Overview](#template-overview)
|
|
54
|
+
- [Customization Guide](#customization-guide)
|
|
55
|
+
- [Naming Conventions](#naming-conventions)
|
|
56
|
+
- [Companion Project: Claude Conductor](#companion-project-claude-conductor)
|
|
57
|
+
- [Contributing](#contributing)
|
|
58
|
+
- [Privacy & Security](#privacy--security)
|
|
59
|
+
- [License](#license)
|
|
60
|
+
|
|
61
|
+
### External Resources
|
|
62
|
+
|
|
63
|
+
- [npm package](https://www.npmjs.com/package/claude-anchor) — `npx claude-anchor`
|
|
64
|
+
- [Claude Conductor](https://github.com/superbasicstudio/claude-conductor) — Companion codebase documentation framework
|
|
65
|
+
- [Changelog](CHANGELOG.md)
|
|
66
|
+
- [Security Policy](SECURITY.md)
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
[Back to top](#table-of-contents)
|
|
71
|
+
|
|
72
|
+
### Option 1: npx (Recommended)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Copy 3 essential templates into your project
|
|
76
|
+
npx claude-anchor
|
|
77
|
+
|
|
78
|
+
# Copy all 8 templates
|
|
79
|
+
npx claude-anchor --full
|
|
80
|
+
|
|
81
|
+
# Copy into a specific directory
|
|
82
|
+
npx claude-anchor ./my-project
|
|
83
|
+
|
|
84
|
+
# Overwrite existing files
|
|
85
|
+
npx claude-anchor --force
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Option 2: Manual (git clone)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Clone the templates
|
|
92
|
+
git clone https://github.com/superbasicstudio/claude-anchor.git
|
|
93
|
+
|
|
94
|
+
# Copy the templates you need into your project
|
|
95
|
+
cp claude-anchor/templates/_GOLDEN-RULES.md ./your-project/
|
|
96
|
+
cp claude-anchor/templates/_TODOS.md ./your-project/
|
|
97
|
+
cp claude-anchor/templates/_LONG-TERM-MEMORY.md ./your-project/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Then:
|
|
101
|
+
|
|
102
|
+
1. Edit each `.md` file, replacing `[PLACEHOLDERS]` with your project-specific content
|
|
103
|
+
2. Customize `_GOLDEN-RULES.md` with your project's constraints
|
|
104
|
+
3. Claude reads these files automatically at the start of each session
|
|
105
|
+
|
|
106
|
+
## What It Does
|
|
107
|
+
|
|
108
|
+
[Back to top](#table-of-contents)
|
|
109
|
+
|
|
110
|
+
Claude Anchor provides a structured template system that gives Claude:
|
|
111
|
+
|
|
112
|
+
- **Persistent memory** — Long-term knowledge that survives across sessions (user preferences, project conventions, important decisions)
|
|
113
|
+
- **Session continuity** — Short-term context for resuming work after interruptions or reboots
|
|
114
|
+
- **Enforceable rules** — Immutable constraints ("NEVER do X") that Claude must follow, read twice per session to prevent context decay
|
|
115
|
+
- **Conversation preferences** — Standardized output formatting, verbosity levels, and communication style
|
|
116
|
+
- **Lessons learned** — A living record of past mistakes and their fixes, so Claude doesn't repeat them
|
|
117
|
+
- **Task tracking** — Priority-based TODOs with blockers and dependencies
|
|
118
|
+
|
|
119
|
+
### The Problem It Solves
|
|
120
|
+
|
|
121
|
+
Without persistent context, Claude:
|
|
122
|
+
- Loses crucial knowledge between sessions
|
|
123
|
+
- Repeats the same mistakes
|
|
124
|
+
- Forgets your preferences and conventions
|
|
125
|
+
- Can't resume interrupted work
|
|
126
|
+
- Has no enforceable behavioral constraints
|
|
127
|
+
|
|
128
|
+
Anchor fixes all of this with a structured set of markdown templates that Claude reads at session start.
|
|
129
|
+
|
|
130
|
+
## Templates
|
|
131
|
+
|
|
132
|
+
[Back to top](#table-of-contents)
|
|
133
|
+
|
|
134
|
+
### Minimal Setup (Simple Projects)
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
your-project/
|
|
138
|
+
├── CLAUDE.md # Your existing project docs
|
|
139
|
+
├── _GOLDEN-RULES.md # Immutable rules
|
|
140
|
+
└── _TODOS.md # Active tasks
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Full Setup (Complex Projects)
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
your-project/
|
|
147
|
+
├── CLAUDE.md # Project context (with load order block)
|
|
148
|
+
├── _GOLDEN-RULES.md # Immutable rules (read twice per session)
|
|
149
|
+
├── _TODOS.md # Active tasks and priorities
|
|
150
|
+
├── _LESSONS-LEARNED.md # Past mistakes and fixes
|
|
151
|
+
├── _CONVERSATION-PREFERENCES.md # Output formatting and communication style
|
|
152
|
+
├── _LONG-TERM-MEMORY.md # Persistent memory (NEVER delete)
|
|
153
|
+
├── _SHORT-TERM-MEMORY.md # Session context (delete when done)
|
|
154
|
+
└── _SYSTEM_ARCHITECTURE.md # Technical diagrams and system design
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Session Load Order
|
|
158
|
+
|
|
159
|
+
[Back to top](#table-of-contents)
|
|
160
|
+
|
|
161
|
+
The CLAUDE.md template includes a mandatory startup block. When Claude enters a project with Anchor files, it reads them in this exact sequence:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
1. _GOLDEN-RULES.md <- Security rules (BINDING)
|
|
165
|
+
2. _TODOS.md <- Know what's pending
|
|
166
|
+
3. _LESSONS-LEARNED.md <- Avoid past mistakes
|
|
167
|
+
4. _CONVERSATION-PREFERENCES.md <- Output formatting
|
|
168
|
+
5. _GOLDEN-RULES.md <- Re-read (reinforce)
|
|
169
|
+
6. CLAUDE.md <- Full project context
|
|
170
|
+
7. BEGIN conversation
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Why read GOLDEN-RULES twice?** In long contexts, content read early can get "forgotten" as the context window fills. Re-reading critical rules last keeps them fresh and prevents behavioral drift during the session.
|
|
174
|
+
|
|
175
|
+
## Template Overview
|
|
176
|
+
|
|
177
|
+
[Back to top](#table-of-contents)
|
|
178
|
+
|
|
179
|
+
| Template | Purpose | Lifecycle |
|
|
180
|
+
|----------|---------|-----------|
|
|
181
|
+
| `_GOLDEN-RULES.md` | Immutable constraints — things Claude must NEVER/ALWAYS do | Permanent. Updated when new rules are needed. |
|
|
182
|
+
| `_TODOS.md` | Active tasks with priorities, blockers, and dependencies | Ongoing. Tasks move from pending to completed. |
|
|
183
|
+
| `_LESSONS-LEARNED.md` | Documented mistakes with root cause and prevention | Permanent. Add entries immediately when issues are discovered. |
|
|
184
|
+
| `_CONVERSATION-PREFERENCES.md` | Output formatting, colors, progress bars, verbosity | Permanent. Adjusted to match your communication style. |
|
|
185
|
+
| `_LONG-TERM-MEMORY.md` | Persistent knowledge: user identity, system config, code style, decisions | **NEVER delete.** Accumulates over months/years. |
|
|
186
|
+
| `_SHORT-TERM-MEMORY.md` | Session context: current task, progress, what to resume | **Delete when task is complete.** Prevents stale context. |
|
|
187
|
+
| `_SYSTEM_ARCHITECTURE.md` | ASCII diagrams, data flows, component maps, security model | On-demand reference. Updated when architecture changes. |
|
|
188
|
+
|
|
189
|
+
### Memory Model
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
_LONG-TERM-MEMORY.md _SHORT-TERM-MEMORY.md
|
|
193
|
+
- NEVER delete - DELETE when task complete
|
|
194
|
+
- Accumulates over time - Temporary session state
|
|
195
|
+
- User preferences, decisions - Current task progress
|
|
196
|
+
- System configuration - Reboot/restart status
|
|
197
|
+
- Always available to Claude - Prevents stale context
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Customization Guide
|
|
201
|
+
|
|
202
|
+
[Back to top](#table-of-contents)
|
|
203
|
+
|
|
204
|
+
All template files use placeholder syntax:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
[PROJECT_NAME] — Your project name
|
|
208
|
+
[DESCRIPTION] — Brief description
|
|
209
|
+
[DATE] — Current date
|
|
210
|
+
[PATH] — File/folder paths
|
|
211
|
+
[COMMAND] — CLI commands
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Tips
|
|
215
|
+
|
|
216
|
+
1. **_GOLDEN-RULES.md** — Be specific. Vague rules get ignored. Include "why" for each rule.
|
|
217
|
+
2. **_TODOS.md** — Keep it current. Stale TODOs confuse Claude about priorities.
|
|
218
|
+
3. **_LESSONS-LEARNED.md** — Add entries immediately when you discover gotchas. Future you will thank past you.
|
|
219
|
+
4. **_CONVERSATION-PREFERENCES.md** — Include visual examples of your preferred output format.
|
|
220
|
+
5. **_LONG-TERM-MEMORY.md** — Start with your identity, system environment, and code style. It grows naturally over time.
|
|
221
|
+
6. **_SHORT-TERM-MEMORY.md** — Create one when you need to pause work. Delete it when you resume and finish.
|
|
222
|
+
7. **_SYSTEM_ARCHITECTURE.md** — ASCII diagrams are universally understood. Use them.
|
|
223
|
+
|
|
224
|
+
## Naming Conventions
|
|
225
|
+
|
|
226
|
+
[Back to top](#table-of-contents)
|
|
227
|
+
|
|
228
|
+
| Pattern | Meaning | Example |
|
|
229
|
+
|---------|---------|---------|
|
|
230
|
+
| `ALLCAPS.md` | Core documentation | `CLAUDE.md`, `TODOS.md` |
|
|
231
|
+
| `_UNDERSCORE.md` | Supporting/reference docs | `_SYSTEM_ARCHITECTURE.md` |
|
|
232
|
+
| `HYPHENATED.md` | Multi-word names | `GOLDEN-RULES.md`, `LESSONS-LEARNED.md` |
|
|
233
|
+
|
|
234
|
+
The underscore prefix keeps supporting files visually grouped at the top of directory listings.
|
|
235
|
+
|
|
236
|
+
## Companion Project: Claude Conductor
|
|
237
|
+
|
|
238
|
+
[Back to top](#table-of-contents)
|
|
239
|
+
|
|
240
|
+
**Two repos, two tools, complementary not competitive.**
|
|
241
|
+
|
|
242
|
+
Anchor is the **behavioral brain** — it manages Claude's rules, memory, conversation preferences, and session continuity. It tells Claude *how to think and behave*.
|
|
243
|
+
|
|
244
|
+
[Claude Conductor](https://github.com/superbasicstudio/claude-conductor) is the **codebase brain** — it documents your project's architecture, APIs, build systems, errors, and development history. It tells Claude *what your project is*.
|
|
245
|
+
|
|
246
|
+
Together they give Claude full context — what the project is AND how to work on it.
|
|
247
|
+
|
|
248
|
+
| | Conductor | Anchor |
|
|
249
|
+
|---|---|---|
|
|
250
|
+
| **Focus** | Codebase documentation | AI behavior and memory |
|
|
251
|
+
| **Generates** | ARCHITECTURE.md, BUILD.md, API.md, JOURNAL.md | _GOLDEN-RULES.md, _LONG-TERM-MEMORY.md, _TODOS.md |
|
|
252
|
+
| **Delivery** | `npx claude-conductor` (automated CLI) | Copy templates into project |
|
|
253
|
+
| **Answers** | "What is this codebase?" | "How should Claude behave?" |
|
|
254
|
+
|
|
255
|
+
A project can use one or both. They don't overlap — they stack.
|
|
256
|
+
|
|
257
|
+
## Contributing
|
|
258
|
+
|
|
259
|
+
[Back to top](#table-of-contents)
|
|
260
|
+
|
|
261
|
+
We welcome contributions! If you have ideas for new templates, improvements to existing ones, or better documentation:
|
|
262
|
+
|
|
263
|
+
1. Fork the repository
|
|
264
|
+
2. Create a feature branch
|
|
265
|
+
3. Make your changes
|
|
266
|
+
4. Submit a pull request
|
|
267
|
+
|
|
268
|
+
Please keep templates framework-agnostic — they should work with any project in any language.
|
|
269
|
+
|
|
270
|
+
## Privacy & Security
|
|
271
|
+
|
|
272
|
+
[Back to top](#table-of-contents)
|
|
273
|
+
|
|
274
|
+
**Claude Anchor is a collection of markdown templates. It:**
|
|
275
|
+
- Has no executable code
|
|
276
|
+
- Makes zero network requests
|
|
277
|
+
- Has no dependencies
|
|
278
|
+
- Has no telemetry or analytics
|
|
279
|
+
- Runs entirely on your local machine
|
|
280
|
+
- Never collects or transmits any data
|
|
281
|
+
|
|
282
|
+
The `_LONG-TERM-MEMORY.md` template includes a warning to NEVER store actual passwords or secrets. Follow this guidance.
|
|
283
|
+
|
|
284
|
+
## License
|
|
285
|
+
|
|
286
|
+
[Back to top](#table-of-contents)
|
|
287
|
+
|
|
288
|
+
BSD 2-Clause (c) Super Basic Studio
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
Made with love by [Super Basic Studio](https://superbasic.studio)
|
|
293
|
+
|
|
294
|
+
## Keywords
|
|
295
|
+
|
|
296
|
+
claude, claude code, claude anchor, ai memory, ai context, persistent memory, rules framework, claude code framework, vibe coding, super basic studio
|
package/bin/init.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
|
|
8
|
+
const packageJson = require('../package.json');
|
|
9
|
+
|
|
10
|
+
const program = new Command();
|
|
11
|
+
|
|
12
|
+
// Template definitions
|
|
13
|
+
const MINIMAL_TEMPLATES = [
|
|
14
|
+
{ src: 'CLAUDE.md', desc: 'Project context with session load order' },
|
|
15
|
+
{ src: '_GOLDEN-RULES.md', desc: 'Immutable rules (read twice per session)' },
|
|
16
|
+
{ src: '_TODOS.md', desc: 'Priority-based task tracking' }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const FULL_TEMPLATES = [
|
|
20
|
+
...MINIMAL_TEMPLATES,
|
|
21
|
+
{ src: '_LESSONS-LEARNED.md', desc: 'Problem/Cause/Solution/Prevention patterns' },
|
|
22
|
+
{ src: '_CONVERSATION-PREFERENCES.md', desc: 'Output formatting and communication style' },
|
|
23
|
+
{ src: '_LONG-TERM-MEMORY.md', desc: 'Persistent memory (NEVER delete)' },
|
|
24
|
+
{ src: '_SHORT-TERM-MEMORY.md', desc: 'Session context (delete when done)' },
|
|
25
|
+
{ src: '_SYSTEM_ARCHITECTURE.md', desc: 'Technical diagrams and system design' }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
program
|
|
29
|
+
.name('claude-anchor')
|
|
30
|
+
.description('Claude Anchor - Persistent memory and behavioral context for Claude Code')
|
|
31
|
+
.version(packageJson.version);
|
|
32
|
+
|
|
33
|
+
program
|
|
34
|
+
.command('init [target-dir]', { isDefault: true })
|
|
35
|
+
.description('Copy Anchor templates into your project')
|
|
36
|
+
.option('-f, --force', 'Overwrite existing files')
|
|
37
|
+
.option('--full', 'Copy all 8 templates (default: 3 essential templates)')
|
|
38
|
+
.addHelpText('after', `
|
|
39
|
+
Examples:
|
|
40
|
+
$ npx claude-anchor # Copy 3 essential templates
|
|
41
|
+
$ npx claude-anchor --full # Copy all 8 templates
|
|
42
|
+
$ npx claude-anchor ./my-project # Copy into specific directory
|
|
43
|
+
$ npx claude-anchor --force # Overwrite existing files
|
|
44
|
+
|
|
45
|
+
Essential templates (default):
|
|
46
|
+
- CLAUDE.md (session load order + project context)
|
|
47
|
+
- _GOLDEN-RULES.md (immutable constraints)
|
|
48
|
+
- _TODOS.md (task tracking)
|
|
49
|
+
|
|
50
|
+
Full template set (--full):
|
|
51
|
+
All essential templates plus:
|
|
52
|
+
- _LESSONS-LEARNED.md, _CONVERSATION-PREFERENCES.md
|
|
53
|
+
- _LONG-TERM-MEMORY.md, _SHORT-TERM-MEMORY.md
|
|
54
|
+
- _SYSTEM_ARCHITECTURE.md`)
|
|
55
|
+
.action(async (targetDir, options) => {
|
|
56
|
+
try {
|
|
57
|
+
const dir = targetDir || '.';
|
|
58
|
+
await initializeAnchor(dir, options);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(chalk.red('Error:'), error.message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
program.parse(process.argv);
|
|
66
|
+
|
|
67
|
+
async function initializeAnchor(targetDir, options) {
|
|
68
|
+
const templatesDir = path.join(__dirname, '..', 'templates');
|
|
69
|
+
const targetPath = path.resolve(targetDir);
|
|
70
|
+
const templates = options.full ? FULL_TEMPLATES : MINIMAL_TEMPLATES;
|
|
71
|
+
const mode = options.full ? 'full' : 'essential';
|
|
72
|
+
|
|
73
|
+
// Banner
|
|
74
|
+
console.log('');
|
|
75
|
+
console.log(chalk.cyan.bold(' ┌─────────────────────────────────────────────┐'));
|
|
76
|
+
console.log(chalk.cyan.bold(' │ │'));
|
|
77
|
+
console.log(chalk.cyan.bold(' │') + chalk.white.bold(' Claude Anchor ') + chalk.cyan.bold('│'));
|
|
78
|
+
console.log(chalk.cyan.bold(' │') + chalk.gray(' Behavioral Context Framework ') + chalk.cyan.bold('│'));
|
|
79
|
+
console.log(chalk.cyan.bold(' │ │'));
|
|
80
|
+
console.log(chalk.cyan.bold(' └─────────────────────────────────────────────┘'));
|
|
81
|
+
console.log('');
|
|
82
|
+
console.log(chalk.gray(' Made with love by ') + chalk.blue.underline('Super Basic Studio'));
|
|
83
|
+
console.log(chalk.gray(' ') + chalk.blue.underline('https://superbasic.studio'));
|
|
84
|
+
console.log('');
|
|
85
|
+
|
|
86
|
+
// Mode display
|
|
87
|
+
if (options.full) {
|
|
88
|
+
console.log(chalk.blue('+---------------------------------------+'));
|
|
89
|
+
console.log(chalk.blue('|') + chalk.blue.bold(' FULL: All 8 behavioral templates ') + chalk.blue('|'));
|
|
90
|
+
console.log(chalk.blue('+---------------------------------------+'));
|
|
91
|
+
console.log(chalk.gray(' Rules, memory, preferences, architecture'));
|
|
92
|
+
console.log(chalk.gray(' Complete behavioral context for Claude'));
|
|
93
|
+
} else {
|
|
94
|
+
console.log(chalk.green('+---------------------------------------+'));
|
|
95
|
+
console.log(chalk.green('|') + chalk.green.bold(' ESSENTIAL: 3 core templates ') + chalk.green('|'));
|
|
96
|
+
console.log(chalk.green('+---------------------------------------+'));
|
|
97
|
+
console.log(chalk.gray(' CLAUDE.md + Golden Rules + TODOs'));
|
|
98
|
+
console.log(chalk.gray(' Use --full for all 8 templates'));
|
|
99
|
+
}
|
|
100
|
+
console.log('');
|
|
101
|
+
|
|
102
|
+
if (options.force) {
|
|
103
|
+
console.log(chalk.yellow(' ⚠ Force mode: existing files will be overwritten'));
|
|
104
|
+
console.log('');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(chalk.blue.bold('[*] Initializing Anchor templates...'));
|
|
108
|
+
console.log(chalk.gray(` Target: ${targetPath}`));
|
|
109
|
+
console.log(chalk.gray(` Mode: ${mode} (${templates.length} templates)`));
|
|
110
|
+
console.log('');
|
|
111
|
+
|
|
112
|
+
// Ensure target directory exists
|
|
113
|
+
await fs.ensureDir(targetPath);
|
|
114
|
+
|
|
115
|
+
let created = 0;
|
|
116
|
+
let skipped = 0;
|
|
117
|
+
let overwritten = 0;
|
|
118
|
+
|
|
119
|
+
for (const template of templates) {
|
|
120
|
+
const srcPath = path.join(templatesDir, template.src);
|
|
121
|
+
const destPath = path.join(targetPath, template.src);
|
|
122
|
+
const exists = await fs.pathExists(destPath);
|
|
123
|
+
|
|
124
|
+
if (exists && !options.force) {
|
|
125
|
+
console.log(chalk.yellow(' [SKIP] ') + chalk.gray(template.src) + chalk.yellow(' (already exists)'));
|
|
126
|
+
skipped++;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
await fs.copy(srcPath, destPath, { overwrite: options.force });
|
|
132
|
+
|
|
133
|
+
if (exists && options.force) {
|
|
134
|
+
console.log(chalk.blue(' [OVERWRITE] ') + chalk.white(template.src));
|
|
135
|
+
overwritten++;
|
|
136
|
+
} else {
|
|
137
|
+
console.log(chalk.green(' [CREATE] ') + chalk.white(template.src) + chalk.gray(` — ${template.desc}`));
|
|
138
|
+
created++;
|
|
139
|
+
}
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(chalk.red(` [ERROR] ${template.src}: ${err.message}`));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Summary
|
|
146
|
+
console.log('');
|
|
147
|
+
console.log(chalk.cyan('─'.repeat(47)));
|
|
148
|
+
console.log('');
|
|
149
|
+
|
|
150
|
+
if (created > 0) {
|
|
151
|
+
console.log(chalk.green.bold(` ✓ Created ${created} template${created !== 1 ? 's' : ''}`));
|
|
152
|
+
}
|
|
153
|
+
if (overwritten > 0) {
|
|
154
|
+
console.log(chalk.blue.bold(` ✓ Overwrote ${overwritten} template${overwritten !== 1 ? 's' : ''}`));
|
|
155
|
+
}
|
|
156
|
+
if (skipped > 0) {
|
|
157
|
+
console.log(chalk.yellow(` ○ Skipped ${skipped} (use --force to overwrite)`));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
console.log('');
|
|
161
|
+
|
|
162
|
+
// Next steps
|
|
163
|
+
if (created > 0 || overwritten > 0) {
|
|
164
|
+
console.log(chalk.white.bold(' Next steps:'));
|
|
165
|
+
console.log(chalk.gray(' 1. Edit each template — replace [PLACEHOLDERS] with your project details'));
|
|
166
|
+
console.log(chalk.gray(' 2. Customize _GOLDEN-RULES.md with your project\'s constraints'));
|
|
167
|
+
console.log(chalk.gray(' 3. Claude reads these files automatically at session start'));
|
|
168
|
+
console.log('');
|
|
169
|
+
|
|
170
|
+
if (!options.full) {
|
|
171
|
+
console.log(chalk.gray(' Want more? Run ') + chalk.cyan('npx claude-anchor --full') + chalk.gray(' for all 8 templates'));
|
|
172
|
+
console.log('');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
console.log(chalk.gray(' Companion project: ') + chalk.blue.underline('https://github.com/superbasicstudio/claude-conductor'));
|
|
176
|
+
console.log(chalk.gray(' Conductor documents your codebase — Anchor manages Claude\'s behavior'));
|
|
177
|
+
} else {
|
|
178
|
+
console.log(chalk.gray(' All templates already exist. Use --force to overwrite.'));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
console.log('');
|
|
182
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-anchor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Persistent memory, enforceable rules, and behavioral consistency for Claude Code",
|
|
5
|
+
"bin": {
|
|
6
|
+
"claude-anchor": "bin/init.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"test:watch": "jest --watch",
|
|
11
|
+
"prepublishOnly": "npm test"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"claude",
|
|
15
|
+
"claude code",
|
|
16
|
+
"claude anchor",
|
|
17
|
+
"ai memory",
|
|
18
|
+
"ai context",
|
|
19
|
+
"persistent memory",
|
|
20
|
+
"rules framework",
|
|
21
|
+
"claude code framework",
|
|
22
|
+
"behavioral context",
|
|
23
|
+
"vibe coding",
|
|
24
|
+
"super basic studio"
|
|
25
|
+
],
|
|
26
|
+
"author": "Super Basic Studio, LLC (https://superbasic.studio)",
|
|
27
|
+
"license": "BSD-2-Clause",
|
|
28
|
+
"files": [
|
|
29
|
+
"templates/",
|
|
30
|
+
"bin/",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"chalk": "^4.1.2",
|
|
35
|
+
"commander": "^11.0.0",
|
|
36
|
+
"fs-extra": "^11.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"jest": "^29.0.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=16.0.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/superbasicstudio/claude-anchor.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/superbasicstudio/claude-anchor/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/superbasicstudio/claude-anchor#readme",
|
|
52
|
+
"funding": [
|
|
53
|
+
{
|
|
54
|
+
"type": "github",
|
|
55
|
+
"url": "https://github.com/superbasicstudio"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "patreon",
|
|
59
|
+
"url": "https://patreon.com/superbasicstudio"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|