Files
asepharyana-hub-guide/hooks/scripts/detect-file-type.sh
T
asepharyana e513cddd68 feat(hub-guide): expand plugin with 26 best-practice skills, hooks, and references
Transform hub-guide from a single-skill Hub monorepo guide into a
comprehensive programming best-practice plugin covering all situations.

Skills (26):
- Core: engineering-principles, clean-code, clean-architecture,
  design-patterns, testing, error-handling, security, api-design,
  git-workflow, documentation, logging-observability, performance
- Languages: typescript, python, rust, go
- Frameworks: react-frontend, elysiajs, hono-backend, drizzle-database, nextjs
- Infrastructure: docker, ci-cd, monitoring
- Monorepo: monorepo, hub-guide (existing)

Hooks:
- SessionStart: auto-detect project type and activate relevant skills
- PreToolUse (Write|Edit): inject language-specific rules per file type

Reference files for deep dives:
- clean-architecture/references/solid.md (SOLID + component principles)
- design-patterns/references/catalog.md (full GoF catalog with examples)
- testing/references/mocks.md (test double taxonomy)

Restructure plugin to modern skills/ directory format.
2026-07-25 11:35:16 +07:00

34 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# hub-guide: detect file extension from tool input and suggest language-specific rules
# Runs before Write/Edit to inject best-practice context
TOOL_INPUT="$1"
# Extract file path from tool input (looks for "file_path" in JSON)
FILE_PATH=$(echo "$TOOL_INPUT" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
EXT="${FILE_PATH##*.}"
case "$EXT" in
ts|tsx)
echo "📐 [hub-guide] TypeScript file — apply typescript skill rules (strict types, no-any, proper generics)"
;;
py)
echo "📐 [hub-guide] Python file — apply python skill rules (type hints, PEP 8, no wildcard imports)"
;;
rs)
echo "📐 [hub-guide] Rust file — apply rust skill rules (ownership, error handling, clippy clean)"
;;
go)
echo "📐 [hub-guide] Go file — apply go skill rules (idiomatic Go, interfaces, error handling)"
;;
js|jsx)
echo "📐 [hub-guide] JavaScript file — apply typescript skill rules (ESM, modern JS)"
;;
dockerfile|Dockerfile)
echo "📐 [hub-guide] Dockerfile — apply docker skill rules (multi-stage, minimal layers, no root)"
;;
yml|yaml)
echo "📐 [hub-guide] YAML file — check ci-cd and docker skill rules"
;;
esac