Working with AI Coding Agents
AI coding agents best practices, ek instructions file, branch par kaam, push aur migration se pehle ijazat, sirf assigned task, aur har claim ki verification.
On this page
1. Yeh practice kya hai?
Coding agents files edit kar sakte hain, commands chala sakte hain, git use kar sakte hain. Yeh taaqat hi khatra hai: ek ghalat command seconds mein woh nuksan karti hai jo insaan haath se karne mein hichkichata.
2. Kyun zaroori hai?
Yeh rules theory se nahi, asli waqiat se bane hain:
| Agent bina rules ke | Agent rules ke saath |
|---|---|
| main par seedha commit | Apni branch ya worktree par |
| Purani baat ko push ki ijazat samjha | Har push ke liye us waqt ki saaf ijazat |
| Live database par migration | Migration file banti hai, chalata insaan hai |
| Backup bana diya, bina check | Sirf woh safety net batao jo verify hua |
| Task ke saath teen aur cheezein theek kar din | Sirf assigned task, baqi report |
| Code likh kar done | Typecheck, lint, tests ke baad done |
| Description suni aur bana diya | Pehle plan, ijazat ke baad build |
3. Kab follow karein?
| Level | Kitna zaroori | Kyun |
|---|---|---|
| Learning project | Branch, verification aur khud code samajhna | Agent ka code samjhe bagair seekhna nahi hota |
| Production code | Poora rule, sab se zyada push aur live data par | Ek ghalat command production data mita sakti hai |
| Senior level | Instructions file, permissions aur team workflow banana | Har developer ka agent ek hi rules par chale |
4. Bura vs acha code
Bura: prompt aur nateeja
make the dashboard faster and push it when doneAgent ne dashboard ke saath auth middleware "saaf" kar diya, migration live database par chala di, aur main par push kar diya. Report: "Done, all good, backup taken."
Acha: prompt
task: the orders page takes 4s. find the cause and propose a fix.
scope: src/orders only. do not touch auth or migrations.
first: reply with a short plan, do not edit yet.
done when: typecheck, lint and tests pass, and you report the before and after timing.
do not push.Acha: agent ki report
cause: n+1 query, 51 queries per page load
fix: one query with include in src/orders/service.ts
verified: tsc --noEmit ok, eslint ok, 14 tests pass
timing: 4.1s to 0.4s on the seeded data
committed locally on fix/orders-n-plus-one, not pushed
not done: the export button has the same pattern, left for a separate taskFarq kya hai?
| Cheez | Bura | Acha |
|---|---|---|
| Scope | Khula | Folder aur mana cheezein saaf |
| Plan | Seedha build | Pehle plan, phir go |
| Verification | "All good" | Commands aur nateeje |
| Push | Prompt mein pehle se | Alag, us waqt ki ijazat |
| Extra kaam | Khud kar diya | Report kiya, shuru nahi kiya |
5. Kaise apply karein?
Ek instructions file per repo
Repo root par ek file (aam convention AGENTS.md hai) jis mein project ke rules, commands aur docs ke pointers hon. Har tool isi ko parhe. Agar koi tool apni alag file maangta hai to woh sirf is file ko import kare, rules dobara na likhe. File chhoti rakhein (taqreeban 150 lines se kam) aur detail docs mein.
# AGENTS.md (misaal ka hissa)
read docs/knowledge/README.md first.
work on a branch named type/kebab-summary. never commit to main.
verify with: npx tsc --noEmit, npm run lint, npm test.
never push, merge, deploy or run migrations on a live database unless asked for that action now.
do only the assigned task. report anything else you notice.Hard rules
| Rule | Kyun |
|---|---|
| Push, merge, rebase, PR sirf us waqt ki saaf ijazat se | Purani ya general baat standing permission nahi |
| Live system par read-only hi ceiling | Migration, insert, update, delete insaan karta hai |
| Sirf assigned task | Write access wale agent ka scope creep live systems torta hai |
| Jo safety net batayein woh maujood aur verified ho | Jhoota backup koi backup na hone se bura |
Shared tree par stash, reset, clean, checkout <path> nahi | Doosre ka kaam ud jata hai |
Apne paths explicitly stage karein, git add -A nahi | Doosre ki files commit na hon |
| Secrets kabhi output, log ya chat mein print nahi | Transcript bhi stored data hai |
| Plan pehle, build ijazat ke baad | Ghalat masla hal karne ka kaam zaya hota hai |
6. Exceptions aur common mistakes
Kab rule nahi lagta: ek chhoti migration jo existing data ko na chhooye, idempotent ho aur jis ka down path ho, kuch teams agent ko local ya dev database par chalane deti hain. Destructive DDL, backfill, drop, rename aur type change hamesha insaan ke saamne aate hain. Akelay ke throwaway repo mein push ki ijazat ek dafa de dena bhi chal jata hai, lekin team repo mein nahi.
Galati: Agent ki report ko bina check maan lena
Why? Agent confident lehje mein woh bhi likh sakta hai jo hua hi nahi, jaise tests pass ya backup bana.
Behtar: Report mein commands aur nateeje maangein, aur zaroori claims khud verify karein.
Galati: Generated route handlers ko bina auth review merge karna
Why? AI code aksar authentication middleware ya ownership check bhool jata hai.
Behtar: Har naye route par auth aur authorization line khud dhoondhein aur failure tests maangein.
Galati: Ek hi tree par kai agents
Why? Ek ka stash, reset ya amend doosre ka kaam le ya bigaar deta hai.
Behtar: Har agent ko alag branch aur alag worktree dein.
Galati: Agent ko visual check ke liye browser aur credentials dena
Why? Shared browser aur accounts mein ghalat action ka khatra, aur credentials leak.
Behtar: Agent code level par verify kare aur aap ko batayein kya dekhna hai, visual check aap karein.
7. Pehle aur baad mein kya seekhein?
| Stage | Topics |
|---|---|
| Pehle | Git Branches & Commits, Definition of Done |
| Saath mein | Documentation & Decision Records, Safe Migrations |
| Baad mein | Pull Requests & Code Review, Production Readiness Checklist |
Final quick revision
| Check | Haan? |
|---|---|
| Ek instructions file, chhoti | |
| Agent branch ya worktree par | |
| Push, merge, migration sirf saaf ijazat se | |
| Sirf assigned task | |
| Typecheck, lint, tests se verify | |
| Har safety net verified | |
| Pehle plan, phir build |