Skip to content

Commit a7844b5

Browse files
fix(install-global): ensure (global) label is always applied to mdd commands
The sed to prepend "(global)" to mdd.md and install-mdd.md descriptions was conditional on a file copy occurring. If a file was skipped as "already up to date", the label was never applied (or re-applied if lost). Switched to an idempotent sed pattern that runs unconditionally after each file is handled (copy, update, or skip), so the (global) prefix is always guaranteed after install-global runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b43078c commit a7844b5

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

.claude/commands/install-global.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ INSTALLED_VERSION=${INSTALLED_VERSION:-0}
4747
- If the file **already exists** and versions match → skip, report "already up to date"
4848
- If the file **does NOT exist** → copy it
4949

50-
**After copying**, update the `description` field in each installed file to prepend `(global)` so it is distinguishable from project-level copies in the Claude command list:
50+
**After handling each file** (whether copied or skipped), always ensure the `(global)` prefix is present in the installed copy's `description` field. Run the sed unconditionally — it is idempotent and safe to run even if `(global)` is already present (the pattern only matches when `(global)` is absent):
5151

5252
```bash
53-
# Prepend (global) to description in the installed copy
54-
sed -i 's/^description: "\(.*\)"$/description: "(global) \1"/' ~/.claude/commands/mdd.md
55-
sed -i 's/^description: "\(.*\)"$/description: "(global) \1"/' ~/.claude/commands/install-mdd.md
53+
# Ensure (global) prefix — idempotent: only adds if not already present
54+
sed -i 's/^description: "\([^(]\)/description: "(global) \1/' ~/.claude/commands/mdd.md
55+
sed -i 's/^description: "\([^(]\)/description: "(global) \1/' ~/.claude/commands/install-mdd.md
5656
```
5757

5858
This only modifies the installed copy at `~/.claude/commands/` — the source files in `.claude/commands/` are never touched.
@@ -64,8 +64,8 @@ Global MDD Update
6464
✓ mdd.md — v<INSTALLED> → v<SOURCE> (updated) [labelled "global"]
6565
✓ install-mdd.md — updated [labelled "global"]
6666
— OR —
67-
✓ mdd.md — v<VERSION> already up to date
68-
✓ install-mdd.md — updated [labelled "global"]
67+
✓ mdd.md — v<VERSION> already up to date [labelled "global"]
68+
✓ install-mdd.md — already up to date [labelled "global"]
6969
7070
/mdd is now current in every project on this machine.
7171
```
@@ -192,23 +192,23 @@ For each file (`mdd.md`, `install-mdd.md`):
192192
- If the file **already exists** at `~/.claude/commands/` → ask: "mdd.md already exists globally (installed: v<INSTALLED_VERSION>, available: v<SOURCE_VERSION>). Overwrite? (yes / keep existing)"
193193
- If it **does NOT exist** → copy it from `.claude/commands/`
194194

195-
**After copying**, prepend `(global)` to the `description` field in each installed file:
195+
**After handling each file** (whether copied, updated, or skipped), always ensure the `(global)` prefix is present. Run the sed unconditionally — it is idempotent and only adds the prefix if absent:
196196
```bash
197-
sed -i 's/^description: "\(.*\)"$/description: "(global) \1"/' ~/.claude/commands/mdd.md
198-
sed -i 's/^description: "\(.*\)"$/description: "(global) \1"/' ~/.claude/commands/install-mdd.md
197+
sed -i 's/^description: "\([^(]\)/description: "(global) \1/' ~/.claude/commands/mdd.md
198+
sed -i 's/^description: "\([^(]\)/description: "(global) \1/' ~/.claude/commands/install-mdd.md
199199
```
200200

201201
Report:
202202
```
203203
Global MDD install:
204-
+ mdd.md — installed (now available as /mdd in every project)
205-
+ install-mdd.md — installed (now available as /install-mdd in every project)
204+
+ mdd.md — installed [labelled "global"]
205+
+ install-mdd.md — installed [labelled "global"]
206206
```
207207
or
208208
```
209209
Global MDD install:
210-
✓ mdd.md — already up to date, skipped
211-
+ install-mdd.md — installed
210+
✓ mdd.md — already up to date [labelled "global"]
211+
+ install-mdd.md — installed [labelled "global"]
212212
```
213213

214214
---

0 commit comments

Comments
 (0)