2026-07-25 13:05:18 +07:00
#!/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)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] TypeScript file — apply typescript skill rules (strict types, no-any, proper generics)"
2026-07-25 13:05:18 +07:00
;;
py)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] Python file — apply python skill rules (type hints, PEP 8, no wildcard imports)"
2026-07-25 13:05:18 +07:00
;;
rs)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] Rust file — apply rust skill rules (ownership, error handling, clippy clean)"
2026-07-25 13:05:18 +07:00
;;
go)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] Go file — apply go skill rules (idiomatic Go, interfaces, error handling)"
2026-07-25 13:05:18 +07:00
;;
js| jsx)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] JavaScript file — apply typescript skill rules (ESM, modern JS)"
2026-07-25 13:05:18 +07:00
;;
dockerfile| Dockerfile)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] Dockerfile — apply docker skill rules (multi-stage, minimal layers, no root)"
2026-07-25 13:05:18 +07:00
;;
yml| yaml)
2026-07-26 11:56:55 +07:00
echo "[hub-guide] YAML file — check ci-cd and docker skill rules"
2026-07-25 13:05:18 +07:00
;;
esac