AI Coding

How to Code Faster With AI: 9 Habits That Actually Work

AI coding tools can write a function before you’ve finished your coffee. They can also send you down a forty-minute rabbit hole fixing code you didn’t ask for. The difference is rarely the model. It’s how you work with it.

So if you want to know how to code faster with AI, the useful answers are habits, not tools. The nine below come from the official best-practice pages for Claude Code, GitHub Copilot and OpenAI Codex. The three vendors agree on more than you’d expect.

One honest note first. We can’t give you a “40% faster” number. Speed gains depend on the codebase, the task and the developer, and we haven’t measured them. What we can say is where time usually gets lost, and how each habit stops that.

How to code faster with AI: the 9 habits

Core habits to code faster with AI assistants

1. Say what “done” looks like

Vague prompts cost you a round of corrections. Claude Code’s docs put it plainly: if you name the file, describe the symptom, and say what “fixed” looks like up front, “you usually save yourself a round of corrections later.” Codex’s guide suggests a four-part structure: goal, context, constraints, and “done when.”

Goal: users get logged out when the session times out. Fix it.
Context: token refresh lives in src/auth/refresh.ts
Constraints: no new libraries, keep the public API the same
Done when: a new test reproduces the bug, then passes, and the
existing auth tests still pass

That last line does most of the work. It turns “looks fixed” into something the agent can check.

2. Give the AI a check it can run

This is the habit we’d keep if we could only keep one. Claude Code’s docs point out that without something to run, the agent stops when the work “looks done,” and “in practice that makes you the test suite.” Every mistake waits until you happen to spot it. Give the agent a test file, a build command or a linter, and it can make a change, run the check, read the failure and fix it on its own. Codex’s guide says the same, asking it to “create tests when needed, run the relevant checks, confirm the result.”

Here’s a tiny example. A slug function an assistant might write, plus tests that pin down what it should do. We ran this on Python 3.12 and all three tests pass:

import re
import unittest


def slugify(title):
    slug = re.sub(r"[^a-z0-9]+", "-", title.lower())
    return slug.strip("-")


class SlugifyTests(unittest.TestCase):
    def test_basic(self):
        self.assertEqual(slugify("Hello World"), "hello-world")

    def test_punctuation(self):
        self.assertEqual(slugify("AI: What's New?"), "ai-what-s-new")

    def test_empty(self):
        self.assertEqual(slugify("!!!"), "")


if __name__ == "__main__":
    unittest.main()

Now add the case nobody mentioned. slugify("Café au lait") returns "caf-au-lait", because the regex throws away the accented letter. A test that expects "cafe-au-lait" fails, and that failure is exactly what you hand back to the AI. A fix using unicodedata.normalize("NFKD", ...) before the regex produced "cafe-au-lait" when we ran it, and the original three tests still passed.

Ask for evidence, too. Claude Code’s page says “All tests pass” on its own “tells you very little.” You want the command it ran and the output.

3. Plan first when the task is fuzzy

For anything bigger than a small fix, ask for a plan before code. Codex’s guide recommends planning when a task is “complex, ambiguous, or hard to describe well,” and its plan mode lets it gather context and ask questions first. Claude Code’s docs go further: ask Claude to interview you until it could write a spec, save it as SPEC.md, then start a fresh session to build from it.

Reading a ten-line plan takes a minute. Unpicking a wrong approach across six files takes much longer.

4. Keep a short instructions file

All three tools read a project file of standing instructions: CLAUDE.md for Claude Code, AGENTS.md for Codex, and .github/copilot-instructions.md for Copilot, per GitHub’s custom instructions docs. The advice from every vendor is to keep it short.

# Commands
- Test: npm test
- Lint: npm run lint

# Gotchas
- Integration tests need DATABASE_URL set to the test DB
- Never edit files in /generated; run npm run codegen instead

Claude Code’s docs suggest a simple filter: only write down what the AI couldn’t find by reading the code, or what it would waste time rediscovering each session. Codex’s guide adds a nice trick: when the agent makes the same mistake twice, ask it for a retrospective and update AGENTS.md.

5. Work in small, separate chunks

Copilot’s page says to “break down complex tasks.” Codex’s guide says to keep “one chat per coherent unit of work.” Claude Code recommends /clear between unrelated tasks, partly for cost: every request resends the whole conversation, so old tasks keep being re-read on the new one.

Small chunks also mean small diffs. You can review 40 changed lines properly. Nobody reviews 900 properly.

6. Use the right AI coding tool for the job

GitHub’s page separates inline suggestions, which complete code “as you write,” from Copilot Chat, which answers questions and takes on larger tasks. Agents like Claude Code and Codex sit further along: they read the repo, edit several files and run commands.

A rough rule: completions for code you already know how to write, chat for questions and explanations, agents for multi-file changes with a clear check. Using an agent to rename a variable is slow. Using autocomplete to build a feature is slower. We compared the three agents side by side in Claude Code vs Codex vs GitHub Copilot.

7. Hand over the real thing, not a description

Don’t describe the error. Paste it. Claude Code’s docs mention referencing files with @, pasting screenshots, and piping command output straight in:

cat error.log | claude -p "what's going on here"

In an editor, Copilot’s guidance is to open the relevant files and close the irrelevant ones, since that’s the context it works from. Its page also recommends giving examples of input data and expected output. One sample row often explains a data format better than a paragraph.

8. Review every diff like a colleague wrote it

GitHub’s page says to “understand suggested code before you implement it” and to check security, not only whether it works. Use linters and code scanning as a second net. Both agents also have review commands: Codex has /review, and Claude Code’s /code-review reviews the diff in a fresh subagent that never saw your conversation.

A small tip from Claude Code’s docs: when you ask for a review, add “skip style.” A reviewer asked to find problems will always find something, and fixing every nitpick adds layers you didn’t need.

9. Stop early, restart cleanly

Watch the first minute of an agent run. Claude Code’s docs say to press Esc the moment it drifts, and “after two failed corrections run /clear and write a better prompt instead of a third.” A third correction mostly adds to a conversation that already holds two failed attempts.

Commit before big changes, too. Claude Code’s checkpoints can roll back its own file edits, but its docs say they work alongside git rather than replacing it.

The part most productivity posts skip: a lot of the old “AI coding hacks” no longer apply. Claude Code’s best-practices page now has a table of advice you can stop following, including writing IMPORTANT in capitals, saying “think harder,” and telling the agent not to be lazy. It says current models follow plain instructions, and that emphasis tends to make the model over-apply a rule. So if your prompts are full of shouting, cut it. The habits that still matter are the boring ones: a clear goal, a check to run, a small diff and a real review.

Where AI coding still slows you down

These habits help. They don’t remove the limits.

  • Code you don’t understand. If you merge it, you own it. Debugging AI-written code you never read is usually slower than writing it yourself.
  • Missing context. Team decisions, deploy steps and unwritten rules aren’t in the repo. The AI can’t guess them.
  • Confident mistakes. Models still invent APIs and flags now and then. Tests catch some of that. Reading catches the rest.
  • Security. Never paste secrets into a prompt, and check generated code for injection, auth and permission problems.

When something does break, a structured approach beats re-prompting at random. Our guide on how to fix bugs with AI walks through one.

Verdict: which habits to start with

Start with habits 1 and 2 this week. Write “done when” into every prompt, and give the AI a test or build command to run. Those two change the most for the least effort. Add the short instructions file once you notice yourself repeating the same correction.

Skip the prompt tricks you saw on social media. The vendors’ own docs are clearer, and they’re updated as the models change. And don’t ignore the editor itself: the VS Code shortcuts worth learning save mouse trips around every AI edit you review.

Next: grab ready-made wording for explaining, refactoring and testing code from our AI prompts for coding list.

FAQ

Does AI really make you code faster?

It can for well-defined tasks with a clear check, like tests, boilerplate and small fixes. It can slow you down when the task is vague or you skip reviewing the output. We don’t have a reliable percentage to give you.

What’s the single most useful habit?

Giving the AI something it can run that returns pass or fail. Claude Code’s and Codex’s docs both stress it, because it lets the agent find and fix its own mistakes.

Should I use CLAUDE.md, AGENTS.md or copilot-instructions.md?

Whichever your tool reads. GitHub’s docs say Copilot can also use AGENTS.md files, and a single CLAUDE.md or GEMINI.md at the repo root. Keep any of them short.

Is it safe to let an AI agent run commands?

Only with limits. Use the tool’s permission settings, keep secrets out of the session, and commit your work first so you can roll back anything you don’t like.

Leave a Comment