Skip to content

Commit c9edc2d

Browse files
Copilotaspiers
andcommitted
docs: address PR #110 review comments in sync-lexicons skill
Co-authored-by: aspiers <100738+aspiers@users.noreply.github.com>
1 parent 97b00d0 commit c9edc2d

1 file changed

Lines changed: 76 additions & 28 deletions

File tree

.claude/skills/sync-lexicons/SKILL.md

Lines changed: 76 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@ develop branch, then update SDK files accordingly.
2020

2121
## How It Works
2222

23-
1. **Extract current dependency**: Read SDK's `packages/sdk-core/package.json` for current `@hypercerts-org/lexicon`
24-
version
25-
2. **Fetch develop branch**: Get latest from lexicons repo develop branch
26-
3. **Compare versions**: Determine semantic version difference
27-
4. **Generate git diff**: Show changes between the two versions in lexicons repo
28-
5. **Update SDK files**: Modify SDK source files to reflect new lexicon imports/exports
23+
1. **Extract current dependency**: Read SDK's `packages/sdk-core/package.json` for current `@hypercerts-org/lexicon`
24+
version
25+
2. **Fetch develop branch**: Get latest from lexicons repo develop branch
26+
3. **Compare versions**: Determine semantic version difference
27+
4. **Review CHANGELOG**:
28+
- For changes between normal releases, inspect `CHANGELOG.md` in the lexicons repo to understand changes between the
29+
two versions.
30+
- For changes with beta pre-releases, `CHANGELOG.md` is not updated in the lexicons repo, but it is in released
31+
packages, so you can download the latest version via:
32+
33+
tgz=$(npm pack @hypercerts-org/lexicon) && tar zxO package/CHANGELOG.md <$tgz >CHANGELOG.md && rm $tgz
34+
35+
5. **Generate git diff**: Show changes between the two versions in lexicons repo
36+
6. **Update SDK files**: Modify SDK source files to reflect new lexicon imports/exports
2937

3038
## Key Paths
3139

@@ -39,16 +47,30 @@ develop branch, then update SDK files accordingly.
3947
### Step 1: Check version of current dependency
4048

4149
```bash
42-
OLD_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"]' packages/sdk-core/package.json)
50+
OLD_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"] // empty' packages/sdk-core/package.json)
51+
if [ -z "$OLD_VERSION" ]; then
52+
echo "Error: @hypercerts-org/lexicon dependency not found in packages/sdk-core/package.json" >&2
53+
echo "Please ensure @hypercerts-org/lexicon is listed under dependencies before running this script." >&2
54+
exit 1
55+
fi
4356
echo "Current SDK dependency: @hypercerts-org/lexicon@${OLD_VERSION}"
4457
```
4558

4659
**Note**: `OLD_VERSION` is extracted without the `v` prefix (e.g., `0.10.0-beta.4`). When using with git commands,
47-
prepend `v` to match git tag format.
60+
prepend `v` to match git tag format. The `OLD_VERSION` variable should be captured and preserved for use in subsequent
61+
steps (Step 5). These commands should be executed in the same shell session to maintain variable state, or the variable
62+
should be saved to a file or environment variable that persists across command executions.
4863

4964
### Step 2: Fetch latest develop and tags
5065

5166
```bash
67+
# Ensure the lexicons repository is present in the expected location
68+
if [ ! -d "../hypercerts-lexicon" ]; then
69+
echo "Error: Lexicons repository not found at ../hypercerts-lexicon" >&2
70+
echo "Please ensure the repository is cloned in the expected location." >&2
71+
exit 1
72+
fi
73+
5274
git -C ../hypercerts-lexicon fetch --tags origin
5375
```
5476

@@ -84,18 +106,27 @@ Look for:
84106
### Step 5: Compare versions and diff
85107

86108
```bash
87-
# NEW_VERSION already set in Step 3 from package.json (without 'v' prefix)
88-
# If running Step 5 independently, re-extract it:
109+
# Use OLD_VERSION from Step 1 and NEW_VERSION from Step 3 (both without the 'v' prefix)
110+
# If running Step 5 independently, re-extract NEW_VERSION:
89111
# NEW_VERSION=$(jq -r '.dependencies["@hypercerts-org/lexicon"]' packages/sdk-core/package.json)
90112

91113
echo "Comparing ${OLD_VERSION} (previous) to ${NEW_VERSION} (updated)"
92114

93-
# Show files that changed between old and new versions
94-
# Note: Prepend 'v' to version numbers to match git tag format
95-
git -C ../hypercerts-lexicon diff v${OLD_VERSION}..v${NEW_VERSION} --stat
96-
97-
# Show detailed changes in lexicon JSON files
98-
git -C ../hypercerts-lexicon diff v${OLD_VERSION}..v${NEW_VERSION} -- '*.json' | head -200
115+
# Check if versions are identical
116+
if [ "${OLD_VERSION}" = "${NEW_VERSION}" ]; then
117+
echo "OLD_VERSION and NEW_VERSION are identical; no diff to show."
118+
else
119+
# Construct git tag names (tags are of the form vX.Y.Z)
120+
OLD_TAG="v${OLD_VERSION}"
121+
NEW_TAG="v${NEW_VERSION}"
122+
123+
# Show files that changed between old and new versions
124+
git -C ../hypercerts-lexicon diff "${OLD_TAG}..${NEW_TAG}" --stat
125+
126+
# Show detailed changes in lexicon JSON files
127+
# Note: `head -200` limits output for readability; remove `| head -200` to see the full diff if needed.
128+
git -C ../hypercerts-lexicon diff "${OLD_TAG}..${NEW_TAG}" -- '*.json' | head -200
129+
fi
99130
```
100131

101132
### Step 6: Create structured plan and get user approval
@@ -118,7 +149,8 @@ Based on the CHANGELOG and git diff analysis, create a detailed plan document
118149
- Helper types needed
119150
- Usage examples to add
120151
- Validation steps (build, test, type checking)
121-
- Changeset requirements (bump type and justification)
152+
- Changeset requirements (bump type according to semantic versioning principles: major/minor/patch, and
153+
justification)
122154

123155
3. **Order changes logically**:
124156
- Group related changes together
@@ -169,7 +201,7 @@ Example plan structure:
169201
- [ ] Tests pass (`pnpm test`)
170202
- [ ] Types export correctly
171203

172-
**Status**: ⏳ Pending / 🚧 In Progress / ✅ Complete
204+
**Status**: ⏳ Pending / In Progress / ✅ Complete
173205

174206
---
175207

@@ -210,6 +242,20 @@ Present this plan to the user and ask:
210242
>
211243
> Should I proceed with implementing Change 1: [Feature Name]?"
212244
245+
Present the structured plan to the user and explicitly ask whether to:
246+
247+
- Approve the plan and proceed
248+
- Request modifications to the plan
249+
- Cancel the sync process for now
250+
251+
If the user **approves** the plan, proceed to the next steps in this skill.
252+
253+
If the user **requests modifications**, revise the plan based on their feedback, re-present it, and remain in this step
254+
until an updated plan is explicitly approved.
255+
256+
If the user **declines approval** or **cancels** the sync, stop the sync process, do **not** execute any further steps
257+
in this skill, and summarize the current state and reasons for cancellation.
258+
213259
**Wait for explicit user confirmation before proceeding to Step 7.**
214260

215261
### Step 7: Implement ONE logical change at a time
@@ -252,9 +298,10 @@ For the current change (e.g., "Change 1: Collection Item Weights"):
252298
pnpm changeset
253299
```
254300

255-
- Use the process in the `writing-changesets` skill
301+
- Follow guidance from the `writing-changesets` skill (see `.claude/skills/writing-changesets/SKILL.md` for detailed
302+
instructions on creating and categorizing changesets)
256303
- Reference the specific feature being added
257-
- Use appropriate bump type
304+
- Use an appropriate semantic version bump type (major/minor/patch) according to semantic versioning principles
258305

259306
**After completing these steps for the current change:**
260307

@@ -307,16 +354,11 @@ After ALL changes are implemented:
307354

308355
## Common Anti-Patterns to Avoid
309356

310-
### Don't Hardcode Lexicon Names
311-
312-
-`if (lexicon === "HYPERCERTS_LEXICON") ...`
313-
- ✅ Read dynamically from the lexicons package exports
314-
315357
### Don't Skip Review of the CHANGELOG.md review or diffs
316358

317359
- ❌ Immediately update without reviewing changes
318360
- ✅ Always check `CHANGELOG.md` first to see exactly what changed between versions
319-
- ✅ Then run `git diff` for additional context
361+
- ✅ Then run `git diff` to see what actually changed in your codebase
320362

321363
### Don't Forget to Rebuild
322364

@@ -383,8 +425,14 @@ Each logical change gets its own changeset:
383425

384426
## Iterative Process Summary
385427

386-
**DO**: Work on one logical feature at a time, validate, get approval, repeat **DON'T**: Try to sync everything at once
387-
in a big batch
428+
**Do:**
429+
430+
- Work on one logical feature at a time
431+
- Validate, get approval, repeat
432+
433+
**Don't:**
434+
435+
- Try to sync everything at once in a big batch
388436

389437
This ensures:
390438

0 commit comments

Comments
 (0)