"""PreToolUse hook on matcher 'Skill': writes a per-session flag so the skill-check hook knows a Skill was invoked at least once in this session. Reads hook input JSON from stdin. Silent on failure - never blocks the tool.""" import json import os import sys import tempfile def main() -> None: try: data = json.load(sys.stdin) except Exception: return sid = data.get("session_id") or "unknown" flag = os.path.join(tempfile.gettempdir(), f"claude-skill-{sid}.flag") try: with open(flag, "w", encoding="utf-8") as f: f.write(data.get("tool_input", {}).get("skill", "") or "") except Exception: return if __name__ == "__main__": main()