Skip to content
Source
Sign inSign up
TanStack/devtools
Open History to see the last commit

check-skills.yml

142 lines5.1 KB

1# check-skills.yml β€” Drop this into your library repo's .github/workflows/
2#
3# Checks for stale intent skills after a release and opens a review PR
4# if any skills need attention. The PR body includes a prompt you can
5# paste into Claude Code, Cursor, or any coding agent to update them.
6#
7# Triggers: new release published, or manual workflow_dispatch.
8#
9# Template variables (replaced by `intent setup`):
10# @tanstack/devtools β€” e.g. @tanstack/query
11​
12name: Check Skills
13​
14on:
15 release:
16 types: [published]
17 workflow_dispatch: {}
18​
19permissions:
20 contents: read
21​
22jobs:
23 check:
24 name: Check for stale skills
25 runs-on: ubuntu-latest
26 permissions:
27 contents: write
28 pull-requests: write
29 steps:
30 - name: Checkout
31 uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
32 with:
33 fetch-depth: 0
34 persist-credentials: true # review job pushes a generated branch
35​
36 - name: Setup Node
37 uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
38 with:
39 node-version: 20
40​
41 - name: Install intent
42 run: npm install -g @tanstack/intent@0.0.41
43​
44 - name: Check staleness
45 id: stale
46 run: |
47 OUTPUT=$(npx @tanstack/intent stale --json 2>&1) || true
48 echo "$OUTPUT"
49​
50 # Check if any skills need review
51 NEEDS_REVIEW=$(echo "$OUTPUT" | node -e "
52 const input = require('fs').readFileSync('/dev/stdin','utf8');
53 try {
54 const reports = JSON.parse(input);
55 const stale = reports.flatMap(r =>
56 r.skills.filter(s => s.needsReview).map(s => ({ library: r.library, skill: s.name, reasons: s.reasons }))
57 );
58 if (stale.length > 0) {
59 console.log(JSON.stringify(stale));
60 }
61 } catch {}
62 ")
63​
64 if [ -z "$NEEDS_REVIEW" ]; then
65 echo "has_stale=false" >> "$GITHUB_OUTPUT"
66 else
67 echo "has_stale=true" >> "$GITHUB_OUTPUT"
68 # Escape for multiline GH output
69 EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
70 echo "stale_json<<$EOF" >> "$GITHUB_OUTPUT"
71 echo "$NEEDS_REVIEW" >> "$GITHUB_OUTPUT"
72 echo "$EOF" >> "$GITHUB_OUTPUT"
73 fi
74​
75 - name: Build summary
76 if: steps.stale.outputs.has_stale == 'true'
77 id: summary
78 run: |
79 node -e "
80 const stale = JSON.parse(process.env.STALE_JSON);
81 const lines = stale.map(s =>
82 '- **' + s.skill + '** (' + s.library + '): ' + s.reasons.join(', ')
83 );
84 const summary = lines.join('\n');
85​
86 const prompt = [
87 'Review and update the following stale intent skills for @tanstack/devtools:',
88 '',
89 ...stale.map(s => '- ' + s.skill + ': ' + s.reasons.join(', ')),
90 '',
91 'For each stale skill:',
92 '1. Read the current SKILL.md file',
93 '2. Check what changed in the library since the skill was last updated',
94 '3. Update the skill content to reflect current APIs and behavior',
95 '4. Run \`npx @tanstack/intent validate\` to verify the updated skill',
96 ].join('\n');
97​
98 // Write outputs
99 const fs = require('fs');
100 const env = fs.readFileSync(process.env.GITHUB_OUTPUT, 'utf8');
101 const eof = require('crypto').randomBytes(15).toString('base64');
102 fs.appendFileSync(process.env.GITHUB_OUTPUT,
103 'summary<<' + eof + '\n' + summary + '\n' + eof + '\n' +
104 'prompt<<' + eof + '\n' + prompt + '\n' + eof + '\n'
105 );
106 "
107 env:
108 STALE_JSON: ${{ steps.stale.outputs.stale_json }}
109​
110 - name: Open review PR
111 if: steps.stale.outputs.has_stale == 'true'
112 env:
113 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114 VERSION: ${{ github.event.release.tag_name || 'manual' }}
115 SUMMARY: ${{ steps.summary.outputs.summary }}
116 PROMPT: ${{ steps.summary.outputs.prompt }}
117 run: |
118 BRANCH="skills/review-${VERSION}"
119​
120 git config user.name "github-actions[bot]"
121 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
122 git checkout -b "$BRANCH"
123 git commit --allow-empty -m "chore: review stale skills for ${VERSION}"
124 git push origin "$BRANCH"
125​
126 {
127 printf '%s\n\n' '## Stale Skills Detected'
128 printf '%s\n\n' 'The following skills may need updates after the latest release:'
129 printf '%s\n\n' "$SUMMARY"
130 printf '%s\n\n' '---'
131 printf '%s\n\n' '### Update Prompt'
132 printf '%s\n\n' 'Paste this into your coding agent (Claude Code, Cursor, etc.):'
133 printf '%s\n' '~~~'
134 printf '%s\n' "$PROMPT"
135 printf '%s\n' '~~~'
136 } > pr-body.md
137​
138 gh pr create \
139 --title "Review stale skills (${VERSION})" \
140 --body-file pr-body.md \
141 --head "$BRANCH" \
142 --base main