gstack: artifacts auto-sync silently broken due to unexpanded ~ in double-quoted bash variable assignments
- Dominant language
- TypeScript
- Stars
- 133k
- Forks
- 19.9k
- Avg merge
- 18h 46m
- Merged PRs (30d)
- 26
Description
## Bug: Bash tilde expansion fails inside double-quoted variable assignments in gstack skill preamble, preventing artifacts auto-sync on all skill invocations
### Description
On Windows (Git Bash), the gstack skill preamble's artifacts sync logic silently never runs. The `~` in double-quoted variable assignments is not resolved to the home directory path.
This means `gstack-brain-sync --once` is never called at skill boundaries, so cross-machine artifact synchronization (checkpoints, learnings, timeline, etc.) does not happen automatically.
### Root Cause
In Bash, tilde expansion only occurs when `~` is at the beginning of an unquoted word. Inside double-quoted variable assignments, `~` is treated as a literal character.
Lines 369-370 in every SKILL.md preamble:
```bash
_BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
_BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
```
When `$_BRAIN_CONFIG_BIN` is later invoked:
```bash
_BRAIN_SYNC_MODE=$("$_BRAIN_CONFIG_BIN" get artifacts_sync_mode 2>/dev/null || echo off)
```
The shell tries to execute the literal path `~/.claude/...` (which doesn't exist as a literal file path), the command fails, and `artifacts_sync_mode` falls back to `off`. This causes all subsequent sync conditions to evaluate to false.
The same issue affects the end-of-skill sync commands in the Telemetry section:
```bash
"~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true
```
### Impact
- **Every** gstack skill invocation (`/context-save`, `/qa`, `/ship`, `/plan-*`, `/review`, etc.) silently skips the artifacts sync
- Cross-machine artifact sharing via the gstack artifacts git repo (`gstack-record`) never works automatically
- No user-visible error — all `|| true` / `2>/dev/null` patterns swallow the failure silently
- This has been broken since the artifacts sync feature was introduced
### Affected Files
All 92 SKILL.md files across two directories:
- `~/.claude/skills/*/SKILL.md` (46 files — loaded by Claude Code at runtime)
- `~/.claude/skills/gstack/*/SKILL.md` (46 files — gstack distribution copies)
Affected skills include: autoplan, benchmark, benchmark-models, browse, canary, codex, context-restore, context-save, cso, design-consultation, design-html, design-review, design-shotgun, devex-review, document-generate, document-release, health, investigate, ios-clean, ios-design-review, ios-fix, ios-qa, ios-sync, land-and-deploy, landing-report, learn, make-pdf, office-hours, open-gstack-browser, pair-agent, plan-ceo-review, plan-design-review, plan-devex-review, plan-eng-review, plan-tune, qa, qa-only, retro, review, scrape, setup-browser-cookies, setup-deploy, setup-gbrain, ship, skillify, sync-gbrain
### Fix
Change `"~/.claude/..."` to `"$HOME/.claude/..."` in two places in the preamble template and the end-of-skill telemetry section.
**In the Artifacts Sync preamble section:**
```diff
- _BRAIN_SYNC_BIN="~/.claude/skills/gstack/bin/gstack-brain-sync"
- _BRAIN_CONFIG_BIN="~/.claude/skills/gstack/bin/gstack-config"
+ _BRAIN_SYNC_BIN="$HOME/.claude/skills/gstack/bin/gstack-brain-sync"
+ _BRAIN_CONFIG_BIN="$HOME/.claude/skills/gstack/bin/gstack-config"
```
**In the end-of-skill Telemetry section:**
```diff
- "~/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true
+ "$HOME/.claude/skills/gstack/bin/gstack-brain-sync" --once 2>/dev/null || true
```
### Verification
After fixing, the preamble correctly shows `ARTIFACTS_SYNC: mode=full | ...` instead of `ARTIFACTS_SYNC: off`. Git status on `~/.gstack/` confirms that `gstack-brain-sync --once` modified `learnings.jsonl`, `timeline.jsonl`, and `.brain-queue.jsonl`.
### Environment
- OS: Windows 11 (Git Bash)
- Shell: Bash (via Git for Windows)
Contributor guide
Research direction
Inspect the 92 affected SKILL.md files, starting with the Artifacts Sync preamble around lines 369-370 and the end-of-skill Telemetry section. Update the two variable assignments and the direct sync command to use the home-directory path, then verify that ARTIFACTS_SYNC reports full and that gstack-brain-sync updates the listed artifact files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100