Agent SDK se Claude Code ko chalana
Ab mazedaar hissa — related tools ka chhota tour jinhein yaad karne ki zaroorat nahi. Pehla hai Claude Agent SDK. Naam ke bawajood yeh agent framework nahi. Yeh code se Claude Code chalane ka tareeqa hai — agent ki poori power, programmatically control mein.
Is par notes banane ki zaroorat nahi — yeh sirf tour hai taake aap ko is ka pata ho. Lekin common confusion door karta hai, is liye samajhna faidemand hai.
01Agent SDK asal mein kya hai
“Claude Agent SDK” naam se agent framework ka guman hota hai. Yeh nahi hai. Yeh Claude Code ko programmatically chalane ka tareeqa hai — aap code likhte hain jo Claude ko prompt aur tools ka set deta hai, aur Claude agentic kaam karta hai. (Pehle isay Claude Code SDK kehte the; naam mein agent singular hai.)
02Chhota uv project set up karein
Hum uv (tez Python tooling) use karenge. Khaali folder se:
uv init --bare # a clean, empty project uv python pin 3.13 uv add python-dotenv requests claude-agent-sdk # like pip install # drop in a .env with your ANTHROPIC_API_KEY, and a .gitignore
03Poora program
Bas itna hi poora program hai. Upar se neeche parhein — aap ki umeed se chhota hai:
import asyncio from dotenv import load_dotenv from claude_agent_sdk import query, ClaudeAgentOptions load_dotenv(override=True) # .env wins over system env vars prompt = "Make a vanilla HTML + JS + CSS game of Space Invaders. " \ "Write the code to files in the current directory, including index.html." tools = ["Read", "Write", "Edit", "Bash"] # the tools we allow Claude to use async def main(): options = ClaudeAgentOptions( allowed_tools=tools, model="claude-opus-4-6", # splashing out for the demo — see the warning! ) async for message in query(prompt=prompt, options=options): print(message) asyncio.run(main())
Demo mein claude-opus-4-6 sirf entertainment ke liye hai. Asal programmatic use ke liye — khaas taur par loops mein — sasta, tez model chunein. Loop mein sab se mehnga model chalane se bill kharab ho jata hai.
04Chalayein: game saamne aa jati hai
uv run main.py # messages stream back — a file appears — it’s working… # done. index.html created.
index.html kholein aur game saamne hai: playable Space Invaders — start screen, arrow-key controls (prompt mein iska zikr bhi nahi tha), sound, score aur upar march karta alien. Vanilla HTML/JS/CSS mein Claude Code ka banaya mukammal working game — sab us chhoti script se driven.
Week one mein sirf ek frivolous build ka wada tha. Isay point samjhane wali exception samjhein: SDK prompt jo kahe woh banayega — commercial ho ya fun — kyun ke neeche wohi Claude Code engine hai.
05Isay kab use karein
Aap SDK rozana use nahi karenge. Lekin agar poore Claude Code ecosystem ke upar application banana ho — apne program ke andar us ki skills, plugins aur tools use karne hon — to Agent SDK tareeqa hai. Isay “terminal mein chat karne” se “apne ship kiye software mein agent embed karne” ka darwaza samjhein.
✓ Ahm baatein
- Claude Agent SDK code se Claude Code chalata hai — yeh agent framework nahi.
- Aap isay prompt aur allowed tools ki list dete hain;
query()messages stream karta hai. - Taqreeban 20-line script ne zero-shot mukammal playable Space Invaders game bana di.
- Asal / looping kaam ke liye sasta model use karein — loop mein Opus mehnga hai.
- Jab Claude Code ecosystem ko apni app ke andar embed karna ho tab use karein.