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 में बाँटें:
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 पढ़ने से रोकने के लिए ये उपाय करें:
- Secrets वाले सभी environment files को
.gitignoreमें जोड़ें। - वास्तविक values के बिना एक साफ़
.env.exampletemplate दें, ताकि agent को runtime secrets देखे बिना environment variables के नाम समझ आएँ। 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.
3. Git और commands को नियंत्रित करने की प्राथमिक checklist
Claude Code के साथ काम करते समय root-cause errors से बचने के लिए पहले यह क्रम लागू करें:
क्रमवार सुरक्षा नियम
- Step 1: Git mutations को gate करें।
git diff --checkऔर tests चलाए बिना agent कोmainमें direct push या commit न करने दें। - Step 2: package installation को अलग रखें।
npm install <package>,pip installया remotecurlscripts जैसे commands को manually verify करें, ताकि untrusted dependencies और supply-chain risks पर नियंत्रण रहे। - Step 3: बदलावों का scope सीमित करें। Agent को किसी तय feature folder या dedicated Git worktree तक सीमित रखें।
4. Test workspace में permissions की जाँच
महत्वपूर्ण repositories के लिए Claude Code को permissions देने से पहले sandbox validation करें:
- एक disposable branch बनाएँ:
git checkout -b test/permission-check. - एक dummy
.envfile जोड़ें, जिसमें केवल fake test secret हो। - Agent को authentication module refactor करने का task दें।
- जाँचें:
- क्या agent ने discovery के दौरान dummy
.envपढ़ी; - क्या कोई secret intermediate comments या
git diffमें पहुँचा; - क्या tests hidden files तक सीधी पहुँच के बिना चलते हैं।
- क्या agent ने discovery के दौरान dummy
- 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 न मानें।