Foundry

Claude Code Hooks in Practice (Windows & PowerShell)

Learn how Claude Code tool hooks work on Windows, write a working PowerShell guardrail, and keep coding agents locked to your intended scope.

by Josh Bradford

About This Course

When you use Claude Code on a real codebase, prompt instructions alone are easy for an agent to forget mid-session. One drifted edit can touch config files, secrets, or unrelated modules you never meant to change.

Claude Code hooks solve this at the tool layer. Instead of hoping the model remembers your rules, a PreToolUse hook intercepts file writes and shell commands before they execute and blocks anything outside your approved scope.

In three short, hands-on lessons built specifically for Windows and PowerShell, you will learn how the hook lifecycle works, wire up a working scope guardrail in .claude/settings.json, and test your hook locally in seconds.

What You'll Learn

Lesson Outline

  1. 1. How Claude Code Hooks Intercept Agent ActionsFree Lesson
  2. 2. Wiring a PowerShell Guardrail in .claude/settings.json
  3. 3. Testing and Debugging Your Hook Locally
  4. 4. Capstone: Build, Wire and Prove a Complete GuardrailCapstone

Before You Start

Prerequisites

Windows 10 or 11 with PowerShell, Claude Code installed, and basic familiarity with running commands in a terminal and editing JSON files.

Software & Tools
  • Claude Code
  • Windows PowerShell 5.1+ / 7+

Code & Asset Reuse

Code and Workflows — Project Use

View License Terms

The purchaser may use, modify and incorporate this code, template, plugin or workflow in personal, client and commercial projects. Source may be shared with necessary collaborators and distributed as an integrated part of a larger project. Do not resell substantially the same standalone source product or remove required notices. Supplied third-party components retain their original licenses; copyleft, attribution, source-disclosure and redistribution rights or obligations are not overridden by this template. The listing must identify dependencies and any separately required services, subscriptions or usage costs.

Free

4 lessons

Sign In to Enroll Read the Free Lesson
AI Disclosure
AI-Assisted Writing · AI-Assisted Images
Purchase & Refund Terms

Version 7 & Update History

Update History

Learner Reviews

Loading Content…
Sign In to Report