Claude Code Permission Budget Loop: permissions, cost और logs 5 मिनट में check करें
Claude Code में allow/deny rules, cost limit, execution log और team handoff के लिए practical loop.
हर सुबह पांच मिनट क्यों जरूरी हैं
Claude Code के साथ असली operational सवाल केवल यह नहीं है कि agent code लिख सकता है या नहीं। असली सवाल है: उसे बिना पूछे क्या करने देना चाहिए? हर Bash command approve करना शुरुआत में safe लगता है, लेकिन कुछ समय बाद approval fatigue आ जाती है। दूसरी तरफ सब कुछ allow करना ज्यादा खतरनाक है: .env पढ़ना, package install, git push, production deploy, database migration और billing changes एक ही lane में आ सकते हैं।
Permission budget एक छोटी operating table है। इसमें लिखा होता है कि Claude Code कौन से काम बिना approval कर सकता है, कौन से काम human approval के बाद करेगा, और कौन से काम इस repository में कभी नहीं होंगे। Loop का मतलब है कि हर सुबह इस table को पिछले दिन के execution log और usage से मिलाया जाए। आसान भाषा में, आपने agent को जो keys और wallet दिए हैं, उन्हें रोज गिनना।
3 जून 2026 को official docs verify करने पर Claude Code permissions में allow, ask और deny rules हैं; deny की priority ask और allow से ऊपर है। /permissions active rules और उनकी settings file दिखाता है। Cost के लिए /usage local/session view देता है, जबकि billing और workspace limits के लिए Claude Console authoritative source है। Official links: Configure permissions, Claude Code settings, Manage costs effectively, और CLI reference।
Internal reading के लिए इसे Claude Code permissions guide, permission audit checklist और permission receipt pattern से जोड़ें।
Basic बात, security jargon के बिना
Claude Code permissions model की इच्छा नहीं, CLI की enforced boundary हैं। CLAUDE.md में “secrets मत पढ़ो” लिखना useful guidance है, लेकिन boundary नहीं। Read(./.env) या Read(./secrets/**) जैसी deny rule boundary है जिसे Claude Code enforce कर सकता है।
Permission modes भी अलग समझें। default normal approval flow है। plan reading और investigation के लिए अच्छा है। acceptEdits file edits को smoother बनाता है। dontAsk उन tools को deny करता है जो pre-approved नहीं हैं या ask में नहीं हैं। bypassPermissions, यानी --dangerously-skip-permissions, prompts skip करता है और isolated container या VM जैसे environment में ही रखना चाहिए।
Cost भी इसी तरह manage करें। /usage एक expensive local session पकड़ने में मदद करता है, लेकिन API billing Claude Console में confirm करें। Scripted claude -p runs में --max-budget-usd और --max-turns helpful guardrails हैं; ये team budget का replacement नहीं हैं।
Daily permission budget loop
Routine छोटी रखें ताकि repeat हो सके। Goal perfect audit नहीं है; goal यह है कि दिन की शुरुआत dangerous permission open छोड़कर न हो।
| Step | Check | Pass condition |
|---|---|---|
| 1 | /permissions | Bash(*) या बहुत broad Bash(npm *) rule नहीं |
| 2 | .claude/settings.json | secrets, deploy, database और billing ask या deny में हैं |
| 3 | /usage और Console | कल का spend explainable है |
| 4 | git diff और execution log | Approved work diff से match करता है |
| 5 | handoff note | Open allowances, blocked actions और next reviewer लिखे गए हैं |
Short starter prompt:
Before starting today's Claude Code work, classify the task into:
1. safe to run without approval
2. requires human approval
3. should not run in this session
Then list up to five checks for /permissions, /usage, and git diff.
Shared settings.json starter
यह .claude/settings.json practical starting point है। defaultMode: "dontAsk" strict है: जो tool allow या ask-first में नहीं है, वह नहीं चलेगा। इसे shared project default बनाने से पहले local में test करें।
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"defaultMode": "dontAsk",
"allow": [
"Bash(npm run lint)",
"Bash(npm run test)",
"Bash(npm run test *)",
"Bash(npm run build)",
"Bash(git status)",
"Bash(git diff)",
"Bash(git diff *)",
"WebFetch(domain:code.claude.com)"
],
"ask": [
"Bash(npm install *)",
"Bash(pnpm add *)",
"Bash(git push *)",
"Bash(wrangler deploy *)",
"Bash(vercel deploy *)",
"Bash(terraform apply *)",
"Bash(kubectl apply *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Bash(curl *)",
"Bash(wget *)",
"Bash(rm -rf *)"
]
}
}
Important point exact command list नहीं, बल्कि safe lane को narrow रखना है। Bash(npm *) test से install या publish तक जा सकता है। Bash(git *) diff से push तक जा सकता है। Read, lint, test और build को narrow allow करें; install, push, deploy और apply को human gate में रखें।
Budget और execution log JSON में रखें
Permissions आधा loop हैं। दूसरा आधा cost है। लंबी investigation, repeated failing tests, background sessions और बड़े logs धीरे-धीरे महंगे हो सकते हैं। इसलिए छोटा budget file और daily log रखें।
{
"date": "2026-06-03",
"dailyLimitUsd": 6,
"warnAtUsd": 4,
"usageSource": "/usage plus Claude Console",
"safeAllow": [
"Bash(npm run lint)",
"Bash(npm run test)",
"Bash(git diff *)"
],
"askFirst": [
"Bash(npm install *)",
"Bash(git push *)",
"Bash(wrangler deploy *)"
],
"mustDeny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
],
"handoffRequired": true
}
{
"date": "2026-06-03",
"spentUsd": 1.85,
"usageChecked": true,
"settingsChecked": true,
"permissionsReviewed": [
"/permissions",
".claude/settings.json"
],
"openAllowances": [
"Bash(npm run lint)",
"Bash(npm run test *)"
],
"handoff": [
"No deploy allowance left open",
"Claude stopped before production data work"
]
}
इन्हें .claude/permission-budget.json और .claude/daily-claude-log.json में रखें। Spreadsheet reporting के लिए ठीक है, लेकिन JSON PR review और automation के लिए बेहतर है।
Copy-paste Node audit script
इसे scripts/audit-claude-loop.mjs के रूप में save करें और node scripts/audit-claude-loop.mjs चलाएं। External dependency नहीं है। Script broad Bash access, allow में deploy commands, missing .env deny, budget overrun और handoff missing जैसी समस्याएं पकड़ता है।
#!/usr/bin/env node
import fs from "node:fs";
const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
const budget = readJson(".claude/permission-budget.json");
const log = readJson(".claude/daily-claude-log.json");
const settings = readJson(".claude/settings.json");
const problems = [];
const permissions = settings.permissions ?? {};
const allow = new Set(permissions.allow ?? []);
const ask = new Set(permissions.ask ?? []);
const deny = new Set(permissions.deny ?? []);
const hasPattern = (items, pattern) => [...items].some((item) => pattern.test(item));
if (typeof budget.dailyLimitUsd !== "number" || budget.dailyLimitUsd <= 0) {
problems.push("dailyLimitUsd must be a positive number");
}
if (typeof budget.warnAtUsd !== "number" || budget.warnAtUsd >= budget.dailyLimitUsd) {
problems.push("warnAtUsd must be lower than dailyLimitUsd");
}
if (log.spentUsd > budget.dailyLimitUsd) {
problems.push(`spentUsd ${log.spentUsd} exceeds daily limit ${budget.dailyLimitUsd}`);
}
if (log.spentUsd >= budget.warnAtUsd) {
console.warn(`WARN: spentUsd ${log.spentUsd} has reached warnAtUsd ${budget.warnAtUsd}`);
}
if (!log.usageChecked) problems.push("Run /usage and mark usageChecked true");
if (!log.settingsChecked) problems.push("Review /permissions and mark settingsChecked true");
if (allow.has("Bash") || allow.has("Bash(*)") || hasPattern(allow, /^Bash\(\*.*\)$/)) {
problems.push("Do not allow every Bash command");
}
if (hasPattern(allow, /(deploy|terraform apply|kubectl apply|git push)/)) {
problems.push("Deploy, infrastructure, and push commands must be ask-first, not allow");
}
for (const rule of budget.askFirst ?? []) {
if (!ask.has(rule)) problems.push(`Missing ask rule: ${rule}`);
}
for (const rule of budget.mustDeny ?? []) {
if (!deny.has(rule)) problems.push(`Missing deny rule: ${rule}`);
}
if (!hasPattern(deny, /Read\(.*\.env/)) {
problems.push("Deny rules should block .env reads");
}
if (!Array.isArray(log.handoff) || log.handoff.length === 0) {
problems.push("Add at least one handoff note");
}
if (problems.length) {
console.error(problems.map((problem) => `- ${problem}`).join("\n"));
process.exit(1);
}
console.log("Claude Code daily permission budget check passed.");
CI में पहले warning या manual mode रखें। पहले दिन बहुत strict gate लगाने से लोग workaround खोजते हैं।
चार concrete use cases
पहला use case article और documentation update है। Markdown, MDX, internal links, CTA, typo fixes और image paths आम तौर पर secrets या production को touch नहीं करते। File read, git diff, lint, tests और local build को narrow allow करने से Claude Code बिना बेकार रुकावट के small diff बना सकता है।
दूसरा use case dependency changes है। npm install और pnpm add lockfile, postinstall scripts, licenses, vulnerabilities और bundle size को affect करते हैं। इन्हें ask में रखें। Approval से पहले Claude Code से reason, alternative और removal plan लिखवाएं।
तीसरा use case deploy और migration है। wrangler deploy, vercel deploy, terraform apply, kubectl apply और database migrations external state बदलते हैं। Claude Code command, impact, rollback, verification URL और monitoring checklist draft कर सकता है, लेकिन execution human approval से होना चाहिए।
चौथा use case team handoff है। अगर कोई दूसरा सदस्य बाद में काम जारी करेगा, तो open allowances, proof commands, blocked actions और remaining budget लिखें। Handoff न हो तो अगला व्यक्ति वही investigation दोहराता है और वही risky permission फिर खोलता है।
बचने वाली गलतियां
सबसे common गलती broad Bash permission है। Bash(npm *) और Bash(git *) convenient लगते हैं, लेकिन read-only habits को state-changing commands से मिला देते हैं। Daily lane के लिए exact commands बेहतर हैं।
दूसरी गलती forgotten deploy allowance है। Incident के दौरान wrangler deploy * ask से allow में जा सकता है। अगर यह अगली सुबह भी open है, तो normal feature work को production power मिल जाती है।
तीसरी गलती token और cost growth ignore करना है। Long investigation productive लग सकती है, लेकिन budget जला सकती है। /usage देखें, billing important हो तो Console से compare करें, और बेकार sessions stop करें।
आखिर में, prompt को enforcement न समझें। “Secrets मत पढ़ो” guidance है। Read(./.env) in deny enforcement है। Harness, यानी agent का काम करने का ढांचा, prompt, settings, logs और review साथ मांगता है।
Products, training और rollout
Solo practice के लिए JSON files और script छोटे repo में copy करें। Reusable checklists, CLAUDE.md templates और review prompts के लिए /products/ देखें। Team rollout में permissions, cost control, CI policy, reviewer training और repository-specific rules चाहिए तो /training/ देखें।
Practice note (実際に試した結果): सबसे बड़ा improvement हर risky command block करने से नहीं आया। Improvement हर सुबह पांच मिनट /permissions, /usage, git diff और handoff note देखने से आया। Narrow allow rules useful रहे, और deploy, billing तथा secrets reliably ask या deny में लौटे।
मुफ़्त PDF: Claude Code cheatsheet
Email डालें और commands, review habits तथा safe workflow वाली एक-page PDF पाएँ.
हम आपका data सुरक्षित रखते हैं और spam नहीं भेजते.
लेखक के बारे में
Masa
Claude Code workflow और team adoption पर काम करने वाला engineer.
संबंधित लेख
Claude Code permission safety ladder: access धीरे-धीरे बढ़ाएं
read-only से limited edits, proof commands और deploy checks तक permission बढ़ाने की सुरक्षित ladder.
Claude Code Small PR Proof Pack: छोटे PR को review-ready बनाना
Claude Code PR के लिए diff, checks, public URL, CTA path और rollback वाला practical proof pack.
Claude Code Review Gate Before Commit: diff, test, public URL और CTA जांच
Claude Code से commit से पहले review gate बनाएं: diff, build, public URL, Gumroad, consultation, tests और unrelated files।