Your AI coding tool is underperforming because you haven’t configured it. Here’s the four-step setup that Anthropic engineers use internally — adapted for any tool.


1. Give Your AI a Project Constitution

AI coding assistants start every session knowing nothing about your project. No conventions, no stack preferences, no patterns to avoid. So they guess — generically.

The fix: a persistent context file that loads at the start of every session.

  • Claude CodeCLAUDE.md in your repo root
  • Cursor.cursorrules
  • GitHub Copilot — repository-level instruction files
  • ChatGPT / Gemini — custom instructions or a system prompt you paste at session start

What to put in it:

  • Stack and versions — “Next.js 14, TypeScript, Tailwind, Supabase. No class components.”
  • Folder structure — where pages, components, utilities, and types live
  • Conventions — naming patterns, file organization, comment style
  • Hard avoids — deprecated libraries, known bad patterns, decisions already made by the team
  • How to run and test — so it can verify its own output without asking you

This is onboarding documentation written for your AI. Without it, every session starts from zero. With it, your AI operates inside your actual constraints from the first message.


2. Encode Repeatable Tasks as Custom Commands

If you’re re-typing the same prompt instructions across sessions — how to write tests, how to structure a new API route, what boilerplate a component needs — you’re wasting time and getting inconsistent results.

Custom commands (slash commands, prompt templates, or saved instructions depending on your tool) turn repeatable tasks into one-line triggers:

  • /test → use Vitest, mock external calls, write a describe block with edge cases, match existing naming conventions
  • /component → scaffold with the team’s boilerplate, TypeScript props interface, no inline styles
  • /pr-review → check for missing error handling, console logs left in, type assertions that bypass safety

How to do it per tool:

  • Claude Code / Cursor — define slash commands in your project config
  • ChatGPT — use custom instructions or create a saved prompt library in a note you paste from
  • Gemini / Copilot — use workspace prompt files or snippet libraries

Identify your three most repeated prompts. Write out what a perfect result looks like. Save it. You’ll never re-explain your standards for those tasks again.


3. Close Feedback Loops with Hooks

Hooks are event-driven automations that fire when something happens — no prompting required. They’re what separates an AI you babysit from one that self-corrects.

What hooks can do:

  • Run your linter after every file edit and feed errors back automatically
  • Execute the test suite after any change and surface failures immediately
  • Auto-format with Prettier before saving
  • Log every change the AI makes for a clean audit trail
  • Push a desktop or Slack notification when a long task completes

If your tool doesn’t support hooks natively, approximate them:

  • Git pre-commit hooks to run checks before anything lands
  • IDE watch tasks that trigger on file save
  • A simple shell script that runs your AI output through validation before you review it

The goal: when your AI writes code that breaks a test, it knows immediately and fixes it before handing anything to you. You review passing code, not broken drafts.


4. Isolate Complex Tasks with Dedicated Contexts

The most common reason AI output degrades on large tasks: context pollution. You ask it to refactor a module. It explores the codebase, accumulates 40 messages of working context, and by the time it implements the change, it’s drifting from the constraints you set at the start.

The solution is deliberate context isolation — each stage of a complex task gets its own clean session:

  • Session 1 — Explore: “Read the codebase and tell me what exists. Don’t change anything.” Output: a summary you save.
  • Session 2 — Plan: Paste the summary. “Given this, here’s what I want to change. How should we approach it?” Output: a plan you save.
  • Session 3 — Implement: Paste the plan. “Execute this.” Clean context, focused task.

In Claude Code and similar tools, this is formalized as subagents — specialized instances with their own context windows, each handling one part of the work. With ChatGPT or Gemini, you replicate it manually by starting new conversations deliberately rather than letting one chat sprawl across five different problems.

Rule of thumb: if your chat is longer than 20 messages on a complex task, start a fresh one with a tight summary of what’s been decided. Context length is not free — it costs coherence.


Quick-Start Checklist

  • ☐ Create a context file in your repo (CLAUDE.md, .cursorrules, or equivalent)
  • ☐ Add stack, conventions, folder structure, and hard avoids
  • ☐ Identify your 3 most repeated prompts and save them as templates
  • ☐ Set up at least one automated feedback loop (linter, test runner, or formatter)
  • ☐ For your next large task, break it into Explore → Plan → Implement sessions

Want to compare AI coding tools side by side? See our full reviews of ChatGPT, Gemini, Cursor, GitHub Copilot, and more at aineedthat.com.