Skip to content

Commit 47dff65

Browse files
committed
feat(ci): add updating skill and weekly-update workflow
- Add updating skill for npm dependency updates - Add weekly-update.yml workflow for automated updates - Fix .gitignore to allow .claude/skills/ and .claude/commands/
1 parent 0db326b commit 47dff65

File tree

3 files changed

+343
-1
lines changed

3 files changed

+343
-1
lines changed

.claude/skills/updating/SKILL.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
name: updating
3+
description: Updates all npm dependencies to their latest versions. Triggers when user asks to "update dependencies", "update packages", or prepare for a release.
4+
user-invocable: true
5+
allowed-tools: Bash, Read, Grep, Glob, Edit
6+
---
7+
8+
# updating
9+
10+
<task>
11+
Your task is to update all npm dependencies to their latest versions, ensuring all builds and tests pass.
12+
</task>
13+
14+
<context>
15+
**What is this?**
16+
This skill updates npm packages for security patches, bug fixes, and new features.
17+
18+
**Update Targets:**
19+
- npm packages via `pnpm run update` or `pnpm update`
20+
</context>
21+
22+
<constraints>
23+
**Requirements:**
24+
- Start with clean working directory (no uncommitted changes)
25+
26+
**CI Mode** (detected via `CI=true` or `GITHUB_ACTIONS`):
27+
- Create atomic commits, skip build validation (CI validates separately)
28+
- Workflow handles push and PR creation
29+
30+
**Interactive Mode** (default):
31+
- Validate updates with build/tests before proceeding
32+
- Report validation results to user
33+
34+
**Actions:**
35+
- Update npm packages
36+
- Create atomic commits
37+
- Report summary of changes
38+
</constraints>
39+
40+
<instructions>
41+
42+
## Process
43+
44+
### Phase 1: Validate Environment
45+
46+
<action>
47+
Check working directory is clean and detect CI mode:
48+
</action>
49+
50+
```bash
51+
# Detect CI mode
52+
if [ "$CI" = "true" ] || [ -n "$GITHUB_ACTIONS" ]; then
53+
CI_MODE=true
54+
echo "Running in CI mode - will skip build validation"
55+
else
56+
CI_MODE=false
57+
echo "Running in interactive mode - will validate builds"
58+
fi
59+
60+
# Check working directory is clean
61+
git status --porcelain
62+
```
63+
64+
<validation>
65+
- Working directory must be clean
66+
- CI_MODE detected for subsequent phases
67+
</validation>
68+
69+
---
70+
71+
### Phase 2: Update npm Packages
72+
73+
<action>
74+
Run pnpm update to update npm dependencies:
75+
</action>
76+
77+
```bash
78+
# Update npm packages (use pnpm run update if script exists, otherwise pnpm update)
79+
if grep -q '"update"' package.json; then
80+
pnpm run update
81+
else
82+
pnpm update
83+
fi
84+
85+
# Check if there are changes
86+
if [ -n "$(git status --porcelain pnpm-lock.yaml package.json)" ]; then
87+
git add pnpm-lock.yaml package.json
88+
git commit -m "chore: update npm dependencies
89+
90+
Updated npm packages via pnpm update."
91+
echo "npm packages updated"
92+
else
93+
echo "npm packages already up to date"
94+
fi
95+
```
96+
97+
---
98+
99+
### Phase 3: Final Validation
100+
101+
<action>
102+
Run build and test suite (skip in CI mode):
103+
</action>
104+
105+
```bash
106+
if [ "$CI_MODE" = "true" ]; then
107+
echo "CI mode: Skipping final validation (CI will run builds/tests separately)"
108+
echo "Commits created - ready for push by CI workflow"
109+
else
110+
echo "Interactive mode: Running full validation..."
111+
pnpm run check
112+
pnpm test
113+
fi
114+
```
115+
116+
---
117+
118+
### Phase 4: Report Summary
119+
120+
<action>
121+
Generate update report:
122+
</action>
123+
124+
```
125+
## Update Complete
126+
127+
### Updates Applied:
128+
129+
| Category | Status |
130+
|----------|--------|
131+
| npm packages | Updated/Up to date |
132+
133+
### Commits Created:
134+
- [list commits if any]
135+
136+
### Validation:
137+
- Build: SUCCESS/SKIPPED (CI mode)
138+
- Tests: PASS/SKIPPED (CI mode)
139+
140+
### Next Steps:
141+
**Interactive mode:**
142+
1. Review changes: `git log --oneline -N`
143+
2. Push to remote: `git push origin main`
144+
145+
**CI mode:**
146+
1. Workflow will push branch and create PR
147+
2. CI will run full build/test validation
148+
3. Review PR when CI passes
149+
```
150+
151+
</instructions>
152+
153+
## Success Criteria
154+
155+
- All npm packages checked for updates
156+
- Full build and tests pass (interactive mode)
157+
- Summary report generated
158+
159+
## Context
160+
161+
This skill is useful for:
162+
163+
- Weekly maintenance (automated via weekly-update.yml)
164+
- Security patch rollout
165+
- Pre-release preparation
166+
167+
**Safety:** Updates are validated before committing. Failures stop the process.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: 🔄 Weekly Dependency Update
2+
3+
on:
4+
schedule:
5+
# Run weekly on Monday at 9 AM UTC
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch:
8+
inputs:
9+
dry-run:
10+
description: 'Check for updates without creating PR'
11+
required: false
12+
type: boolean
13+
default: false
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
check-updates:
20+
name: Check for dependency updates
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
outputs:
25+
has-updates: ${{ steps.check.outputs.has-updates }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
with:
30+
fetch-depth: 0
31+
persist-credentials: false
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
35+
with:
36+
node-version-file: .node-version
37+
cache: ''
38+
39+
- name: Setup pnpm
40+
uses: pnpm/action-setup@b307475762933b98ed359c036b0e51f26b63b74b # v5.0.0
41+
42+
- name: Install dependencies
43+
run: pnpm install --frozen-lockfile
44+
45+
- name: Check for npm updates
46+
id: check
47+
run: |
48+
echo "Checking for npm package updates..."
49+
HAS_UPDATES=false
50+
NPM_UPDATES=$(pnpm outdated 2>/dev/null || true)
51+
if [ -n "$NPM_UPDATES" ] && ! echo "$NPM_UPDATES" | grep -q "No outdated"; then
52+
echo "npm packages have updates available"
53+
HAS_UPDATES=true
54+
fi
55+
echo "has-updates=$HAS_UPDATES" >> $GITHUB_OUTPUT
56+
57+
apply-updates:
58+
name: Apply updates with Claude Code
59+
needs: check-updates
60+
if: needs.check-updates.outputs.has-updates == 'true' && inputs.dry-run != true
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
pull-requests: write
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
68+
with:
69+
fetch-depth: 0
70+
persist-credentials: false
71+
72+
- name: Setup Node.js
73+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
74+
with:
75+
node-version-file: .node-version
76+
cache: ''
77+
78+
- name: Setup pnpm
79+
uses: pnpm/action-setup@b307475762933b98ed359c036b0e51f26b63b74b # v5.0.0
80+
81+
- name: Install dependencies
82+
run: pnpm install --frozen-lockfile
83+
84+
- name: Install Claude Code
85+
run: npm install -g @anthropic-ai/claude-code
86+
87+
- name: Create update branch
88+
id: branch
89+
run: |
90+
BRANCH_NAME="weekly-update-$(date +%Y%m%d)"
91+
git config user.name "github-actions[bot]"
92+
git config user.email "github-actions[bot]@users.noreply.github.com"
93+
git checkout -b "$BRANCH_NAME"
94+
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
95+
96+
- name: Run updating skill with Claude Code
97+
id: claude
98+
timeout-minutes: 30
99+
env:
100+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
101+
CI: 'true'
102+
GITHUB_ACTIONS: 'true'
103+
run: |
104+
if [ -z "$ANTHROPIC_API_KEY" ]; then
105+
echo "⚠️ ANTHROPIC_API_KEY not set - skipping automated update"
106+
echo "success=false" >> $GITHUB_OUTPUT
107+
exit 0
108+
fi
109+
110+
claude --print --dangerously-skip-permissions \
111+
--model sonnet \
112+
"/updating - Run the updating skill to update all dependencies. Create atomic commits for each update. You are running in CI mode - skip builds and tests. Do not push or create a PR." \
113+
2>&1 | tee claude-output.log
114+
115+
if [ $? -eq 0 ]; then
116+
echo "success=true" >> $GITHUB_OUTPUT
117+
else
118+
echo "success=false" >> $GITHUB_OUTPUT
119+
fi
120+
121+
- name: Check for changes
122+
id: changes
123+
run: |
124+
if [ -n "$(git status --porcelain)" ] || [ "$(git rev-list --count HEAD ^origin/main)" -gt 0 ]; then
125+
echo "has-changes=true" >> $GITHUB_OUTPUT
126+
else
127+
echo "has-changes=false" >> $GITHUB_OUTPUT
128+
fi
129+
130+
- name: Push branch
131+
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
132+
env:
133+
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
134+
run: git push origin "$BRANCH_NAME"
135+
136+
- name: Create Pull Request
137+
if: steps.claude.outputs.success == 'true' && steps.changes.outputs.has-changes == 'true'
138+
env:
139+
GH_TOKEN: ${{ github.token }}
140+
BRANCH_NAME: ${{ steps.branch.outputs.branch }}
141+
run: |
142+
COMMITS=$(git log --oneline origin/main..HEAD)
143+
COMMIT_COUNT=$(git rev-list --count origin/main..HEAD)
144+
145+
gh pr create \
146+
--title "chore(deps): weekly dependency update ($(date +%Y-%m-%d))" \
147+
--body "## Weekly Dependency Update
148+
149+
Automated weekly update of npm packages.
150+
151+
### Commits (${COMMIT_COUNT})
152+
153+
<details>
154+
<summary>View commit history</summary>
155+
156+
\`\`\`
157+
${COMMITS}
158+
\`\`\`
159+
160+
</details>
161+
162+
---
163+
164+
<sub>Generated by [weekly-update.yml](.github/workflows/weekly-update.yml)</sub>" \
165+
--draft \
166+
--head "$BRANCH_NAME" \
167+
--base main
168+
169+
- name: Upload Claude output
170+
if: always()
171+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
172+
with:
173+
name: claude-output-${{ github.run_id }}
174+
path: claude-output.log
175+
retention-days: 7

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ dist/
6767
# ============================================================================
6868
# Claude Code configuration
6969
# ============================================================================
70-
.claude/
70+
.claude/*
7171
!.claude/commands/
7272
!.claude/skills/

0 commit comments

Comments
 (0)