Advanced (अपडेट: 3/6/2026)

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

Claude Code और Codex agents के लिए सुरक्षित harness: permissions, plan, verification और rollback.

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>

Team checklist: exit point से design करें

सबसे common mistake prompt खराब लिखना नहीं है. असली problem तब आती है जब agent पहले सिर्फ पढ़ता है, फिर बिना clear boundary के external action भी कर देता है. इसलिए हर workflow का exit point पहले define करें.

Content workflow में exit point “article लिखा गया” नहीं है. सही exit point है: public URL 200 दे, Analytics और AdSense tags मौजूद हों, और mobile पर code blocks overflow न करें. Sales workflow में exit point “email भेज दिया” नहीं है. सही exit point है: company list, sample page और email draft review के लिए तैयार हों. Security fix में exit point “code बदल गया” नहीं है. सही exit point है: diff, tests और rollback plan साफ हों.

use caseपहले automate करेंapproval बचाकर रखें
Contenttopic, draft, translation, internal links, builddeploy, git push, ad tag change
SaaS integrationread-only lookup, CSV, summary, draftsend, delete, billing change
Security fixpatch proposal, tests, impact notesecrets, production, wider permissions

मुख्य pitfall है reading और execution को mix करना. Agent logs, issues और web pages पढ़े, यह useful है. लेकिन उसी agent को email send, database delete या production deploy का अधिकार भी है, तो external document में छिपा malicious instruction real action बन सकता है. OWASP का Top 10 for LLM Applications Prompt Injection और Excessive Agency जैसे risk समझने के लिए अच्छा reference है.

Claude Code के लिए official security guide और permissions guide पहले पढ़ें. Codex के लिए OpenAI का code generation guide useful है. ClaudeCodeLab में आगे पढ़ने के लिए security failure cases और dangerous prompts देखें.

Ready templates और checklists /products/ में हैं. अगर team permissions, CI, review और deployment flow साथ में design करना है, तो /training/ से consultation लेना बेहतर है.

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: Claude Code cheatsheet

Email डालें और commands, review habits तथा safe workflow वाली एक-page PDF पाएँ.

हम आपका data सुरक्षित रखते हैं और spam नहीं भेजते.

Masa

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

Masa

Claude Code workflow और team adoption पर काम करने वाला engineer.