-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
1186 lines (994 loc) · 37.4 KB
/
justfile
File metadata and controls
1186 lines (994 loc) · 37.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
set unstable := true
# Claude Code configuration directory
CLAUDE_DIR := env("HOME") / ".claude"
EMBEDDING_MODEL := "nomic-embed-text"
# Install project dependencies (idempotent)
[group('install')]
init: _init-brew _init-python _init-pre-commit _init-docker _init-ollama _init-db
@echo "✓ Project initialized"
[private]
_init-brew:
@echo "Installing Homebrew dependencies..."
@brew bundle --quiet
[private]
_init-pre-commit:
@echo "Installing Pre-commit Hooks..."
@pre-commit install --install-hooks
[private]
_init-python:
@echo "Installing Python dependencies..."
@uv sync --quiet
[private]
_init-docker: mcp-up
[private]
_init-ollama:
#!/usr/bin/env bash
echo "Checking Ollama embedding model..."
if ollama list 2>/dev/null | grep -q "{{ EMBEDDING_MODEL }}"; then
echo " ✓ {{ EMBEDDING_MODEL }} available"
else
echo " Pulling {{ EMBEDDING_MODEL }}..."
ollama pull "{{ EMBEDDING_MODEL }}" || echo " ⚠ Ollama not running - will use sentence-transformers fallback"
fi
[private]
_init-db:
@echo "Initializing knowledge graph database..."
@just kg-init
# Docker MCP services
[group('docker')]
mcp-up:
@"{{ which("docker") }}" compose -f .docker/compose.yaml up -d
@echo "✓ MCP services started"
@echo " Add crawl4ai to Claude: claude mcp add --transport sse crawl4ai http://localhost:11235/mcp/sse"
[group('docker')]
mcp-down:
@"{{ which("docker") }}" compose -f .docker/compose.yaml down
[group('docker')]
mcp-logs service="crawl4ai":
@"{{ which("docker") }}" compose -f .docker/compose.yaml logs -f "{{ service }}"
[group('docker')]
mcp-status:
@"{{ which("docker") }}" compose -f .docker/compose.yaml ps
# Install Claude Code components to ~/.claude/
[group('install')]
install target='all':
@just _install-{{ target }}
[private]
_install-all: _install-claude
ls-tags:
yq --output-format=json '.' "{{ justfile_directory() }}/components/skills/external.yaml" | jq '[ .manifest[] | add | .tags[] ] | unique'
[private]
_install-claude: _install-claude-commands _install-claude-rules _install-claude-skills _install-claude-hooks _install-claude-settings
@echo "✓ Claude Code components installed to {{ CLAUDE_DIR }}"
[private]
_install-claude-settings:
@echo "Installing settings..."
@mkdir -p "{{ CLAUDE_DIR }}"
@ln -sf "$(pwd)/settings/claude.json" "{{ CLAUDE_DIR }}/settings.json" && echo " → ~/claude/settings.json" || true
[private]
_install-claude-commands:
@echo "Installing commands..."
@mkdir -p "{{ CLAUDE_DIR }}/commands"
@for f in components/commands/*.md; do \
[ -f "$f" ] && ln -sf "$(pwd)/$f" "{{ CLAUDE_DIR }}/commands/$(basename $f)" && echo " → $(basename $f)"; \
done || true
[private]
_install-claude-rules:
@echo "Installing rules..."
@mkdir -p "{{ CLAUDE_DIR }}/rules"
@for f in components/rules/*.md; do \
[ -f "$f" ] && ln -sf "$(pwd)/$f" "{{ CLAUDE_DIR }}/rules/$(basename $f)" && echo " → $(basename $f)"; \
done || true
[private]
_install-claude-skills:
@echo "Installing skills..."
@mkdir -p "{{ CLAUDE_DIR }}/skills"
@for d in components/skills/*/; do \
name=$(basename "$d"); \
target="{{ CLAUDE_DIR }}/skills/$name"; \
if [ -d "$d" ]; then \
if [ -L "$target" ]; then \
rm -f "$target"; \
elif [ -d "$target" ]; then \
rm -rf "$target"; \
fi; \
ln -sfn "$(pwd)/$d" "$target" && echo " → $name/"; \
fi; \
done || true
[private]
_install-claude-hooks:
@echo "Installing hooks..."
@mkdir -p "{{ CLAUDE_DIR }}/hooks"
@for f in components/hooks/*; do \
[ -f "$f" ] && [ "$(basename $f)" != ".gitkeep" ] && ln -sf "$(pwd)/$f" "{{ CLAUDE_DIR }}/hooks/$(basename $f)" && echo " → $(basename $f)"; \
done || true
# Uninstall Claude Code components from ~/.claude/
[group('install')]
uninstall target='all':
@just _uninstall-{{ target }}
[private]
_uninstall-all: _uninstall-claude
[private]
_uninstall-claude:
@echo "Uninstalling Claude Code components..."
@for f in components/commands/*.md; do \
[ -f "$f" ] && rm -f "{{ CLAUDE_DIR }}/commands/$(basename $f)"; \
done || true
@for f in components/rules/*.md; do \
[ -f "$f" ] && rm -f "{{ CLAUDE_DIR }}/rules/$(basename $f)"; \
done || true
@for d in components/skills/*/; do \
[ -d "$d" ] && rm -f "{{ CLAUDE_DIR }}/skills/$(basename $d)"; \
done || true
@for f in components/hooks/*; do \
[ -f "$f" ] && [ "$(basename $f)" != ".gitkeep" ] && rm -f "{{ CLAUDE_DIR }}/hooks/$(basename $f)"; \
done || true
@echo "✓ Claude Code components uninstalled"
# List installed Claude Code components
[group('install')]
list-claude:
@echo "Commands:"
@ls -la "{{ CLAUDE_DIR }}/commands/" 2>/dev/null | grep -E "\.md$" || echo " (none)"
@echo "\nRules:"
@ls -la "{{ CLAUDE_DIR }}/rules/" 2>/dev/null | grep -E "\.md$" || echo " (none)"
@echo "\nSkills:"
@ls -la "{{ CLAUDE_DIR }}/skills/" 2>/dev/null | grep -v "^total" | grep -v "^\." || echo " (none)"
@echo "\nHooks:"
@ls -la "{{ CLAUDE_DIR }}/hooks/" 2>/dev/null | grep -v "^total" | grep -v "^\." || echo " (none)"
# Anthropic skills registry
ANTHROPIC_SKILLS_REPO := "https://github.com/anthropics/skills.git"
ANTHROPIC_VERSION_FILE := "components/skills/.anthropic-version"
# Mapping: local-name -> upstream-path
ANTHROPIC_SKILL_MAP := "claude-skill-dev:skills/skill-creator"
# Fetch/update skills from Anthropic's skills repository
[group('upstream')]
sync-anthropic-skills:
#!/usr/bin/env bash
set -euo pipefail
echo "Fetching latest from anthropics/skills..."
# Get current commit SHA
NEW_SHA=$(curl -sL https://api.github.com/repos/anthropics/skills/commits/main | jq -r '.sha[:7]')
OLD_SHA=$(cat "{{ ANTHROPIC_VERSION_FILE }}" 2>/dev/null || echo "none")
if [ "$NEW_SHA" = "$OLD_SHA" ]; then
echo "✓ Already up to date ($OLD_SHA)"
exit 0
fi
echo "Updating: $OLD_SHA → $NEW_SHA"
# Clone with sparse checkout
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
git clone --depth 1 --filter=blob:none --sparse "{{ ANTHROPIC_SKILLS_REPO }}" "$TMPDIR/skills" 2>/dev/null
cd "$TMPDIR/skills"
# Parse skill map and checkout each
IFS=' ' read -ra MAPPINGS <<< "{{ ANTHROPIC_SKILL_MAP }}"
PATHS=""
for mapping in "${MAPPINGS[@]}"; do
upstream_path="${mapping#*:}"
PATHS="$PATHS $upstream_path"
done
git sparse-checkout set $PATHS
cd - > /dev/null
# Copy each skill to local name
for mapping in "${MAPPINGS[@]}"; do
local_name="${mapping%%:*}"
upstream_path="${mapping#*:}"
rm -rf "components/skills/$local_name"
cp -r "$TMPDIR/skills/$upstream_path" "components/skills/$local_name"
echo " → $local_name (from $upstream_path)"
done
# Save version
echo "$NEW_SHA" > "{{ ANTHROPIC_VERSION_FILE }}"
echo "✓ Updated to $NEW_SHA"
# Check if Anthropic skills have updates available
[group('upstream')]
check-anthropic-updates:
#!/usr/bin/env bash
set -euo pipefail
NEW_SHA=$(curl -sL https://api.github.com/repos/anthropics/skills/commits/main | jq -r '.sha[:7]')
OLD_SHA=$(cat "{{ ANTHROPIC_VERSION_FILE }}" 2>/dev/null || echo "not installed")
if [ "$OLD_SHA" = "not installed" ]; then
echo "Anthropic skills not installed. Run: just sync-anthropic-skills"
elif [ "$NEW_SHA" = "$OLD_SHA" ]; then
echo "✓ Up to date ($OLD_SHA)"
else
echo "Update available: $OLD_SHA → $NEW_SHA"
echo "Run: just sync-anthropic-skills"
fi
# Show current Anthropic skills version
[group('upstream')]
anthropic-version:
@cat "{{ ANTHROPIC_VERSION_FILE }}" 2>/dev/null || echo "not installed"
# External skills manifest
EXTERNAL_MANIFEST := justfile_directory() / "components/skills/external.yaml"
EXTERNAL_VERSION_DIR := justfile_directory() / "components/skills/.versions"
# List available external skills (optionally filter by category)
[group('external')]
list-external-skills category='':
#!/usr/bin/env bash
set -euo pipefail
if [ -z "{{ category }}" ]; then
echo "Categories:"
yq -r '.manifest | keys[]' "{{ EXTERNAL_MANIFEST }}" | while read cat; do
count=$(yq -r ".manifest[\"$cat\"] | length" "{{ EXTERNAL_MANIFEST }}")
printf " %-30s (%d skills)\n" "$cat" "$count"
done
else
echo "Skills in {{ category }}:"
yq -r ".manifest[\"{{ category }}\"][] | \" \" + .name + \" - \" + (.notes // \"(no description)\")" "{{ EXTERNAL_MANIFEST }}" 2>/dev/null || echo " Category not found"
fi
# Search external skills by name or tag
[group('external')]
search-skills query:
#!/usr/bin/env bash
set -euo pipefail
echo "Searching for '{{ query }}'..."
yq -o=json '.manifest' "{{ EXTERNAL_MANIFEST }}" | \
jq -r --arg q "{{ query }}" '
to_entries[] |
.key as $cat |
.value[] |
select(
(.name | test($q; "i")) or
(.tags[]? | test($q; "i")) or
(.notes? // "" | test($q; "i"))
) |
"[\($cat)] \(.name) - \(.notes // "(no description)")"
'
# Import a skill from an external repository
[group('external')]
import-skill repo skill local_name='':
#!/usr/bin/env bash
set -euo pipefail
SKILL_NAME="{{ if local_name != '' { local_name } else { skill } }}"
TARGET_DIR="{{ justfile_directory() }}/components/skills/$SKILL_NAME"
echo "Importing $SKILL_NAME from {{ repo }}..."
# Create version tracking directory
mkdir -p "{{ EXTERNAL_VERSION_DIR }}"
# Get current commit SHA
NEW_SHA=$(curl -sL "https://api.github.com/repos/{{ repo }}/commits/main" 2>/dev/null | jq -r '.sha[:7]' || \
curl -sL "https://api.github.com/repos/{{ repo }}/commits/master" | jq -r '.sha[:7]')
VERSION_FILE="{{ EXTERNAL_VERSION_DIR }}/$SKILL_NAME"
OLD_SHA=$(cat "$VERSION_FILE" 2>/dev/null || echo "none")
if [ "$NEW_SHA" = "$OLD_SHA" ] && [ -d "$TARGET_DIR" ]; then
echo "✓ Already up to date ($OLD_SHA)"
exit 0
fi
echo "Fetching: $OLD_SHA → $NEW_SHA"
# Clone with sparse checkout
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
git clone --depth 1 --filter=blob:none --sparse "https://github.com/{{ repo }}.git" "$TMPDIR/repo" 2>/dev/null
cd "$TMPDIR/repo"
# Try to find the skill path (check if git ls-tree returns non-empty output)
SKILL_PATH=""
for path in "{{ skill }}" "skills/{{ skill }}" ".claude/skills/{{ skill }}"; do
if [ -n "$(git ls-tree --name-only HEAD "$path" 2>/dev/null)" ]; then
SKILL_PATH="$path"
break
fi
done
if [ -z "$SKILL_PATH" ]; then
echo "Error: Could not find skill '{{ skill }}' in repository"
echo "Tried: {{ skill }}, skills/{{ skill }}, .claude/skills/{{ skill }}"
exit 1
fi
git sparse-checkout set "$SKILL_PATH"
cd - > /dev/null
# Copy to local
rm -rf "$TARGET_DIR"
cp -r "$TMPDIR/repo/$SKILL_PATH" "$TARGET_DIR"
# Save version
echo "$NEW_SHA" > "$VERSION_FILE"
echo "✓ Imported $SKILL_NAME from {{ repo }} ($NEW_SHA)"
# Import skill by name from manifest
[group('external')]
import-skill-by-name name local_name='':
#!/usr/bin/env bash
set -euo pipefail
# Find skill in manifest
SKILL_DATA=$(yq -o=json '.manifest' "{{ EXTERNAL_MANIFEST }}" | \
jq -r --arg name "{{ name }}" '
to_entries[] |
.value[] |
select(.name == $name) |
"\(.repo)|\(.path // .name)"
' | head -1)
if [ -z "$SKILL_DATA" ]; then
echo "Error: Skill '{{ name }}' not found in manifest"
echo "Try: just search-skills {{ name }}"
exit 1
fi
REPO=$(echo "$SKILL_DATA" | cut -d'|' -f1)
SKILL_PATH=$(echo "$SKILL_DATA" | cut -d'|' -f2)
SKILL_NAME=$(basename "$SKILL_PATH")
LOCAL_NAME="{{ if local_name != '' { local_name } else { '' } }}"
if [ -z "$LOCAL_NAME" ]; then
LOCAL_NAME="$SKILL_NAME"
fi
echo "Found: $REPO / $SKILL_PATH"
just import-skill "$REPO" "$SKILL_PATH" "$LOCAL_NAME"
# List external registries
[group('external')]
list-registries:
#!/usr/bin/env bash
set -euo pipefail
echo "Registries:"
yq -r '.registries[] | " [" + .type + "] " + .name + " - " + (.notes // "")' "{{ EXTERNAL_MANIFEST }}"
# Show version of imported external skill
[group('external')]
external-version skill:
@cat "{{ EXTERNAL_VERSION_DIR }}/{{ skill }}" 2>/dev/null || echo "not imported"
# Check for updates to imported external skills
[group('external')]
check-external-updates:
#!/usr/bin/env bash
set -euo pipefail
if [ ! -d "{{ EXTERNAL_VERSION_DIR }}" ]; then
echo "No external skills imported yet."
exit 0
fi
echo "Checking for updates..."
for version_file in "{{ EXTERNAL_VERSION_DIR }}"/*; do
[ -f "$version_file" ] || continue
skill=$(basename "$version_file")
old_sha=$(cat "$version_file")
# Find repo in manifest
repo=$(yq -o=json '.manifest' "{{ EXTERNAL_MANIFEST }}" | \
jq -r --arg name "$skill" '
to_entries[] |
.value[] |
select(.name == $name) |
.repo
' | head -1)
if [ -n "$repo" ]; then
new_sha=$(curl -sL "https://api.github.com/repos/$repo/commits/main" 2>/dev/null | jq -r '.sha[:7]' || echo "$old_sha")
if [ "$new_sha" != "$old_sha" ]; then
echo " ⬆ $skill: $old_sha → $new_sha"
else
echo " ✓ $skill: up to date ($old_sha)"
fi
fi
done
# Skill management
SKILL_TEMPLATE_DIR := justfile_directory() / "components/skills/.templates"
# Create new skill from template
[group('skills')]
create-skill name:
#!/usr/bin/env bash
set -euo pipefail
SKILL_NAME="{{ name }}"
TARGET_DIR="{{ justfile_directory() }}/components/skills/$SKILL_NAME"
# Validate naming convention (allows lowercase letters and numbers like k8s)
if ! echo "$SKILL_NAME" | grep -qE '^[a-z0-9]+-([a-z0-9]+-)?[a-z0-9]+-[a-z]+$'; then
echo "Error: Invalid skill name format"
echo "Expected: <category>-[<subcategory>-]<tool>-<focus>"
echo "Focus must be one of: ops, dev, eng, nub, xec"
echo "Examples: lang-rust-cargo-dev, cloud-aws-terraform-eng"
exit 1
fi
# Extract components
FOCUS=$(echo "$SKILL_NAME" | rev | cut -d'-' -f1 | rev)
if ! echo "$FOCUS" | grep -qE '^(ops|dev|eng|nub|xec)$'; then
echo "Error: Invalid focus '$FOCUS'"
echo "Must be one of: ops, dev, eng, nub, xec"
exit 1
fi
if [ -d "$TARGET_DIR" ]; then
echo "Error: Skill '$SKILL_NAME' already exists"
exit 1
fi
echo "Creating skill: $SKILL_NAME"
# Create directory structure
mkdir -p "$TARGET_DIR/references"
# Copy template
cp "{{ SKILL_TEMPLATE_DIR }}/SKILL.md" "$TARGET_DIR/SKILL.md"
# Replace basic placeholders
CREATED_DATE=$(date -u +"%Y-%m-%dT%H:%M")
sed -i '' "s/\{\{SKILL_NAME\}\}/$SKILL_NAME/g" "$TARGET_DIR/SKILL.md"
sed -i '' "s/\{\{CREATED_DATE\}\}/$CREATED_DATE/g" "$TARGET_DIR/SKILL.md"
sed -i '' "s/\{\{UPDATED_DATE\}\}/$CREATED_DATE/g" "$TARGET_DIR/SKILL.md"
echo "✓ Created skill at: $TARGET_DIR"
echo " Edit SKILL.md to complete the skill definition"
# Validate skill naming and structure
[group('skills')]
validate-skill path:
#!/usr/bin/env bash
set -euo pipefail
SKILL_PATH="{{ path }}"
SKILL_NAME=$(basename "$SKILL_PATH")
ERRORS=0
echo "Validating: $SKILL_NAME"
# Check naming convention (allows lowercase letters and numbers like k8s)
if ! echo "$SKILL_NAME" | grep -qE '^[a-z0-9]+-([a-z0-9]+-)?[a-z0-9]+-[a-z]+$'; then
echo " ✗ Name doesn't match pattern: <category>-[<subcategory>-]<tool>-<focus>"
ERRORS=$((ERRORS + 1))
else
echo " ✓ Name follows convention"
fi
# Check focus
FOCUS=$(echo "$SKILL_NAME" | rev | cut -d'-' -f1 | rev)
if ! echo "$FOCUS" | grep -qE '^(ops|dev|eng|nub|xec)$'; then
echo " ✗ Invalid focus: $FOCUS (expected: ops, dev, eng, nub, xec)"
ERRORS=$((ERRORS + 1))
else
echo " ✓ Valid focus: $FOCUS"
fi
# Check SKILL.md exists
if [ ! -f "$SKILL_PATH/SKILL.md" ]; then
echo " ✗ Missing SKILL.md"
ERRORS=$((ERRORS + 1))
else
echo " ✓ SKILL.md exists"
# Check for required frontmatter
if ! head -1 "$SKILL_PATH/SKILL.md" | grep -q '^---$'; then
echo " ✗ Missing YAML frontmatter"
ERRORS=$((ERRORS + 1))
else
echo " ✓ Has YAML frontmatter"
fi
# Check for required sections
for section in "Overview" "Quick Reference" "Troubleshooting"; do
if grep -q "^## $section" "$SKILL_PATH/SKILL.md"; then
echo " ✓ Has $section section"
else
echo " ⚠ Missing $section section (recommended)"
fi
done
fi
if [ $ERRORS -gt 0 ]; then
echo "Validation failed with $ERRORS error(s)"
exit 1
else
echo "✓ Validation passed"
fi
# List local skills with their focus levels
[group('skills')]
list-skills:
#!/usr/bin/env bash
set -euo pipefail
echo "Local skills:"
for d in "{{ justfile_directory() }}"/components/skills/*/; do
[ -d "$d" ] || continue
name=$(basename "$d")
# Skip hidden directories and templates
[[ "$name" == .* ]] && continue
# Extract focus if follows convention (allows lowercase letters and numbers like k8s)
if echo "$name" | grep -qE '^[a-z0-9]+-([a-z0-9]+-)?[a-z0-9]+-[a-z]+$'; then
focus=$(echo "$name" | rev | cut -d'-' -f1 | rev)
printf " %-40s [%s]\n" "$name" "$focus"
else
printf " %-40s [non-standard]\n" "$name"
fi
done
# Validate all local skills
[group('skills')]
validate-all-skills:
#!/usr/bin/env bash
set -euo pipefail
TOTAL=0
PASSED=0
FAILED=0
for d in "{{ justfile_directory() }}"/components/skills/*/; do
[ -d "$d" ] || continue
name=$(basename "$d")
[[ "$name" == .* ]] && continue
TOTAL=$((TOTAL + 1))
if just validate-skill "$d" >/dev/null 2>&1; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
echo "Failed: $name"
fi
done
echo ""
echo "Results: $PASSED/$TOTAL passed, $FAILED failed"
# Validate pillar coverage in a lang-*-dev skill
[group('skills')]
validate-pillars skill:
#!/usr/bin/env bash
set -euo pipefail
SKILL_NAME="{{ skill }}"
SKILL_FILE="{{ justfile_directory() }}/components/skills/$SKILL_NAME/SKILL.md"
if [ ! -f "$SKILL_FILE" ]; then
echo "❌ Skill not found: $SKILL_NAME"
exit 1
fi
echo "Validating pillars for $SKILL_NAME..."
echo ""
PILLARS=0
# Module System
if grep -qiE "^## Module|import.*export|namespace|package structure" "$SKILL_FILE"; then
echo "✓ Module System"
PILLARS=$((PILLARS + 1))
else
echo "✗ Module System"
fi
# Error Handling
if grep -qiE "^## Error|Result|Option|Exception" "$SKILL_FILE"; then
echo "✓ Error Handling"
PILLARS=$((PILLARS + 1))
else
echo "✗ Error Handling"
fi
# Concurrency
if grep -qiE "^## Concur|async|thread|actor|channel|goroutine|process" "$SKILL_FILE"; then
echo "✓ Concurrency"
PILLARS=$((PILLARS + 1))
else
echo "✗ Concurrency"
fi
# Metaprogramming
if grep -qiE "^## Meta|macro|decorator|reflection|annotation|code.*gen" "$SKILL_FILE"; then
echo "✓ Metaprogramming"
PILLARS=$((PILLARS + 1))
else
echo "✗ Metaprogramming"
fi
# Zero/Default Values
if grep -qiE "^## Zero|^## Default|null|nil|None|Option|nullable" "$SKILL_FILE"; then
echo "✓ Zero/Default Values"
PILLARS=$((PILLARS + 1))
else
echo "✗ Zero/Default Values"
fi
# Serialization
if grep -qiE "^## Serial|JSON|serde|codec|Encode|Decode|marshal" "$SKILL_FILE"; then
echo "✓ Serialization"
PILLARS=$((PILLARS + 1))
else
echo "✗ Serialization"
fi
# Build System
if grep -qiE "^## Build|^## Dep|package.*manager|cargo|npm|pip|maven|gradle" "$SKILL_FILE"; then
echo "✓ Build/Dependencies"
PILLARS=$((PILLARS + 1))
else
echo "✗ Build/Dependencies"
fi
# Testing
if grep -qiE "^## Test|unit test|property.*test|test.*framework" "$SKILL_FILE"; then
echo "✓ Testing"
PILLARS=$((PILLARS + 1))
else
echo "✗ Testing"
fi
echo ""
echo "Coverage: $PILLARS/8 pillars"
if [ $PILLARS -eq 8 ]; then
echo "✅ Full coverage - ready for conversion skills"
elif [ $PILLARS -ge 6 ]; then
echo "⚠️ Acceptable coverage (6+/8) - minor gaps exist"
else
echo "❌ Below recommended coverage - address gaps before creating conversion skills"
exit 1
fi
# Validate all lang-*-dev skills for pillar coverage
[group('skills')]
validate-all-lang-skills:
#!/usr/bin/env bash
set -euo pipefail
TOTAL=0
FULL=0
ACCEPTABLE=0
GAPS=0
echo "Validating all lang-*-dev skills..."
echo "=================================="
echo ""
for d in "{{ justfile_directory() }}"/components/skills/lang-*-dev/; do
[ -d "$d" ] || continue
name=$(basename "$d")
TOTAL=$((TOTAL + 1))
echo "[$TOTAL] $name"
echo "---"
# Run validation and capture exit code
if just validate-pillars "$name" 2>&1 | tail -n +2; then
if grep -q "8/8" <<< "$(just validate-pillars "$name" 2>&1)"; then
FULL=$((FULL + 1))
else
ACCEPTABLE=$((ACCEPTABLE + 1))
fi
else
GAPS=$((GAPS + 1))
fi
echo ""
done
echo "=================================="
echo "Summary: $TOTAL skills validated"
echo " ✅ Full coverage (8/8): $FULL"
echo " ⚠️ Acceptable (6-7/8): $ACCEPTABLE"
echo " ❌ Gaps (<6/8): $GAPS"
if [ $GAPS -gt 0 ]; then
echo ""
echo "Run 'just validate-pillars <skill-name>' for details on specific gaps"
fi
# Import external skill and normalize to naming convention
[group('skills')]
import-and-normalize repo skill target:
#!/usr/bin/env bash
set -euo pipefail
echo "Importing and normalizing: {{ skill }} → {{ target }}"
# Import the skill
just import-skill "{{ repo }}" "{{ skill }}" "{{ target }}"
# Validate the result
just validate-skill "{{ justfile_directory() }}/components/skills/{{ target }}"
# Plugin management
# Install a plugin locally via symlinks
[group('plugins')]
install-plugin name:
#!/usr/bin/env bash
set -euo pipefail
PLUGIN_DIR="context/plugins/{{ name }}"
SOURCES="$PLUGIN_DIR/.claude-plugin/plugin.sources.json"
if [ ! -f "$SOURCES" ]; then
echo "Error: $SOURCES not found"; exit 1
fi
RECEIPT="{{ CLAUDE_DIR }}/plugins/{{ name }}.installed"
mkdir -p "{{ CLAUDE_DIR }}/plugins"
# Read each source mapping and create symlinks
jq -r '.sources | to_entries[] | "\(.key)\t\(.value)"' "$SOURCES" | while IFS=$'\t' read -r local_path source_path; do
target="{{ CLAUDE_DIR }}/$local_path"
mkdir -p "$(dirname "$target")"
ln -sfn "$(pwd)/$source_path" "$target"
echo " → $local_path"
done
# Write receipt
jq -r '.sources | keys[]' "$SOURCES" > "$RECEIPT"
echo "✓ Plugin {{ name }} installed"
# Build a plugin — copy source components into the plugin directory
[group('plugins')]
build-plugin name:
#!/usr/bin/env bash
set -euo pipefail
PLUGIN_DIR="context/plugins/{{ name }}"
SOURCES="$PLUGIN_DIR/.claude-plugin/plugin.sources.json"
if [ ! -f "$SOURCES" ]; then
echo "Error: $SOURCES not found"; exit 1
fi
# Check for stale sources before building
echo "Checking source hashes..."
verify_exit=0
"{{ which("uv") }}" run python .scripts/plugin-hash.py --verify-sources "$PLUGIN_DIR" --interactive || verify_exit=$?
if [ "$verify_exit" -eq 1 ]; then
echo ""
echo "✗ Build aborted"
exit 1
elif [ "$verify_exit" -eq 2 ]; then
echo ""
echo "⚠ Warning: Plugin uses legacy format without hashes"
echo " Consider upgrading to extended format for hash verification"
echo ""
fi
# Copy each source component into the plugin directory
# Handle both legacy format (string path) and extended format (object with source field)
jq -r '.sources | to_entries[] | "\(.key)\t\(if .value | type == "string" then .value else .value.source end)"' "$SOURCES" | while IFS=$'\t' read -r local_path source_path; do
target="$PLUGIN_DIR/$local_path"
mkdir -p "$(dirname "$target")"
if [ -d "$source_path" ]; then
rm -rf "$target"
cp -r "$source_path" "$target"
else
cp "$source_path" "$target"
fi
echo " → $local_path"
done
echo "✓ Plugin {{ name }} built"
# Uninstall a plugin
[group('plugins')]
uninstall-plugin name:
#!/usr/bin/env bash
set -euo pipefail
RECEIPT="{{ CLAUDE_DIR }}/plugins/{{ name }}.installed"
if [ ! -f "$RECEIPT" ]; then
echo "Plugin {{ name }} is not installed"; exit 1
fi
while read -r local_path; do
rm -f "{{ CLAUDE_DIR }}/$local_path"
echo " ✕ $local_path"
done < "$RECEIPT"
rm -f "$RECEIPT"
echo "✓ Plugin {{ name }} uninstalled"
# Validate plugin source mappings
[group('plugins')]
check-plugin-sources name:
#!/usr/bin/env bash
set -euo pipefail
PLUGIN_DIR="context/plugins/{{ name }}"
SOURCES="$PLUGIN_DIR/.claude-plugin/plugin.sources.json"
errors=0
jq -r '.sources | to_entries[] | "\(.key)\t\(.value)"' "$SOURCES" | while IFS=$'\t' read -r local_path source_path; do
if [ ! -e "$source_path" ]; then
echo "MISSING: $source_path (for $local_path)"
errors=$((errors + 1))
fi
done
[ "$errors" -eq 0 ] && echo "✓ All sources exist" || exit 1
# List available and installed plugins
[group('plugins')]
list-plugins:
#!/usr/bin/env bash
echo "Available plugins:"
for d in context/plugins/*/; do
name=$(basename "$d")
[ "$name" = "TODO.md" ] && continue
installed=""
[ -f "{{ CLAUDE_DIR }}/plugins/$name.installed" ] && installed=" [installed]"
echo " $name$installed"
done
# Add feedback infrastructure to an existing plugin (non-destructive)
[group('plugins')]
add-feedback-infra name:
#!/usr/bin/env bash
set -euo pipefail
PLUGIN_DIR="context/plugins/{{ name }}"
TEMPLATE_DIR="context/plugins/.template"
if [ ! -d "$PLUGIN_DIR" ]; then
echo "Error: Plugin directory $PLUGIN_DIR not found"; exit 1
fi
if [ "{{ name }}" = ".template" ]; then
echo "Error: Cannot retrofit .template itself"; exit 1
fi
echo "Adding feedback infrastructure to {{ name }}..."
added=()
# Create docs directory if needed
mkdir -p "$PLUGIN_DIR/docs/src"
# Copy feedback-related files (non-destructive)
for file in CHANGELOG.md CONTRIBUTING.md docs/src/TROUBLESHOOTING.md docs/src/USAGE.md; do
src="$TEMPLATE_DIR/$file"
dest="$PLUGIN_DIR/$file"
if [ ! -f "$dest" ]; then
cp "$src" "$dest"
# Replace <plugin-name> placeholder with actual name
sed -i '' "s/<plugin-name>/{{ name }}/g" "$dest"
added+=("$file")
echo " + $file"
else
echo " - $file (exists, skipped)"
fi
done
# Update plugin.json to include feedback-submission.md in outputStyles
PLUGIN_JSON="$PLUGIN_DIR/.claude-plugin/plugin.json"
if [ -f "$PLUGIN_JSON" ]; then
if ! grep -q "feedback-submission.md" "$PLUGIN_JSON"; then
# Check if outputStyles exists and its type
if grep -q '"outputStyles"' "$PLUGIN_JSON"; then
if jq -e '.outputStyles | type == "array"' "$PLUGIN_JSON" > /dev/null 2>&1; then
# It's an array, append to it
jq '.outputStyles += ["../../output-styles/feedback-submission.md"]' "$PLUGIN_JSON" > "$PLUGIN_JSON.tmp"
mv "$PLUGIN_JSON.tmp" "$PLUGIN_JSON"
added+=("plugin.json (outputStyles updated)")
echo " + plugin.json (outputStyles updated)"
elif jq -e '.outputStyles | type == "string"' "$PLUGIN_JSON" > /dev/null 2>&1; then
# It's a string (directory path), convert to array with both
existing=$(jq -r '.outputStyles' "$PLUGIN_JSON")
jq --arg existing "$existing" '.outputStyles = [$existing, "../../output-styles/feedback-submission.md"]' "$PLUGIN_JSON" > "$PLUGIN_JSON.tmp"
mv "$PLUGIN_JSON.tmp" "$PLUGIN_JSON"
added+=("plugin.json (outputStyles converted to array)")
echo " + plugin.json (outputStyles converted to array)"
fi
else
# Add outputStyles field
jq '. + {"outputStyles": ["../../output-styles/feedback-submission.md"]}' "$PLUGIN_JSON" > "$PLUGIN_JSON.tmp"
mv "$PLUGIN_JSON.tmp" "$PLUGIN_JSON"
added+=("plugin.json (outputStyles added)")
echo " + plugin.json (outputStyles added)"
fi
else
echo " - plugin.json (feedback-submission.md already referenced)"
fi
fi
# Generate CHANGELOG from git history if plugin has commits
CHANGELOG="$PLUGIN_DIR/CHANGELOG.md"
if [ ${#added[@]} -gt 0 ] && [[ " ${added[*]} " =~ " CHANGELOG.md " ]]; then
# Check for plugin-specific git history
plugin_commits=$(git log --oneline -- "$PLUGIN_DIR" 2>/dev/null | head -20 || true)
if [ -n "$plugin_commits" ]; then
# Enhance CHANGELOG with git history
echo "" >> "$CHANGELOG"
echo "## Git History" >> "$CHANGELOG"
echo "" >> "$CHANGELOG"
echo "\`\`\`" >> "$CHANGELOG"
echo "$plugin_commits" >> "$CHANGELOG"
echo "\`\`\`" >> "$CHANGELOG"
echo " + CHANGELOG.md (enhanced with git history)"
fi
fi
# Report
if [ ${#added[@]} -gt 0 ]; then
echo ""
echo "✓ Feedback infrastructure added to {{ name }}"
echo " Files added/updated: ${#added[@]}"
else
echo ""
echo "✓ {{ name }} already has feedback infrastructure"
fi
# Add feedback infrastructure to all existing plugins
[group('plugins')]
add-feedback-infra-all:
#!/usr/bin/env bash
set -euo pipefail
echo "Adding feedback infrastructure to all plugins..."
echo ""
for d in context/plugins/*/; do
name=$(basename "$d")
[ "$name" = ".template" ] && continue
[ "$name" = "TODO.md" ] && continue
[ ! -d "$d" ] && continue
echo "=== $name ==="
just add-feedback-infra "$name"
echo ""
done
echo "✓ All plugins updated"
# Compute content-addressed hash for a file or directory
[group('plugins')]
plugin-hash path:
@"{{ which("uv") }}" run python .scripts/plugin-hash.py "{{ path }}"
# Verify a component hash matches expected value
[group('plugins')]
plugin-hash-verify path expected:
@"{{ which("uv") }}" run python .scripts/plugin-hash.py "{{ path }}" --verify "{{ expected }}"
# Verify all sources in a plugin's plugin.sources.json (exit 0=ok, 1=stale, 2=no-hash warning)
[group('plugins')]
plugin-verify-sources name:
#!/usr/bin/env bash
"{{ which("uv") }}" run python .scripts/plugin-hash.py --verify-sources "context/plugins/{{ name }}"
exit_code=$?
if [ $exit_code -eq 2 ]; then
echo "⚠ Warning: Plugin uses legacy format without hashes"
exit 0
fi
exit $exit_code
# Check plugin sources without prompts (for CI) — exit 0=fresh, 1=stale/missing