惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
T
Tenable Blog
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Security Latest
Security Latest
P
Privacy & Cybersecurity Law Blog
Google Online Security Blog
Google Online Security Blog
SecWiki News
SecWiki News
P
Palo Alto Networks Blog
TaoSecurity Blog
TaoSecurity Blog
Webroot Blog
Webroot Blog
Spread Privacy
Spread Privacy
O
OpenAI News
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
C
Check Point Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
人人都是产品经理
人人都是产品经理
S
Security @ Cisco Blogs
Scott Helme
Scott Helme
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
T
Troy Hunt's Blog
W
WeLiveSecurity
GbyAI
GbyAI
N
News | PayPal Newsroom
Y
Y Combinator Blog
C
Cisco Blogs
H
Help Net Security
The GitHub Blog
The GitHub Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 【当耐特】
Jina AI
Jina AI
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
云风的 BLOG
云风的 BLOG
小众软件
小众软件
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Claude Code Hooks vs Skills: When to Use Which
Ravi Patel · 2026-05-27 · via DEV Community

Originally published on rikuq.com. Republished here for Dev.to's readers.

Claude Code shipped Hooks and Skills near each other in 2026, and they get conflated. They solve different problems and the wrong choice burns context, breaks reliability, or both.

The 30-second answer: Hooks run on lifecycle events whether you want them to or not. Skills run when Claude decides they're relevant. That single distinction tells you which one to pick almost every time.

TL;DR

Hooks Skills
What Shell commands the harness runs on lifecycle events Markdown bundles Claude loads on demand
Trigger Fixed event points (pre-commit, post-tool-use, prompt-submit, session-stop, ...) Claude matches a user request to a skill's description
Determinism Deterministic — runs every time the event fires Probabilistic — runs when Claude judges it relevant
Best for Guardrails, telemetry, auto-format, blocking unsafe actions Reusable procedures, multi-step workflows, codified expertise
Failure mode Can block the action that fired it Claude might forget to invoke it
Lives in settings.json (project-local or user-global) A directory with a SKILL.md, registered via a plugin manifest
Costs Negligible — runs out-of-band Eats some context per session for the skill descriptions

What Hooks actually are

A Hook is a shell command registered against a lifecycle event in settings.json. When the event fires, the harness runs your command with relevant context as environment variables. Your command does its thing and exits — exit 0 means continue, non-zero means stop.

The event surface in 2026 (the ones I actually use):

  • prompt-submit — fires when you hit enter on a prompt
  • pre-tool-use / post-tool-use — fires around every tool invocation
  • pre-commit — fires before git commit (when Claude is committing)
  • session-stop — fires when a session ends

That's most of what you need. The full list is in the docs; these five cover 90% of real setups.

Real example #1: strip em dashes from commit messages (pre-commit)

Cloudflare Pages and a bunch of MTAs reject UTF-8 em dashes in commit messages with cryptic "invalid commit message" errors. I lost an afternoon to this exact problem on rikuq. Now it's a one-line hook:

{
  "hooks": {
    "pre-commit": [
      "sed -i '' 's/—/--/g; s/–/-/g' $CLAUDE_COMMIT_MSG_FILE"
    ]
  }
}

Enter fullscreen mode Exit fullscreen mode

Runs every commit. Never costs context. Never fails because Claude "forgot."

Real example #2: log expensive tool calls (post-tool-use)

For FinOps tracking on Claude Max, I want a running ledger of which sessions hit which expensive tools (anything that calls an external API or runs a long process). Hook fires after every tool:

{
  "hooks": {
    "post-tool-use": [
      "node ~/.claude/hooks/log-tool.mjs"
    ]
  }
}

Enter fullscreen mode Exit fullscreen mode

The script appends one JSON line per tool call to ~/.claude/tool-log.jsonl with tool name, duration, exit code. Weekly I jq over it to see where Claude's spending time. This is the kind of telemetry you want collected automatically — making it a skill would mean Claude has to remember to log, which is a worst-of-both-worlds outcome.

Real example #3: refuse writes outside the project (pre-tool-use)

A loose Claude session can occasionally try to write to a sibling project's directory by mistake (especially when juggling multiple worktrees). One pre-tool-use hook closes that:

#!/usr/bin/env bash
# ~/.claude/hooks/no-cross-project.sh
if [[ "$CLAUDE_TOOL_NAME" == "Write" || "$CLAUDE_TOOL_NAME" == "Edit" ]]; then
  case "$CLAUDE_TOOL_PATH" in
    "$PWD"/*) exit 0 ;;
    *) echo "blocked: write outside project root ($PWD)"; exit 1 ;;
  esac
fi

Enter fullscreen mode Exit fullscreen mode

Exit 1 blocks the write. Claude sees the error and asks me what I want to do. This is the use case Hooks exist for — deterministic enforcement of a constraint that should never bend.

What Skills actually are

A Skill is a directory containing a SKILL.md markdown file plus any optional helper scripts. The markdown opens with a description Claude uses to decide whether the skill is relevant to the current request. When Claude decides yes, it reads the full skill body and follows the instructions.

The trigger model is the key thing to internalize. Skills don't fire on events. They fire when Claude matches your description to a user message. So the description's specificity matters more than the body — a vague description means Claude won't reliably invoke the skill; an overly specific description means it'll be skipped when it would have been useful.

Real example #1: the content-publish skill

I have a content-publish skill that lives in a shared npm package (@ravirdp/content-ops). Its description starts: "Publish an approved brief end-to-end inside the current project's repo. Reads brief from project's SQLite DB, writes MDX...". When I say "publish brief 20," Claude matches that to the skill and follows its body — which is a 200-line procedure: load config, verify the brief is approved, write the MDX, generate the hero image, commit, push, open PR, merge, run post-publish hooks, update trackers.

If that were a Hook, there'd be no event for "the user wants a blog post written." Skills are right when the work is procedural but its invocation depends on intent.

Real example #2: an SEO audit skill

A seo-audit skill I use across projects. Description: "Run a full SEO audit on a project — GSC ranks, on-page issues, internal-link gaps, GEO citation status. Use when the user asks to audit a site or check why traffic dropped." Body walks through the data pulls and writes a markdown report.

I invoke it once a week per project. A Hook would be wrong — there's no lifecycle event that means "Friday afternoon, do an SEO audit." Skills are right when the cadence is human-driven.

Real example #3: deploy-readiness check

A deploy-readiness skill. Description: "Pre-deployment checklist: run tests, scan for hardcoded secrets, verify env vars are set, confirm migrations apply cleanly. Use before deploying to production." When I say "I'm about to deploy, check we're good," Claude invokes it.

Could be a Hook on pre-tool-use for the deploy command? Maybe. But deploys come from many surfaces (Cloudflare dashboard, wrangler deploy, GitHub Action) and the checklist evolves frequently. A Skill that Claude can update over time beats a brittle Hook trying to intercept every deploy path.

Decision tree: which one for what

Is the work tied to a specific lifecycle event
(commit, tool use, session end, etc.)?
│
├── Yes ──> Should it run every time, regardless of intent?
│           │
│           ├── Yes ──> HOOK
│           │
│           └── No  ──> Skill (and trigger via conversation)
│
└── No  ──> Should Claude decide when it's relevant?
            │
            ├── Yes ──> SKILL
            │
            └── No  ──> Neither — just a regular script you run by hand

Enter fullscreen mode Exit fullscreen mode

If you find yourself answering "Yes" to both branches, the work probably wants both: a Hook for the deterministic part (telemetry, guardrails) and a Skill for the procedural part (the actual workflow Claude executes).

The 3 anti-patterns I see most

1. The "Hook that requires intelligence." Trying to use a Hook to do something that needs to look at the surrounding context — like a pre-commit hook that decides whether to bump the version number based on the commit's content. Hooks run shell commands; they don't get Claude's reasoning. If logic is needed, expose the logic as a Skill and let Claude trigger it.

2. The "Skill that should fire automatically." Defining a Skill for "auto-format the file after every edit." That's a Hook (on post-tool-use filtered to Edit). Skills run when Claude decides; you don't want format-on-save to depend on whether Claude noticed.

3. The "Skill description that's too vague to match." Writing description: "Helps with content". Claude has no way to know when this is relevant. Descriptions need to be specific about what the skill does AND when to use it. Look at how Anthropic ships their first-party skills — every description has the shape "do X. Use when the user asks Y."

What I have configured today

The shape of my project-local settings.json for rikuq, with the hooks removed for brevity:

{
  "hooks": {
    "pre-commit": ["sed -i '' 's/—/--/g; s/–/-/g' $CLAUDE_COMMIT_MSG_FILE"],
    "post-tool-use": ["node ~/.claude/hooks/log-tool.mjs"],
    "pre-tool-use": ["bash ~/.claude/hooks/no-cross-project.sh"]
  }
}

Enter fullscreen mode Exit fullscreen mode

Three hooks. All deterministic, all about guardrails or telemetry.

For skills, I install one plugin globally — @ravirdp/content-ops — which provides:

  • content-research — surface keyword opportunities, write briefs as pending
  • content-publish — ship an approved brief end-to-end

Plus a seo-audit and a deploy-readiness skill I maintain in a personal plugin.

That's it. Five hooks, four skills. The temptation is to add more — every new piece of Claude friction looks like a hook or skill opportunity. Most of the time, it isn't. Most friction is solved by writing a better prompt or adding a sentence to the project's CLAUDE.md. Hooks and skills are reserved for the small set of things that genuinely need to be codified.

Who should pick which

  • You're hitting the same friction every commit / every tool call / every session — Hook. Deterministic. Cheap. Out of context.
  • You're describing the same multi-step workflow to Claude every time — Skill. Write it once, let Claude invoke it.
  • You want to enforce something Claude shouldn't be able to override — Hook. Skills can be skipped; Hooks block.
  • You want Claude to surface a procedure when relevant but skip it when not — Skill. The probabilistic invocation is the feature, not the bug.

What's next

If you're standing up a Claude Code setup from scratch in 2026, my unbiased starting recommendations are in Claude Code Review 2026 — From Zero Code to 3 Live SaaS. If you're comparing Claude Code against Cursor, the right framing is in Cursor vs Claude Code 2026. And if you want to see what a real production stack looks like behind one of these solo-founder operations, How I Run 3 Production AI SaaS on $5/Month of Hosting is the operational counterpart to this post.

The pattern across all of them is the same: pick the simplest abstraction that does the job. Hooks for the deterministic things. Skills for the procedural things. Everything else is a prompt.