Guard pack: default local denies (Shield KYA OSS)

Status: ships in 0.33.1. The eleven rules marked 0.35.0 in the shell table, and the ask outcome, ship in 0.35.0. The guard pack is a separate, default-on layer that runs after the never-list in never-list. The never-list is unchanged: its rules and rule ids stay, no setting lifts it, and it still runs first. The guard pack adds more destructive shell commands, more credential files, secret-shaped writes and secret exfiltration, and it has the config switches below.

The deny is local, offline and sub-second. Every other call is recorded, not blocked. Local hooks fail open: if kya breaks or times out, the call goes ahead. The hosted hook (--plane-config, preview) runs the same guard pack too, with the same rules and reason codes, and keeps its own fail-closed stance; see Hosted mode below.

What it blocks by default

A deny exits with code 2 and prints one line on stderr, for example:

KYA denied Bash: NEVER_SHELL (terraform-destroy). Run terraform plan -destroy and ask the user to run the destroy themselves. Ask the user; see docs/guard-pack.md.

The line carries the reason code, the rule id and what to do instead. It never carries the command, a path or the matched text. It does not say where the allowlist lives, because the agent reads this text and can write files.

Shell commands (NEVER_SHELL)

Checked on shell tools (Bash and the equivalents). Compound commands are split and every part is checked: &&, ||, ;, pipes, newlines, $(...), backticks, and the code given to bash -c, sh -c, zsh -c and eval. sudo, env VAR=x, command, nohup and time are skipped to find the real command.

Rule id What it denies
rm-root-home rm with recursive and force flags (-rf, -fr, -r -f, -Rf, --recursive --force) on /, /*, your home directory, any parent of it, or any parent of the project folder. Relative paths are resolved against the working directory, so rm -rf ../../* from ~/work/app is caught. A recursive rm of a parent folder of the project, with a relative path, is denied first by the never-list rule rm-recursive-home-or-system, even without -f. guardAllow cannot allow that case. A variable that is unset or empty in the hook’s environment counts too: rm -rf "$X/" runs rm -rf /.
terraform-destroy terraform destroy with any flags, terraform apply -destroy, tofu destroy.
sql-drop DROP TABLE, DROP DATABASE, DROP SCHEMA and TRUNCATE (any case) inside a psql, mysql, mariadb, sqlite3, mongosh or clickhouse-client command, including -c, -e and a heredoc. Files are not read. The rule reads SQL words only. A MongoDB db.dropDatabase() is not SQL: mongo-drop-database below stops it.
git-force-push git push with --force, -f (also inside -fu) or a +refspec, to any branch. Not --force-with-lease and not --force-if-includes, except on main, master, release* and prod*, where the never-list (git-force-push-protected-branch) denies those too.
git-delete-default-branch git push <remote> --delete main or master, git push <remote> :main, git branch -D main or master.
git-hard-reset-clean git reset --hard together with git clean -fdx (or -ffdx) in the same command.
docker-volumes docker volume rm, docker volume prune, docker system prune with --volumes or -a, docker compose down -v or --volumes, docker-compose down -v.
k8s-delete-ns kubectl delete namespace (or ns), and kubectl delete --all with -A or --all-namespaces.
cloud-delete aws ec2 terminate-instances, aws s3 rb ... --force, aws s3 rm ... --recursive, aws rds delete-db-instance and delete-db-cluster, gcloud projects delete, gcloud sql instances delete, az group delete.
railway-volume-delete railway volume delete, and the text volumeDelete in a curl, wget, http or xh call.
sql-delete-all Ask (0.35.0). DELETE FROM <table> with no WHERE in the same statement, in the same database clients as sql-drop. DELETE ... WHERE ... passes. A WHERE that is always true (WHERE 1=1) also passes: the rule reads words, not meaning.
prisma-migrate-reset Ask (0.35.0). prisma migrate reset with any flags, also through npx, pnpm exec, pnpm dlx or bunx. prisma migrate dev, deploy and status pass.
prisma-accept-data-loss Ask (0.35.0). prisma db push --accept-data-loss. prisma db push without the flag passes.
supabase-reset-linked 0.35.0. supabase db reset --linked, or with --db-url. supabase db reset against the local stack passes.
rm-project-wipe Ask (0.35.0). rm -rf (recursive and force) on ., ./, ./*, * or the absolute path of the working directory. The working directory is taken as the project folder. rm -rf dist, build, node_modules, .next, coverage and tmp pass, and so does rm -rf src/*. A cd to another folder earlier in the same command skips the relative targets, because the folder is then not the project folder.
rm-git-dir 0.35.0. rm -r (with or without -f) on the .git folder at the project root: .git, ./.git/, or its absolute path. A .git folder under node_modules or vendor passes.
mongo-drop-database 0.35.0. dropDatabase( in a mongosh or mongo command (--eval or a heredoc). find, insert and createIndex pass.
redis-flush 0.35.0. FLUSHALL or FLUSHDB in a redis-cli or valkey-cli command that names a server with -u or -h, unless every host it names is localhost, 127.0.0.1, ::1 or 0.0.0.0 (a unix:// URL counts as local). All -h and -u options are read, so -h localhost -h prod.example is remote. A variable (-u $REDIS_URL) counts as a remote server. The same commands with no host, or with a loopback host, pass.
fly-destroy 0.35.0. fly or flyctl volumes destroy, apps destroy and destroy <app>. fly volumes list and fly deploy pass.
vercel-remove 0.35.0. vercel remove or vercel rm, and vercel project rm, also through npx. vercel env ls and vercel deploy pass.
gh-repo-delete 0.35.0. gh repo delete, and gh api -X DELETE (also --method DELETE) on a path that starts with repos/. The endpoint is normalized first: a scheme and host (https://api.github.com), a GitHub Enterprise /api/v3 prefix, a leading slash and a query are removed. --method DELETE, -X DELETE, -XDELETE and -X=DELETE all count. gh repo view, gh pr ... and gh api with GET or POST pass.

The ask outcome (GUARD_ASK)

Some commands are routine on a local database or a scratch folder and catastrophic on a remote one, and the hook often cannot tell which. A deny would push developers to uninstall the hook. Four rules (sql-delete-all, prisma-migrate-reset, prisma-accept-data-loss, rm-project-wipe) therefore ask the person instead of denying. They are marked Ask in the table above.

Credential reads (NEVER_SECRET_READ)

The never-list already denies reads of ~/.ssh/id_*, ~/.aws/credentials, gcloud credential files, ~/.npmrc, ~/.netrc, ~/.git-credentials, .env and .env.* (not .env.example, .env.sample, .env.template), *.pem and *.key (rule ids secret-read-file and secret-read-shell). The guard pack adds these. It applies to the Read tool and to shell reads (cat, less, more, head, tail, cp, scp, rsync, base64, xxd, strings and similar, and < file).

Rule id File
secret-read-railway ~/.railway/config.json
secret-read-docker ~/.docker/config.json
secret-read-kube ~/.kube/config
secret-read-pypirc ~/.pypirc
secret-read-gh ~/.config/gh/hosts.yml
secret-read-azure anything under ~/.azure/
secret-read-gcloud anything under ~/.config/gcloud/
secret-read-key id_rsa*, id_ed25519*, id_ecdsa*, id_dsa* in any folder (not .pub)
secret-read-environ /proc/<pid>/environ

Public parts stay readable: ~/.ssh/*.pub, ~/.ssh/known_hosts, .env.example.

Secret-shaped writes (NEVER_SECRET_WRITE)

Checked on the text a Write, Edit or MultiEdit tool puts into a file (the text an edit removes is not checked), and on echo, printf, cat or tee that redirects into a file. The rule id names the kind and never the matched text. The trail row for a denied write has no summary and no preview.

Rule id Pattern
secret-write-aws AWS access key id: AKIA or ASIA plus 16 upper case letters or digits
secret-write-privkey a PEM private key header (RSA, OPENSSH, EC, DSA or plain)
secret-write-github ghp_ plus 36 letters or digits
secret-write-github-pat github_pat_ plus 60 or more characters
secret-write-slack xoxa-, xoxb-, xoxp-, xoxr- plus 10 or more characters
secret-write-stripe sk_live_ plus 20 or more characters

The string AKIA alone, a short ghp_ prefix and .env.example placeholders are fine. Documentation that quotes the AWS example key id will be denied; use guardAllow with a path for those files.

Exfiltration (NEVER_EXFIL)

A Bash command where env, printenv, a bare set, or a credential file (the lists above and in the never-list) is piped, redirected or passed (-d @file, --data-binary @file, -T file, -F file=@) into curl, wget, nc, ncat, socat, scp or rsync, to a host that is not loopback. Rule id exfil-<tool>, for example exfil-nc. Sending to localhost, 127.0.0.1 or ::1 is allowed.

Configuration

Keys in ~/.kya/config.json, the user-level file in your home directory:

Key Default Effect
shellNeverList true false turns off the shell rules above.
secretsGuard true false turns off credential reads and secret-shaped writes.
exfilGuard true false turns off the exfiltration rules.
guardAllow [] Entries that skip one rule for one exact case.

guardAllow entries have one of two shapes:

{
  "guardAllow": [
    { "rule": "terraform-destroy", "command": "terraform destroy -target=aws_instance.scratch" },
    { "rule": "secret-write-aws", "path": "~/work/app/docs/fixtures/**" },
    { "rule": "secret-read-railway", "path": "~/.railway/config.json" }
  ]
}

Only the user-level file is read. A project .kya/config.json ships with the repository and an agent can write it, so it can never lift a deny. KYA_HOME does not move the file either. The hook error fallback ignores the file entirely and uses the defaults.

A malformed file never breaks the hook: every key you got wrong keeps its default, the rest of the file still applies, and the trail gets one line (GUARD_CONFIG_INVALID, at most once an hour) saying the file was ignored.

An agent cannot change this file through its tools: a write to ~/.kya/config.json or its folder is denied as guard-config-write, and neither the switches nor guardAllow can turn that rule off. Edit the file yourself, in your own editor.

When a call is denied, the agent is told to ask you. Allowing an exact case is your decision, made in your own file.

Near-miss card

When the guard denies a call, you can make one image about it, with nothing private in it, and post it yourself. The card is made on your machine. Nothing is uploaded.

Hosted mode

The fail-closed hosted hook (kya hook --plane-config <file>, preview; see hosted-hook) evaluates the guard pack locally, before it calls the plane. The rules, rule ids, reason codes, deny text and guardAllow semantics are the same as above. What differs:

Where it runs

KYA supports 23 coding tools. Six have native hooks and get the guard on their own shell and file tools: Claude Code, Codex, Grok, Kimi Code, Gemini CLI and Copilot CLI. The other tools connect through the MCP gate or the command wrapper (kya wrap). Those paths evaluate the same rules, but only for calls that reach KYA; a tool that runs its own built-in shell without going through KYA is not seen. Cursor, for example, has no hook in this package, so its built-in shell is not guarded.

What it does not block

False positives you will see

The guard is a seatbelt, not a sandbox. It reads words and separators, it does not run a full shell parser, and a determined agent can get around it. The audit trail records what happened either way. For enforcement with human approval, use the hosted workspace.