@link-assistant/claude-profiles 1.2.3

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 ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
package/README.md ADDED
@@ -0,0 +1,533 @@
1
+ [![npm](https://img.shields.io/npm/v/@link-assistant/claude-profiles.svg)](https://npmjs.com/@link-assistant/claude-profiles)
2
+ [![License](https://img.shields.io/badge/license-Unlicense-blue.svg)](https://github.com/link-assistant/claude-profiles/blob/main/LICENSE)
3
+ [![GitHub stars](https://img.shields.io/github/stars/link-assistant/claude-profiles?style=social)](https://github.com/link-assistant/claude-profiles/stargazers)
4
+
5
+ [![Open in Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-f29718?logo=gitpod)](https://gitpod.io/#https://github.com/link-assistant/claude-profiles)
6
+ [![Open in GitHub Codespaces](https://img.shields.io/badge/GitHub%20Codespaces-Open-181717?logo=github)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=link-assistant/claude-profiles)
7
+
8
+ # Claude Profiles
9
+
10
+ A powerful CLI tool to manage multiple Claude configuration profiles using GitHub Gists as secure cloud storage. This tool enables you to store, restore, and synchronize Claude configurations across machines, supporting both macOS and Linux platforms with automatic credential format conversion.
11
+
12
+ Perfect for developers working with:
13
+ - **Cloud Development Environments**: GitPod, GitHub Codespaces, and other cloud IDEs
14
+ - **Multiple Devices**: Seamlessly sync profiles between your macOS laptop, Linux desktop, and cloud workspaces
15
+ - **Team Environments**: Share configurations across team development environments
16
+ - **Ephemeral Environments**: Quickly restore your Claude setup in temporary containers or VMs
17
+
18
+ ## Features
19
+
20
+ ### Core Functionality
21
+ - **Profile Management**: Store, restore, and delete multiple Claude configuration profiles
22
+ - **Cloud Storage**: Uses GitHub Gists (secret) for secure profile storage
23
+ - **Cross-Platform Support**: Works on macOS and Linux with automatic credential format conversion
24
+ - **macOS Keychain Integration**: Fully supports macOS Keychain credentials storage and retrieval
25
+ - **Watch Mode**: Automatically saves configuration changes to a profile with intelligent debouncing
26
+ - **Profile Verification**: Validates profile integrity before restoration
27
+ - **No Dependencies**: Uses dynamic module loading (use-m) - no package.json required
28
+ - **Comprehensive Logging**: Optional file logging and verbose mode for debugging
29
+
30
+ ### What Gets Backed Up
31
+ - `~/.claude/` directory - **entire directory with all subdirectories and files**:
32
+ - IDE lock files (`ide/*.lock`)
33
+ - Plugin configurations (`plugins/`)
34
+ - Project history and conversations (`projects/`)
35
+ - Todo items (`todos/`)
36
+ - Shell snapshots (`shell-snapshots/`)
37
+ - Settings and statistics (`settings.json`, `statsig/`)
38
+ - All other Claude-related data
39
+ - `~/.claude.json` (main configuration file)
40
+ - `~/.claude.json.backup` (configuration backup)
41
+ - macOS Keychain credentials (exported to archive as `.macos.credentials.json`)
42
+ - Linux credentials file (`~/.claude/.credentials.json`)
43
+
44
+ ### Restore Behavior
45
+ **Important**: When restoring a profile:
46
+ - **Files are overwritten**: Existing files with the same name will be replaced
47
+ - **New files are added**: Files from the backup are added to existing directories
48
+ - **Existing files are preserved**: Files not in the backup remain untouched
49
+ - **Merge behavior**: The restore process merges the backup with existing content:
50
+ - Project conversations are merged (existing conversations remain)
51
+ - Todo items are merged (existing todos remain)
52
+ - Settings files (`settings.json`, `config.json`) are overwritten with backup versions
53
+ - Lock files and temporary files are overwritten
54
+
55
+ ## Installation
56
+
57
+ ### Prerequisites
58
+ - Node.js (v18 or higher)
59
+ - GitHub CLI (`gh`) authenticated with gist permissions
60
+ - `unzip` command (pre-installed on macOS, may need installation on Linux)
61
+
62
+ ### Install via Package Manager (Recommended)
63
+
64
+ #### Using Bun (Fastest)
65
+ ```bash
66
+ bun install -g @link-assistant/claude-profiles
67
+ ```
68
+
69
+ #### Using npm
70
+ ```bash
71
+ npm install -g @link-assistant/claude-profiles
72
+ ```
73
+
74
+ After installation, the tool will be available globally as `claude-profiles`:
75
+
76
+ ```bash
77
+ claude-profiles --help
78
+ ```
79
+
80
+ ### Install from Source
81
+
82
+ 1. **Install GitHub CLI** (if not already installed):
83
+ ```bash
84
+ # macOS
85
+ brew install gh
86
+
87
+ # Ubuntu/Debian
88
+ sudo apt install gh
89
+
90
+ # Other Linux distributions
91
+ # Visit: https://github.com/cli/cli#installation
92
+ ```
93
+
94
+ 2. **Authenticate with GitHub**:
95
+ ```bash
96
+ gh auth login -s gist
97
+ ```
98
+ Follow the prompts and ensure you grant the `gist` scope for creating and managing gists.
99
+
100
+ 3. **Clone or download the tool**:
101
+ ```bash
102
+ # Option A: Clone the repository
103
+ git clone https://github.com/link-assistant/claude-profiles.git
104
+ cd claude-profiles
105
+ chmod +x claude-profiles.mjs
106
+
107
+ # Option B: Download directly
108
+ curl -O https://raw.githubusercontent.com/link-assistant/claude-profiles/main/claude-profiles.mjs
109
+ chmod +x claude-profiles.mjs
110
+ ```
111
+
112
+ 4. **Verify installation**:
113
+ ```bash
114
+ # If installed via npm
115
+ claude-profiles --list
116
+
117
+ # If using from source
118
+ ./claude-profiles.mjs --list
119
+ ```
120
+
121
+ ## Usage
122
+
123
+ ### Basic Commands
124
+
125
+ #### List All Profiles
126
+ ```bash
127
+ claude-profiles --list
128
+ # or
129
+ claude-profiles -l
130
+ ```
131
+
132
+ #### Store Current Configuration
133
+ ```bash
134
+ claude-profiles --store work
135
+ # or
136
+ claude-profiles --save work
137
+ # or
138
+ claude-profiles -s work
139
+ ```
140
+
141
+ #### Restore a Profile
142
+ ```bash
143
+ claude-profiles --restore personal
144
+ # or
145
+ claude-profiles -r personal
146
+ ```
147
+
148
+ #### Delete a Profile
149
+ ```bash
150
+ claude-profiles --delete old-profile
151
+ # or
152
+ claude-profiles -d old-profile
153
+ ```
154
+
155
+ #### Verify Profile Integrity
156
+ ```bash
157
+ claude-profiles --verify work
158
+ # or
159
+ claude-profiles -v work
160
+ ```
161
+
162
+ **Note**: If you're using the tool from source instead of npm, prefix commands with `./` like `./claude-profiles.mjs --list`
163
+
164
+ ### Advanced Features
165
+
166
+ #### Watch Mode
167
+ Automatically saves configuration changes to a profile with a 30-second throttle:
168
+ ```bash
169
+ claude-profiles --watch work
170
+
171
+ # With verbose logging
172
+ claude-profiles --watch work --verbose
173
+
174
+ # With file logging
175
+ claude-profiles --watch work --log
176
+
177
+ # With custom log file
178
+ claude-profiles --watch work --log=/path/to/log-file.txt
179
+ ```
180
+
181
+ **Watch Mode Features:**
182
+ - Monitors all Claude configuration files for changes
183
+ - Debounced saves (waits 2 seconds after last change)
184
+ - Minimum 30-second interval between saves to prevent excessive updates
185
+ - On macOS, also monitors Keychain credentials changes
186
+ - Graceful shutdown with Ctrl+C
187
+
188
+ #### Verbose Mode
189
+ Enable detailed logging for troubleshooting:
190
+ ```bash
191
+ claude-profiles --store work --verbose
192
+ ```
193
+
194
+ #### File Logging
195
+ Save all output to a log file:
196
+ ```bash
197
+ # Auto-generated filename with timestamp
198
+ claude-profiles --store work --log
199
+
200
+ # Custom log file
201
+ claude-profiles --store work --log=claude-backup.log
202
+ ```
203
+
204
+ ## Profile Names
205
+
206
+ Profile names must follow these rules:
207
+ - Only lowercase letters (a-z)
208
+ - Numbers (0-9)
209
+ - Hyphens (-)
210
+ - Examples: `work`, `personal`, `client-1`, `dev-2024`
211
+
212
+ ## Cross-Platform Support
213
+
214
+ ### macOS ↔ Linux Profile Compatibility
215
+
216
+ The tool automatically handles credential format conversion between platforms:
217
+
218
+ #### macOS → Linux
219
+ When restoring a macOS profile on Linux:
220
+ - Keychain credentials are converted to Linux format
221
+ - Credentials are saved to `~/.claude/.credentials.json`
222
+ - Both old (underscore) and new (claudeAiOauth) formats are supported
223
+
224
+ #### Linux → macOS
225
+ When restoring a Linux profile on macOS:
226
+ - Linux credentials are converted to Keychain format
227
+ - Credentials are stored in macOS Keychain
228
+ - Legacy Linux formats are automatically upgraded
229
+
230
+ ### Credential Formats
231
+
232
+ The tool supports multiple credential formats:
233
+
234
+ 1. **Modern Format** (with claudeAiOauth wrapper):
235
+ ```json
236
+ {
237
+ "claudeAiOauth": {
238
+ "accessToken": "...",
239
+ "refreshToken": "...",
240
+ "expiresAt": "...",
241
+ "scopes": ["user:inference"],
242
+ "subscriptionType": "max"
243
+ }
244
+ }
245
+ ```
246
+
247
+ 2. **Legacy Linux Format** (underscore format):
248
+ ```json
249
+ {
250
+ "access_token": "...",
251
+ "refresh_token": "...",
252
+ "expiry_date": "...",
253
+ "scopes": ["user:inference"],
254
+ "subscriptionType": "max"
255
+ }
256
+ ```
257
+
258
+ All formats are automatically detected and converted as needed.
259
+
260
+ ## Error Handling & Edge Cases
261
+
262
+ ### GitHub Authentication Issues
263
+
264
+ #### Missing Gist Scope
265
+ **Problem**: Token lacks gist permissions
266
+ ```
267
+ ❌ Permission error creating gist
268
+ ```
269
+ **Solution**:
270
+ ```bash
271
+ gh auth refresh -s gist
272
+ ```
273
+
274
+ #### Wrong Account
275
+ **Problem**: Gist owned by different GitHub account
276
+ ```
277
+ ❌ HTTP 409 - Gist cannot be updated
278
+ ```
279
+ **Solution**:
280
+ ```bash
281
+ # Check current account
282
+ gh auth status
283
+
284
+ # Re-login with correct account
285
+ gh auth login
286
+ ```
287
+
288
+ #### Rate Limiting
289
+ **Problem**: Too many API requests
290
+ ```
291
+ ⚠️ GitHub API rate limit exceeded
292
+ ```
293
+ **Solution**: Wait a few minutes and try again
294
+
295
+ ### Profile Issues
296
+
297
+ #### Missing Essential Files
298
+ **Problem**: Claude configuration incomplete
299
+ ```
300
+ ❌ Cannot create profile - essential files are missing
301
+ ```
302
+ **Solution**:
303
+ - Ensure Claude is properly configured
304
+ - Use Claude at least once to generate config files
305
+ - Check that `~/.claude/` directory exists
306
+
307
+ #### Large Profiles
308
+ **Problem**: Profile exceeds GitHub's 10MB gist limit
309
+ ```
310
+ ❌ Profile is too large for GitHub Gist (>10MB)
311
+ ```
312
+ **Solution**:
313
+ - Clean up `~/.claude/` directory
314
+ - Remove unnecessary files or cache
315
+ - Consider splitting into multiple profiles
316
+
317
+ #### Corrupted Profile
318
+ **Problem**: Profile verification fails
319
+ ```
320
+ ❌ Cannot restore profile - verification failed
321
+ ```
322
+ **Solution**:
323
+ - Use `--verify` to check profile integrity
324
+ - Create a new backup with `--store`
325
+ - Check if the profile was created on a different platform
326
+
327
+ ### Platform-Specific Issues
328
+
329
+ #### macOS Keychain Access
330
+ **Problem**: Cannot access Keychain
331
+ ```
332
+ ⚠️ No credentials found in macOS Keychain
333
+ ```
334
+ **Solution**:
335
+ - Ensure Claude has been used at least once
336
+ - Check Keychain Access app for "Claude Code-credentials"
337
+ - Grant terminal access to Keychain if prompted
338
+
339
+ #### Linux Missing unzip
340
+ **Problem**: unzip command not found
341
+ ```
342
+ 📦 The unzip command is required but not installed
343
+ ```
344
+ **Solution**:
345
+ ```bash
346
+ # Ubuntu/Debian
347
+ sudo apt-get install unzip
348
+
349
+ # Alpine
350
+ apk add unzip
351
+
352
+ # RHEL/CentOS
353
+ sudo yum install unzip
354
+ ```
355
+
356
+ ### Network Issues
357
+
358
+ #### Connection Problems
359
+ **Problem**: Cannot connect to GitHub
360
+ ```
361
+ 🌐 Network error while accessing GitHub
362
+ ```
363
+ **Solution**:
364
+ - Check internet connection
365
+ - Verify GitHub is accessible: `ping github.com`
366
+ - Check proxy settings if behind firewall
367
+
368
+ ### File System Issues
369
+
370
+ #### Permission Denied
371
+ **Problem**: Cannot read/write Claude files
372
+ ```
373
+ 📝 Permission denied
374
+ ```
375
+ **Solution**:
376
+ ```bash
377
+ # Check permissions
378
+ ls -la ~/.claude/
379
+
380
+ # Fix ownership (if needed)
381
+ chown -R $USER:$USER ~/.claude
382
+ ```
383
+
384
+ #### Disk Space
385
+ **Problem**: No space for extraction
386
+ ```
387
+ 💾 No space left on device
388
+ ```
389
+ **Solution**:
390
+ - Free up disk space
391
+ - Use a different temp directory: `export TMPDIR=/path/to/space`
392
+
393
+ ## Security Considerations
394
+
395
+ 1. **Gist Privacy**: All profiles are stored as **secret** gists (not public)
396
+ 2. **Credential Security**:
397
+ - macOS: Stored securely in Keychain
398
+ - Linux: Stored in user-only readable file
399
+ - Transit: Base64 encoded (not encrypted)
400
+ 3. **GitHub Authentication**: Uses GitHub CLI's secure token storage
401
+ 4. **File Permissions**: Restored files maintain appropriate permissions
402
+
403
+ ## Troubleshooting
404
+
405
+ ### Enable Debug Output
406
+ ```bash
407
+ # Verbose mode for detailed logging
408
+ claude-profiles --store work --verbose
409
+
410
+ # Save debug output to file
411
+ claude-profiles --store work --verbose --log=debug.log
412
+ ```
413
+
414
+ ### Check GitHub Status
415
+ ```bash
416
+ # Verify GitHub CLI authentication
417
+ gh auth status
418
+
419
+ # Test gist access
420
+ echo "test" | gh gist create -
421
+
422
+ # List your gists
423
+ gh gist list --limit 5
424
+ ```
425
+
426
+ ### Manual Gist Management
427
+ ```bash
428
+ # View gist contents
429
+ gh gist list | grep claude-profiles
430
+ gh gist view <GIST_ID>
431
+
432
+ # Delete gist entirely (removes all profiles)
433
+ gh gist delete <GIST_ID>
434
+ ```
435
+
436
+ ### Common Solutions
437
+
438
+ 1. **First Time Setup**:
439
+ ```bash
440
+ # 1. Install the tool (bun is faster)
441
+ bun install -g @link-assistant/claude-profiles
442
+ # or: npm install -g @link-assistant/claude-profiles
443
+
444
+ # 2. Authenticate GitHub CLI
445
+ gh auth login -s gist
446
+
447
+ # 3. Create your first profile
448
+ claude-profiles --store default
449
+
450
+ # 4. List profiles to confirm
451
+ claude-profiles --list
452
+ ```
453
+
454
+ 2. **Switching Between Profiles**:
455
+ ```bash
456
+ # Save current state
457
+ claude-profiles --store current-work
458
+
459
+ # Switch to different profile
460
+ claude-profiles --restore personal
461
+
462
+ # Later, switch back
463
+ claude-profiles --restore current-work
464
+ ```
465
+
466
+ 3. **Migrating to New Machine**:
467
+ ```bash
468
+ # On old machine
469
+ claude-profiles --store migration
470
+
471
+ # On new machine (after installing and gh auth)
472
+ bun install -g @link-assistant/claude-profiles
473
+ claude-profiles --restore migration
474
+ ```
475
+
476
+ ## Technical Details
477
+
478
+ ### Storage Format
479
+ - Profiles are stored as ZIP archives
480
+ - Archives are base64-encoded for gist compatibility
481
+ - Each profile is a separate file in the gist
482
+ - Gist description: "claude-profiles-backup"
483
+
484
+ ### File Structure in Archive
485
+ ```
486
+ profile.zip.base64
487
+ ├── .claude/ # Complete directory structure
488
+ │ ├── .credentials.json # Linux credentials (if present)
489
+ │ ├── ide/ # IDE lock files
490
+ │ ├── plugins/ # Plugin configurations
491
+ │ │ ├── config.json
492
+ │ │ └── repos/
493
+ │ ├── projects/ # Project conversations
494
+ │ │ └── [project-folders]/ # Individual project histories
495
+ │ ├── settings.json # Claude settings
496
+ │ ├── shell-snapshots/ # Shell session snapshots
497
+ │ ├── statsig/ # Usage statistics
498
+ │ └── todos/ # Todo items
499
+ ├── .claude.json # Main configuration
500
+ ├── .claude.json.backup # Configuration backup
501
+ └── .macos.credentials.json # macOS Keychain export (see note below)
502
+ ```
503
+
504
+ ### macOS Credentials Handling
505
+
506
+ **Important Note about `.macos.credentials.json`**:
507
+ - This is an **internal file** created by the tool, not a Claude system file
508
+ - It only exists within the backup archive stored on GitHub Gist
509
+ - **Purpose**: Exports macOS Keychain credentials for cross-platform compatibility
510
+ - **On restore**:
511
+ - **To macOS**: Credentials are restored directly to Keychain (file is not created on disk)
512
+ - **To Linux**: Credentials are converted and saved as `~/.claude/.credentials.json`
513
+ - This file never appears in your local filesystem on macOS - credentials always stay in Keychain
514
+
515
+ ### Dependencies
516
+ The tool uses dynamic loading via `use-m` for zero-install dependencies:
517
+ - `command-stream@0.7.0` - Shell command execution
518
+ - `yargs@17.7.2` - CLI argument parsing
519
+ - `archiver@7.0.1` - ZIP archive creation
520
+
521
+ ## License
522
+
523
+ This project is released into the public domain under The Unlicense. See [LICENSE](LICENSE) file for details.
524
+
525
+ ## Contributing
526
+
527
+ Contributions are welcome! Please feel free to submit issues or pull requests at:
528
+ https://github.com/link-assistant/claude-profiles
529
+
530
+ ## Support
531
+
532
+ For issues, questions, or feature requests, please open an issue on GitHub:
533
+ https://github.com/link-assistant/claude-profiles/issues