whatisgithub

What is fence?

hoophq/fence — explained in plain English

Analysis updated 2026-05-18

18GoAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A safety tool that intercepts AI coding agent commands, blocking or asking to confirm dangerous ones like wiping a disk or leaking credentials.

Mindmap

mindmap
  root((Fence))
    What it does
      Blocks dangerous commands
      Asks before risky ones
      Stays quiet otherwise
    Tech stack
      Go
      CLI
      Hooks
    Use cases
      Guard Claude Code
      Guard Codex agents
      Custom safety rules
    Audience
      Developers
      AI agent users

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Stop an AI coding agent from running catastrophic commands like wiping a home directory or a disk.

USE CASE 2

Get a confirmation prompt before an agent runs a risky but sometimes legitimate command, like a forced git push.

USE CASE 3

Write custom YAML rules or install shared rulepacks to guard against project-specific dangerous commands.

What is it built with?

GoCLI

How does it compare?

hoophq/fence6mb/vohivegacjie/agent_flow
Stars181818
LanguageGoGoGo
Setup difficultyeasyhardeasy
Complexity2/54/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Windows is not natively supported yet, though it works inside WSL.

MIT license: free to use, modify, and distribute, including commercially, as long as the copyright notice is kept.

So what is it?

Fence is a safety layer for AI coding agents like Claude Code, Codex, and OpenCode. When one of these agents tries to run a command in your terminal, Fence checks it first and can block the command entirely, ask you to confirm it, or let it through silently, before the agent's action ever actually runs. The problem it addresses is that coding agents run with your own permissions on your machine, so a confused agent, or one tricked by a hidden instruction buried in a file it read, could delete your files, leak your credentials, or set up unwanted persistence with nothing stopping it. Simple keyword-blocking tools are easy to trick by rephrasing a command, and they tend to be so noisy that people turn them off. Fence instead looks at what a command actually does rather than matching text patterns, so it catches many different ways of writing the same dangerous command, such as wiping a home directory, while staying quiet on everyday commands like deleting a node_modules folder or force-pushing with a safety flag. Built-in protection covers things like wiping your home or root directory, wiping an entire disk, running a fork bomb, sending private keys or credentials out over the network, opening up file permissions system-wide, rewriting git history, and installing packages from untrusted sources. Some of these are blocked outright, while riskier but sometimes legitimate actions, like a forced git push, prompt you to confirm before continuing. Fence installs through Homebrew or npm, and for Claude Code a single command wires it into that tool's hook system for every project, showing a small status line confirming it is active. Similar one-line setup exists for Codex and OpenCode. You can also write your own custom rules in a YAML file, override how strict a built-in rule is, or install rule packs shared by others for tools like Terraform or Kubernetes. The project notes it fails open: if it cannot understand a command, that command is simply allowed to run rather than getting stuck, since a safety tool should never break the agent it is meant to protect. Windows is not yet natively supported, though it works normally inside WSL. The project is released under the MIT license.

Copy-paste prompts

Prompt 1
Walk me through installing Fence and wiring it into Claude Code with fence init --global.
Prompt 2
Show me how to write a custom .fence.yaml rule that blocks terraform destroy commands.
Prompt 3
Explain the difference between Fence's deny, ask, and allow verdicts with examples.
Prompt 4
Help me find and install a Fence rulepack for protecting a Kubernetes workflow.

Frequently asked questions

What is fence?

A safety tool that intercepts AI coding agent commands, blocking or asking to confirm dangerous ones like wiping a disk or leaking credentials.

What language is fence written in?

Mainly Go. The stack also includes Go, CLI.

What license does fence use?

MIT license: free to use, modify, and distribute, including commercially, as long as the copyright notice is kept.

How hard is fence to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is fence for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.