Advanced (अपडेट किया गया: 19/5/2026)

Claude Code और Codex के लिए सुरक्षित Agent Harness: permissions, verification और rollback

Claude Code और Codex agents को सुरक्षित चलाने के लिए policy, plan, verification और recovery layers वाला practical harness design.

Claude Code और Codex के लिए सुरक्षित Agent Harness: permissions, verification और rollback

Powerful agents को safe rails चाहिए

Claude Code या Codex शुरू में prompt writing जैसा लगता है. छोटे बदलावों के लिए यह ठीक है. लेकिन जब agent deployment, SaaS APIs, local files, publishing या email sending करने लगे, तब असली समस्या prompt नहीं होती. असली समस्या होती है उसके चारों ओर बना execution harness.

इस article में Agent Harness का मतलब है वह बाहरी structure जो AI agent को सुरक्षित तरीके से काम कराता है: permissions, execution plan, verification checks, logs और rollback path.

Concept पहले समझना हो तो harness engineering guide देखें. Practical risk patterns के लिए Claude Code security failure cases भी useful है.

User request
  |
  v
Agent
  |
  v
[1] Policy layer       क्या allow, ask या deny होगा
[2] Plan layer         कौन सा step किस order में चलेगा
[3] Verification layer success कैसे prove होगा
[4] Recovery layer     failure के बाद वापस कैसे आएंगे
  |
  v
Files / shell / SaaS APIs / deploy

Claude Code की official documentation settings, permissions, hooks और MCP को अलग-अलग explain करती है. शुरुआत के लिए Claude Code settings, Hooks reference और MCP देखें.

Example: article publishing harness

“एक article publish करो” असल में कई steps का workflow है.

1. पिछले 7 दिनों का analytics पढ़ना
2. high-performing topic cluster के पास नया topic चुनना
3. existing articles से duplicate check करना
4. source article लिखना
5. सभी language versions बनाना
6. frontmatter, slug और internal links validate करना
7. site build करना
8. live URL check करना
9. commit और push करना

अगर यह plan explicit नहीं है, तो agent visible काम पूरा कर सकता है लेकिन translations, build या live check भूल सकता है.

SaaS integration: read, generate और send को अलग रखें

मान लें agent companies research करता है और outreach email draft करता है.

OperationAutomatic?Reason
Public pages read करनाYesLow impact
Local CSV save करनाYesReviewable
Sample page generate करनाYesPublish से पहले check कर सकते हैं
Email draft करनाYesअभी send नहीं हुआ
Email send करनाApprovalExternal irreversible action

Agent Harness का core यही है: read, draft, publish और send को अलग permissions दें.

Policy layer

एक simple policy file से शुरुआत करें.

{
  "allowCommands": [
    "npm run build",
    "npm run test",
    "node scripts/content-trend-report.mjs"
  ],
  "askCommands": [
    "git push",
    "wrangler pages deploy",
    "node scripts/outreach-send-mails.mjs --send"
  ],
  "denyCommands": [
    "rm -rf",
    "git reset --hard",
    "curl * | sh",
    "npm publish"
  ],
  "protectedPaths": [
    ".env",
    ".env.local",
    "claudecode-lab-sheets-f54fc47c68f0.json"
  ]
}

Claude Code project settings में भी ऐसी boundary बनाई जा सकती है.

{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "permissions": {
    "allow": [
      "Bash(npm run build)",
      "Bash(npm run test *)",
      "Bash(node scripts/content-trend-report.mjs *)"
    ],
    "ask": [
      "Bash(git push *)",
      "Bash(wrangler pages deploy *)"
    ],
    "deny": [
      "Bash(rm -rf *)",
      "Bash(git reset --hard *)",
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(./claudecode-lab-sheets-f54fc47c68f0.json)"
    ]
  }
}

“Secrets का ध्यान रखना” लिखना काफी नहीं है. Secret files और dangerous commands को concrete deny rules में डालें.

Verification layer

Success को command से prove करें.

const url = process.argv[2];
const response = await fetch(url, { redirect: "follow" });

if (!response.ok) {
  throw new Error(`Page returned ${response.status}: ${url}`);
}

const html = await response.text();
const checks = [
  ["title", /<title>.+<\/title>/i],
  ["description", /<meta name="description"/i],
  ["adsense", /ca-pub-2125588229998303/i],
  ["analytics", /G-3YR0LE68MJ/i]
];

for (const [name, pattern] of checks) {
  if (!pattern.test(html)) throw new Error(`Missing ${name}`);
}

Code-heavy article में Playwright से mobile width पर pre, code और table overflow भी check करें.

Recovery layer

हर run का log रखें, ताकि failure के बाद पता हो कि क्या बदला.

{
  "runId": "2026-05-19-article-001",
  "topic": "agent harness security",
  "changedFiles": [
    "site/src/content/blog/claude-code-codex-agent-harness-security.mdx"
  ],
  "commands": [
    "node scripts/content-trend-report.mjs --days 7",
    "npm run build"
  ],
  "status": "deployed"
}

Git में broad reset की जगह targeted recovery बेहतर है.

git status --short
git diff -- site/src/content/blog/target-article.mdx
git revert <bad-commit>

Summary

AI agent की quality सिर्फ prompt quality नहीं है. Real workflows में quality harness से आती है.

  • Policy: क्या allow, ask और deny होगा
  • Plan: execution से पहले steps clear करना
  • Verification: success को command से prove करना
  • Recovery: failure के बाद वापस आने का तरीका रखना

Claude Code और Codex अलग tools हैं, लेकिन दोनों को यही structure चाहिए: unlimited execution नहीं, बल्कि safe path for useful work.

#claude-code #codex #agent-harness #security #permissions #automation
मुफ़्त

मुफ़्त PDF: 5 मिनट में Claude Code चीटशीट

बस अपना ईमेल दर्ज करें और हम तुरंत A4 एक-पृष्ठ चीटशीट PDF भेज देंगे।

हम आपकी व्यक्तिगत जानकारी की सुरक्षा करते हैं और स्पैम नहीं भेजते।

Masa

लेखक के बारे में

Masa

Claude Code का गहराई से उपयोग करने वाले इंजीनियर। claudecode-lab.com चलाते हैं, जो 10 भाषाओं में 2,000 से अधिक पेजों वाला टेक मीडिया है।