# HOL Guard: Make Claude Code Ask Before It Installs a Package or Reads a Secret

> Install HOL Guard for Claude Code, publish the Safe defaults policy, then watch it hold an npm install for your OK, block a .env read and log both.

Source: https://learn.ynteractive.com/content/hol-guard-claude-code-ask-before-install-or-secret-read · Updated 2026-11-14 · Free from Stepthrough (https://learn.ynteractive.com)

## Practice it step by step

[Start the free practice](https://learn.ynteractive.com/modules/hol-guard-claude-code-human-approval)

[Take the free module: why it matters, practice and a quick check →](https://learn.ynteractive.com/courses/safe-ai-agents/9)

You do every step yourself in a practice copy of HOL Guard. It checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, about 8 minutes, and nothing touches your real accounts. [Open full screen](https://learn.ynteractive.com/modules/hol-guard-claude-code-human-approval)

Free · Live now · [AI Basics](https://learn.ynteractive.com/content/course/ai-basics) · HOL Guard · Claude Code · ~8 min · 8 steps · Advanced

Updated November 14, 2026. Built against the tool’s current screens and checked step by step. [How we check this lesson](https://learn.ynteractive.com/content/about#how-we-check)

An AI coding agent that can run shell commands can also run npm install on a package nobody checked, or cat .env in a client's repo. HOL Guard is a free, open-source (Apache-2.0), [local-first](https://learn.ynteractive.com/content/glossary#local-first) runtime control for AI coding agents: it checks shell commands, secret reads, package installs and MCP calls before they run, then allows, asks or blocks, and keeps a record. In this free lesson you play Priya, lead developer at Larkspur Digital, a made-up web agency, as [Claude](https://learn.ynteractive.com/content/tool/claude) Code starts work in a client's online-store repo. You add the laptop in the Guard [web app](https://learn.ynteractive.com/content/glossary/web-app), run the documented install and hol-guard install claude-code, publish the Safe defaults starter policy, then watch Guard hold an install for a person, block a .env read, and record both in Evidence. 8 steps, about eight minutes, no account needed to practice. The web screens are rebuilt from the real Guard app; the terminal screens come from HOL's docs and were not run here.

## At a glance

| Question | Answer |
| --- | --- |
| What you build | Let Claude Code work in a client repo without letting it install whatever it likes or read the .env. Install HOL Guard, hook it into Claude Code, publish the Safe defaults policy, then watch it hold an npm install for your OK, block a secret read, and log both. |
| Tools | HOL Guard |
| Time | About 8 minutes, 8 steps in 3 parts |
| Level | Advanced |
| Cost | Free |
| Ways to learn it | [Practice it step by step](https://learn.ynteractive.com/modules/hol-guard-claude-code-human-approval) |

### The 3 parts, in short

1. Install Guard: Add the machine Claude Code runs on, Copy the install command, Hook Guard into Claude Code.
2. Set the policy: Open Policy, Browse the starters, Use Safe defaults, Review and publish.
3. Watch it work: Approve the install, keep the secret blocked.

**Start here first:** [Start Here: How Stepthrough Works](https://learn.ynteractive.com/content/how-stepthrough-works) (module 1 of AI Basics)

**Part of:** Safe AI Agents: Approvals, Guardrails and Audit Trails (step 8 of 11). Next up: [How to Put PDF Invoices in Google Sheets with n8n, AI and an Approval Step](https://learn.ynteractive.com/content/invoice-inbox-to-google-sheets-approval-n8n)

**Part of:** [AI Apps Worth Knowing](https://learn.ynteractive.com/content/paths/partner-tools-ai-apps) (step 154 of 175). Next up: [SPIRITT: Get a Weekly KPI Report Every Monday Without Building It](https://learn.ynteractive.com/content/spiritt-weekly-kpi-report-from-stripe-and-hubspot)

## The business case: an agent with a shell is an agent that can install anything

Picture Priya Nair, lead developer at Larkspur Digital, a made-up twelve-person web and marketing agency. A retail client, Bramblewood Outfitters, wants a small change on its checkout page, and Priya lets [Claude](https://learn.ynteractive.com/content/glossary#claude) Code do it in the client's repo because that is faster than doing it by hand. The repo holds a .env with the store's payment keys. Claude Code runs shell commands to do its work, and a shell command can be npm install on a package from a publisher nobody has looked at, or cat .env. With example numbers you should replace with your own: one compromised dependency in a client build is a week of cleanup and an awkward call; one secret in a transcript is a key rotation and a disclosure.

HOL Guard puts a check in front of every one of those commands. Guard hooks into Claude Code, so each Bash, Read, Write, Edit and MCP call is evaluated before it runs: allowed, held for a person, or blocked, with the reason recorded. Priya keeps the speed of the agent and adds one click of human judgement where it matters.

## Who this is for, and what you need

Developers and technical leads at agencies, consultancies and product teams who let Claude Code (or Codex, Cursor, OpenCode and the other agents Guard supports) work in repos that hold client code or secrets, and the owners who want a record of what the agent did. The practice runs in your browser with no account. To do it for real you need a free HOL Guard account at hol.org/guard, a macOS, Linux or Windows x64 machine (check hol.org/guard/install for the current platform and installer status), and Claude Code installed on it.

## What the real Guard app shows, and what the docs say

In the Guard web app (captured on 10 November 2026 on a free account), Fleet has an Add a machine drawer with the macOS and Linux command, a Windows PowerShell line and hol-guard connect. Policy opens with defaults of Warn when nothing matches, Ask a person for an unknown publisher and Prompt mode; you can Add rule (Block, Ask a person or Allow; an installed item, a kind of action, everything, or one shell command; which AI tools; for how long), describe a rule in plain words, or Browse starters: Safe defaults, Package firewall, Secrets guard, MCP server guard, Team baseline and Blank. The YAML tab shows the same policy as a GuardPolicy document. Review lists the actions Guard paused before they ran, and Evidence is the proof ledger of every allow, warn and block with export.

On the machine, HOL's docs say hol-guard install claude-code writes Guard hook entries into the global ~/.claude/settings.json (PreToolUse and PermissionRequest hooks on Bash, Read, Write, Edit, WebFetch and every mcp__* tool), hol-guard doctor should show the daemon running and the intercept layer active, and a held action returns an approval URL in the block output so a person can approve or deny it from the local approval center on 127.0.0.1 or with hol-guard approvals approve or deny. Guard's default for a held action is Find a safe alternative; set blocked_request_mode = "ask" in ~/.hol-guard/config.toml to be asked instead. hol-guard [receipts](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets) and hol-guard events show the decisions locally, in ~/.hol-guard/guard.db.

## What this saves you

- The unchecked dependency: an install from a publisher Guard does not know waits for a person instead of landing in a client build.
- The leaked key: a prompt that reads environment variables is blocked outright, with no contents returned to the agent.
- The awkward question: Evidence and hol-guard receipts answer what the agent did in the client's repo with a record, not a memory.
- What it does not do: it does not review the code Claude Code writes. Guard checks actions, not quality; you still read the diff.

## How this lesson was built

The web screens in the practice copy (Fleet, Add a machine, Policy, its starters and Evidence) are rebuilt from the real HOL Guard web app at hol.org/guard, signed in on a free account on 10 November 2026, with the labels as shown there. The terminal screens are built from HOL's documentation (the install page, the Guard for Claude Code page, get-started, blocked-requests, approval-decision-wait and local-vs-cloud) read the same day; HOL Guard was not installed and those commands were not run on a real machine, so check each line against your own terminal. A version with the terminal steps run on a real machine is planned.

## Links

- [HOL Guard: Install](https://hol.org/guard/install): the install command for macOS and Linux, the Windows line, hol-guard doctor, and the platform table (macOS, Linux and Windows x64; check this page for the current platform and installer status).
- [HOL Guard docs: Guard for Claude Code](https://hol.org/guard/docs/guard/claude-code-harness): hol-guard install claude-code, the hooks it writes into ~/.claude/settings.json, the native-or-center approval tier, --dry-run and uninstall.
- [HOL Guard docs: Get started](https://github.com/hashgraph-online/hol-guard/blob/main/docs/guard/get-started.md): the approval URL in the block output, hol-guard approvals, receipts and events, ~/.hol-guard/config.toml and .hol-guard.toml.
- [HOL Guard docs: Blocked requests](https://github.com/hashgraph-online/hol-guard/blob/main/docs/guard/blocked-requests.md): the Find a safe alternative default and blocked_request_mode = "ask".
- [HOL Guard docs: Local vs Cloud](https://github.com/hashgraph-online/hol-guard/blob/main/docs/guard/local-vs-cloud.md): hol-guard connect, what stays local and what the optional Guard Cloud adds.
- [HOL Guard on GitHub](https://github.com/hashgraph-online/hol-guard): the source, the Apache-2.0 license and the pipx install route.

## Try it yourself, free

Reading the steps is a start. Doing them is how it sticks. The interactive module walks you through every click in a practice copy of HOL Guard, checks each step, and never touches your real accounts.

[Start “HOL Guard: Make Claude Code Ask Before It Installs a Package or Reads a Secret”](https://learn.ynteractive.com/modules/hol-guard-claude-code-human-approval)

## Step by step: HOL Guard: Make Claude Code Ask Before It Installs a Package or Reads a Secret

All 8 steps of the interactive module, in order. In the module you watch each one, then do it yourself in a practice copy that checks your work.

### 1. Install Guard

1. **Add the machine Claude Code runs on.** You are Priya Nair, lead developer at Larkspur Digital, a made-up 12-person web agency. Claude Code is about to work in a client's online-store repo, and that repo has a .env with the store's payment keys. You want a person to approve any package install, and no secret read at all. This is the Guard web app's **Fleet** page. Click **Add a machine**.
   You are Priya, lead developer at a small web agency. Claude Code is about to work in a client repo that holds payment keys. You want a person to approve any package install, and no secret reads at all. On the Fleet page, click Add a machine.
2. **Copy the install command.** The drawer shows the macOS and Linux command, a Windows PowerShell line (check hol.org/guard/install for the current platform and installer status) and **hol-guard connect** to link the machine to this workspace. Click **Copy command for macOS and Linux**. In this practice copy, your terminal opens next; nothing is installed here.
   The drawer shows the install command for macOS and Linux, a Windows line, and hol-guard connect to link the machine to this workspace.
3. **Hook Guard into Claude Code.** The install ran and **hol-guard connect** paired the laptop with the workspace (both from the docs). Now click **hol-guard install claude-code**. HOL's Claude Code page says this writes Guard hook entries into the global ~/.claude/settings.json, so Guard sees each Bash, Read, Write, Edit and MCP call before Claude Code runs it.
   The install ran and hol-guard connect paired the laptop with the workspace. It writes Guard hooks into Claude Code's settings, so Guard sees each command before it runs.

### 2. Set the policy

4. **Open Policy.** Back in the Guard web app, click **Policy** in the sidebar. The defaults read **When nothing matches: Warn**, **Unknown publisher: Ask a person**, **Mode: Prompt**, and there are no rules yet, so a .env read would only warn.
   Back in the Guard web app, click Policy in the sidebar. The defaults are Warn when nothing matches, Ask a person for an unknown publisher, and Prompt mode. There are no rules yet.
5. **Browse the starters.** Click **Browse starters**. Guard offers Safe defaults, Package firewall, Secrets guard, MCP server guard, Team baseline and Blank. **Safe defaults** 'blocks installs from unknown publishers and asks before AI tools touch secrets', and carries one rule: block prompts that read environment variables in every AI tool, permanently. That is exactly Priya's case.
   Safe defaults blocks installs from unknown publishers and asks before AI tools touch secrets, with one rule: block prompts that read environment variables in every AI tool. That is exactly our case.
6. **Use Safe defaults.** Under **Safe defaults**, click **Use this**. It replaces the empty draft: Rules 1. The header still says Not published, and the rule drawer's own words apply: nothing is enforced until you publish.
   Under Safe defaults, click Use this. It replaces the empty draft with one rule. Nothing is enforced until you publish.
7. **Review and publish.** Click **Review and publish**. The Defaults drawer notes that you choose the mode again when you publish; keep **Prompt**. This is the step that turns the draft into the policy Guard enforces. Next, Claude Code gets to work in the client repo.
   This is the step that turns the draft into the policy Guard enforces. Now Claude Code gets to work.

### 3. Watch it work

8. **Approve the install, keep the secret blocked.** Priya asked Claude Code to add a date helper. It tried **npm install date-fmt-helpers**: the publisher is one Guard does not know, so **Unknown publisher: Ask a person** held it, and the docs say the approval URL is in the block output. It also tried **cat .env**: the Safe defaults rule blocked it outright, no contents returned. Priya checks the package and decides it is fine. Click **hol-guard approvals approve <request-id>** (the approval center page on 127.0.0.1 has the same approve and deny). The install runs, the .env read stays blocked, and Evidence opens with both decisions. In your own account: create a free one at hol.org/guard, Add a machine, run the command it shows plus hol-guard connect and hol-guard install claude-code, then publish Safe defaults.
   Claude Code tried npm install on a package from a publisher Guard does not know, so Guard held it for a person. It also tried cat dot env, and the rule blocked it outright. Priya checked the package and it is fine. The install runs, the secret read stays blocked, and both decisions land in Evidence.

## Frequently asked questions

**How do I install HOL Guard for Claude Code?**

The install page gives one command for macOS and Linux: set -o pipefail; curl -fsSL https://hol.org/guard/install.sh | bash -s -- --mode install --verify, then hol-guard init (the GitHub README also lists pipx install hol-guard). Run hol-guard connect to link the machine to your Guard workspace, then hol-guard install claude-code, which HOL's docs say writes Guard hook entries into the global ~/.claude/settings.json. hol-guard doctor should show the daemon running and the intercept layer active.

**Does HOL Guard ask before Claude Code installs a package?**

With the Safe defaults starter published, the policy's Unknown publisher default is Ask a person, so an install from a publisher Guard does not know is held for a person; HOL's get-started doc says the approval URL is returned in the block output and the request is queued locally. Approve or deny it in the local approval center or with hol-guard approvals approve or deny <request-id>. Guard's default for a held action is to tell the agent to find a safe alternative; set blocked_request_mode = "ask" in ~/.hol-guard/config.toml to be asked.

**Does HOL Guard stop Claude Code reading .env?**

The Safe defaults, Secrets guard and Team baseline starters each include the rule Block prompts that read environment variables in every AI tool, permanently. HOL's docs also list other secret-bearing files Guard detects, such as ~/.ssh, ~/.aws/credentials, ~/.kube/config, .npmrc, .pypirc and Docker auth config.

**Where is the HOL Guard log?**

In the web app, Evidence is the proof ledger of every allow, warn and block with its reason, and Review keeps the history of decisions people made. On the machine, hol-guard receipts lists the decisions Guard recorded and hol-guard events shows the timeline; the docs say they are stored in ~/.hol-guard/guard.db.

**Was this lesson tested with HOL Guard installed?**

Not yet. The web screens come from the real Guard web app, signed in on a free account. The terminal steps come from HOL's public docs and were not run on a real machine, so check each command against your own screen.

**Is HOL Guard free?**

The local runtime is free and open source under Apache-2.0. Guard Cloud, which adds cloud history, sync and team features, is an optional paid service; the lesson uses the free account and the local runtime.

[Start this module free](https://learn.ynteractive.com/modules/hol-guard-claude-code-human-approval)

- Previous in AI Basics: [Catch a Poisoned Email Before Your AI Assistant Obeys It using Claude](https://learn.ynteractive.com/content/catch-a-poisoned-email-before-your-ai-assistant-obeys-it)
- Next in AI Basics: [How AI Answers from Your Documents: Retrieval (RAG) Explained](https://learn.ynteractive.com/content/how-ai-answers-from-your-documents)

## More in AI Basics

- [Start Here: How Stepthrough Works](https://learn.ynteractive.com/content/how-stepthrough-works): Try the practice in under two minutes: watch a step, click, type, get unstuck with Do it for me, and finish.
- [How to Get ChatGPT in Agent Mode: AI Agent vs Chatbot vs Automation](https://learn.ynteractive.com/content/ai-agent-vs-chatbot-vs-automation): Chase six unpaid invoices three ways: a chatbot writes a template, an automation follows a rule, and an AI agent works out the steps and flags the tricky one.
- [What Is a Webhook? Send a Test and Watch the Data Arrive](https://learn.ynteractive.com/content/what-is-a-webhook): Point a plumber's website contact form at a free webhook tester, send a test and a real message, and watch the data arrive the moment it's sent.
- [Automation Basics: Triggers, Actions and Data Mapping](https://learn.ynteractive.com/content/automation-triggers-actions-mapping): Learn the three ideas behind every n8n workflow, Make scenario and Zap: a trigger starts it, actions do the jobs, and data mapping carries the details. Fix the classic…
- [When to Add AI to an Automation (n8n, Make or Zapier)](https://learn.ynteractive.com/content/when-to-add-ai-to-automation): Sort six office jobs into plain rules, AI steps and human decisions, then see the safe shape of an AI automation and how n8n, Make and Zapier each add the AI step.
- [Your First AI Automation: Pick the Right Job and Test It Before It Runs](https://learn.ynteractive.com/content/first-ai-automation-what-to-automate-first-and-how-to-test): Most first automations fail because people pick the wrong job or switch it on untested. Score four repeat jobs, pick the one to automate first, add one small AI step…

[All 25 modules in AI Basics](https://learn.ynteractive.com/content/course/ai-basics)

## Terms in this lesson

Plain-English definitions, each with an example from a free lesson.

[Local-first software](https://learn.ynteractive.com/content/glossary#local-first) · [Claude](https://learn.ynteractive.com/content/glossary#claude) · [Web app](https://learn.ynteractive.com/content/glossary/web-app) · [Prompt](https://learn.ynteractive.com/content/glossary/prompt) · [Model Context Protocol (MCP)](https://learn.ynteractive.com/content/glossary) · [General ledger](https://learn.ynteractive.com/content/glossary)

[The full AI glossary](https://learn.ynteractive.com/content/glossary)

## Browse related tutorials

[AI Basics (25)](https://learn.ynteractive.com/content/course/ai-basics)

**Get the badge / embed this lesson**
