Skip to content

Commit d5c2fe2

Browse files
committed
Address CodeRabbit review findings (1, 2, 6, 7)
- CHANGELOG.md: Add #### Documentation subsection under Changed, add #### Scripts subsection under Removed for consistent structure - CLAUDE.md: Document CLAUDE_AUTH_TOKEN, .credentials.json auto-creation, skip-if-exists behavior, sk-ant-* validation, and named volume persistence - setup-auth.sh: Detect printf subshell write failure — report warning instead of false success when .credentials.json write fails - setup-migrate-claude.sh: Verify cp exit status before printing success — warn if copy failed instead of unconditional "Migration complete" - docs/reference/changelog.md: Mirror CHANGELOG structure fixes Findings 3-5 (feature $HOME fallback) confirmed as false positives: postStartCommand runs as vscode user, CLAUDE_CONFIG_DIR is exported by setup.sh before hooks execute.
1 parent 69ca626 commit d5c2fe2

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

.devcontainer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
- Replaced `setup-symlink-claude.sh` with `setup-migrate-claude.sh` (one-time migration)
2222
- Auto-migrates from `/workspaces/.claude/` if `.credentials.json` present
2323

24+
#### Documentation
25+
- All docs now reference `~/.claude` as default config path
26+
- Added `CLAUDE_AUTH_TOKEN` setup flow to README, configuration reference, and troubleshooting
27+
2428
### Removed
29+
30+
#### Scripts
2531
- `setup-symlink-claude.sh` — no longer needed with native home directory location
2632

2733
## [v1.14.2] - 2026-02-24

.devcontainer/CLAUDE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ Rules in `config/defaults/rules/` deploy to `.claude/rules/` on every container
7777
| Variable | Value |
7878
|----------|-------|
7979
| `CLAUDE_CONFIG_DIR` | `/home/vscode/.claude` |
80+
| `CLAUDE_AUTH_TOKEN` | Long-lived token from `claude setup-token` (optional, via `.secrets` or Codespaces secrets) |
8081
| `ANTHROPIC_MODEL` | `claude-opus-4-6` |
8182
| `WORKSPACE_ROOT` | `/workspaces` |
8283

8384
All experimental feature flags are in `settings.json` under `env`. Setup steps controlled by boolean flags in `.env`.
8485

86+
## Authentication & Persistence
87+
88+
The `~/.claude/` directory is backed by a Docker named volume (`codeforge-claude-config-${devcontainerId}`), persisting config, credentials, and session data across container rebuilds. Each devcontainer instance gets an isolated volume.
89+
90+
**Token authentication:** Set `CLAUDE_AUTH_TOKEN` in `.devcontainer/.secrets` (or as a Codespaces secret) with a long-lived token from `claude setup-token`. On container start, `setup-auth.sh` auto-creates `~/.claude/.credentials.json` with `600` permissions. If `.credentials.json` already exists, token injection is skipped (idempotent). Tokens must match `sk-ant-*` format.
91+
8592
## Modifying Behavior
8693

8794
1. **Change model**: Edit `config/defaults/settings.json``"model"` field

.devcontainer/scripts/setup-auth.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ if [ -n "$CLAUDE_AUTH_TOKEN" ]; then
8989
# Write credentials with restrictive permissions from the start (no race window).
9090
# Uses printf '%s' to avoid shell expansion of token value (defense against
9191
# metacharacters in the token string — backticks, $(), quotes).
92-
( umask 077; printf '{\n "claudeAiOauth": {\n "accessToken": "%s",\n "refreshToken": "%s",\n "expiresAt": 9999999999999,\n "scopes": ["user:inference", "user:profile"]\n }\n}\n' "$CLAUDE_AUTH_TOKEN" "$CLAUDE_AUTH_TOKEN" > "$CLAUDE_CRED_FILE" )
93-
echo "[setup-auth] Claude auth token configured"
94-
AUTH_CONFIGURED=true
92+
if ( umask 077; printf '{\n "claudeAiOauth": {\n "accessToken": "%s",\n "refreshToken": "%s",\n "expiresAt": 9999999999999,\n "scopes": ["user:inference", "user:profile"]\n }\n}\n' "$CLAUDE_AUTH_TOKEN" "$CLAUDE_AUTH_TOKEN" > "$CLAUDE_CRED_FILE" ); then
93+
echo "[setup-auth] Claude auth token configured"
94+
AUTH_CONFIGURED=true
95+
else
96+
echo "[setup-auth] WARNING: Failed to write .credentials.json — check permissions on $CLAUDE_CRED_DIR"
97+
fi
9598
fi
9699
unset CLAUDE_AUTH_TOKEN
97100
else

.devcontainer/scripts/setup-migrate-claude.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ mkdir -p "$NEW_DIR"
3636
# --no-dereference: copy symlinks as symlinks (don't follow them)
3737
# -n: no-clobber (don't overwrite existing files)
3838
# -r: recursive
39-
cp -rn --no-dereference "$OLD_DIR/." "$NEW_DIR/" 2>/dev/null || true
40-
echo "[setup-migrate] Migration complete. You can safely remove /workspaces/.claude/"
39+
if cp -rn --no-dereference "$OLD_DIR/." "$NEW_DIR/" 2>/dev/null; then
40+
echo "[setup-migrate] Migration complete. You can safely remove /workspaces/.claude/"
41+
else
42+
echo "[setup-migrate] WARNING: Some files may not have been copied — verify $NEW_DIR before removing /workspaces/.claude/"
43+
fi

docs/src/content/docs/reference/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ For minor and patch updates, you can usually just rebuild the container. Check t
6868
- Replaced `setup-symlink-claude.sh` with `setup-migrate-claude.sh` (one-time migration)
6969
- Auto-migrates from `/workspaces/.claude/` if `.credentials.json` present
7070

71+
#### Documentation
72+
- All docs now reference `~/.claude` as default config path
73+
- Added `CLAUDE_AUTH_TOKEN` setup flow to README, configuration reference, and troubleshooting
74+
7175
### Removed
76+
77+
#### Scripts
7278
- `setup-symlink-claude.sh` — no longer needed with native home directory location
7379

7480
---

0 commit comments

Comments
 (0)