Claude Code अनुमतियाँ: .env, Git और खतरनाक कमांड को कैसे सुरक्षित रखें

Claude Code के लिए न्यूनतम अनुमतियाँ सेट करें: .env को अलग रखें, Git बदलाव नियंत्रित करें, खतरनाक कमांड रोकें और टेस्ट workspace में सुरक्षा जाँचें।

प्रोडक्शन रिपॉज़िटरी में Claude Code सेट करते समय अक्सर एक असहज विकल्प सामने आता है: हर छोटे read command की पुष्टि करते रहें, या पूरा bypass mode (--dangerously-skip-permissions) चालू कर दें और .env से secrets लीक होने, अनचाहे git push --force चलने या project dependencies टूटने का जोखिम लें।

दोनों छोर व्यावहारिक नहीं हैं। सुरक्षित AI coding का आधार least privilege है: read access, file changes, shell execution और version-control operations की सीमाएँ साफ़ रखें।


1. अनुमतियों का चार-स्तरीय नक्शा

Tools और commands को चार अलग-अलग access tiers में बाँटें:

स्तरऑपरेशनडिफ़ॉल्ट नीतिउदाहरण
1. कोड निरीक्षणworkspace files पढ़नाअनुमति (auto-approved)cat, grep, src/ में source files देखना
2. Secrets और config.env, keys, tokens तक पहुँचसख्ती से निषिद्ध.env*, id_rsa, *.pem, credentials.json
3. File editscode बदलना या लिखनाworkspace scope के भीतर अनुमतिwrite_to_file, replace_file_content
4. खतरनाक shell और Gitpackage managers, mutating Git commandsmanual approval अनिवार्यrm -rf, git push --force, npm publish, DROP TABLE

2. .env files और project secrets को अलग रखना

Transport Layer Security (TLS) API traffic को transit में encrypt करती है, लेकिन वह confidential credentials को model context window, error logs या handoff summaries में पहुँचने से नहीं रोकती।

Claude Code को private credentials पढ़ने से रोकने के लिए ये उपाय करें:

  1. Secrets वाले सभी environment files को .gitignore में जोड़ें।
  2. वास्तविक values के बिना एक साफ़ .env.example template दें, ताकि agent को runtime secrets देखे बिना environment variables के नाम समझ आएँ।
  3. CLAUDE.md या AGENTS.md में स्पष्ट boundary rule जोड़ें:

Secret Protection Rule

  • Never inspect, echo, or output contents from .env, .env.local, or private key files.
  • To check required configuration keys, inspect .env.example.
> [!IMPORTANT] > **API Key management**: Claude Code के लिए अपना API Key local environment में configure करें; उसे कभी repository files में commit न करें। सुरक्षित integration के लिए [BetterToken की Claude Code guide](https://docs.bettertoken.ai/ai-tools/claude-code) देखें और key को model requests में न भेजें। ---

3. Git और commands को नियंत्रित करने की प्राथमिक checklist

Claude Code के साथ काम करते समय root-cause errors से बचने के लिए पहले यह क्रम लागू करें:

Agent कोई command प्रस्तावित करता है │ ├─> क्या इसमें destructive pattern है (rm -rf, drop, force push)? │ └─> हाँ: इसे अस्वीकार करें या developer की निगरानी में manually चलाएँ │ └─> क्या यह .git internals, .env files या external networks को छूती है? │ ├─> हाँ: स्पष्ट कारण माँगें और command का scope सीमित करें │ └─> नहीं: target branch में execution की अनुमति दें

क्रमवार सुरक्षा नियम

  1. Step 1: Git mutations को gate करें। git diff --check और tests चलाए बिना agent को main में direct push या commit न करने दें।
  2. Step 2: package installation को अलग रखें। npm install <package>, pip install या remote curl scripts जैसे commands को manually verify करें, ताकि untrusted dependencies और supply-chain risks पर नियंत्रण रहे।
  3. Step 3: बदलावों का scope सीमित करें। Agent को किसी तय feature folder या dedicated Git worktree तक सीमित रखें।

4. Test workspace में permissions की जाँच

महत्वपूर्ण repositories के लिए Claude Code को permissions देने से पहले sandbox validation करें:

  1. एक disposable branch बनाएँ: git checkout -b test/permission-check.
  2. एक dummy .env file जोड़ें, जिसमें केवल fake test secret हो।
  3. Agent को authentication module refactor करने का task दें।
  4. जाँचें:
    • क्या agent ने discovery के दौरान dummy .env पढ़ी;
    • क्या कोई secret intermediate comments या git diff में पहुँचा;
    • क्या tests hidden files तक सीधी पहुँच के बिना चलते हैं।
  5. Boundaries सही मिलने पर test branch को साफ़ कर दें।

यह permission boundary secrets के अनजाने exposure का जोखिम घटाती है और agent को साफ़, सीमित दायरे में स्वायत्त रूप से काम करने देती है।

API भुगतान और balance

BetterToken पर API usage pay-as-you-go आधार पर bill होता है। भुगतान किया गया balance हर महीने अपने-आप समाप्त नहीं होता; promotional, trial, referral और redemption-code balances के अपने नियम हो सकते हैं। उपलब्ध payment methods, card restrictions, minimum amount, exchange rate, fee और crediting time भुगतान के समय console में जाँचें।

कीमत और usage calculation

Text-model usage में input, output और cache tokens को model की मौजूदा pricing और request record के अनुसार अलग-अलग दिखाया और bill किया जाता है। कोई cost estimate बनाने से पहले उस model की current pricing, लागू cache rules और token volumes देखें; पुराने rate card या fixed percentage को current price न मानें।

अपना LLM वर्कफ़्लो बेहतर बनाना चाहते हैं?

एक API से मॉडल जोड़ें, कुंजियाँ प्रबंधित करें और AI खर्च नियंत्रित करें।