spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / hooks / policy / decided-by-policy.ts
15 lines · 550 BRaw
1import type { Settings } from 'claude-code'
2
3/**
4 * A yes/no read off managed policy that fails closed: true (protect) when
5 * the read rejects or deciding throws.
6 *
7 * @param policy the memoized policy read (createPolicyMemo over the hook's
8 * `$.settings.read({ source: "policy" })`)
9 * @param decide the answer once the policy is read
10 * @returns what decide answers, else true
11 */
12export const decidedByPolicy = (
13 policy: Promise<Settings>,
14 decide: (policy: Settings) => boolean,
15): Promise<boolean> => policy.then(decide).catch(() => true)