DEV Community

Tosh
Tosh

Posted on

How I Use ChatGPT to Write Better Code Faster (Real Prompts, Real Results)

How I Use ChatGPT to Write Better Code Faster (Real Prompts, Real Results)

I've been writing code for a decade. ChatGPT has changed the way I work — not by writing code for me, but by compressing the time between "idea" and "working implementation."

Here's what that actually looks like day-to-day, with the exact prompts I use.


The problem with how most devs use AI

Most developers I talk to treat ChatGPT like a smarter Google. They paste an error message, get an answer, move on. That works, but it's leaving a lot on the table.

The real leverage comes from using it as a thinking partner and a force multiplier on the boring-but-important parts of development: code review, documentation, debugging hunches, explaining unfamiliar APIs.


5 prompts I actually use

1. Code review before PR

Before I open a pull request, I paste in my diff and ask:

You are a senior engineer doing a code review. Here's a diff:

[paste diff]

Flag:
- Logic bugs or edge cases I might have missed
- Security issues (injection, auth, input validation)
- Performance problems
- Things that will confuse the next engineer

Be specific. No generic advice.
Enter fullscreen mode Exit fullscreen mode

This catches things I'm blind to after staring at the code for 3 hours. Last week it found an off-by-one error in a pagination function that my tests didn't cover.


2. Debugging with context

When I'm stuck on a bug, I give it full context:

I'm debugging a Node.js app. Here's what I know:

- The function is: [paste function]
- Input: [paste sample input]
- Expected output: [describe expected]
- Actual output: [paste actual output or error]
- What I've already tried: [list what you tried]

What are the most likely causes? Walk through each one.
Enter fullscreen mode Exit fullscreen mode

The key is "what I've already tried." Without that, it suggests the things you already ruled out.


3. Explaining an unfamiliar API

When I'm integrating a new SDK or API I haven't used before:

Explain the [Stripe Webhooks / AWS SDK / whatever] API to me like I'm a backend developer who knows HTTP but has never used this specific service.

Focus on:
- The mental model I need
- The 3 most common mistakes
- A minimal working example in [language]

Skip the marketing copy from the docs.
Enter fullscreen mode Exit fullscreen mode

This is faster than reading the docs cold. I use this probably 3x a week.


4. Writing technical documentation

Documentation is where I used to lose hours. Now:

Write technical documentation for this function:

[paste function]

Audience: developers joining this project who know [language] but don't know this codebase.

Include:
- What it does (one sentence)
- Parameters (name, type, what they control)
- Return value
- Edge cases and gotchas
- Example usage

Format it as a JSDoc/docstring comment.
Enter fullscreen mode Exit fullscreen mode

Takes 30 seconds instead of 20 minutes.


5. Before/after refactor review

When I think something could be cleaner but I'm not sure how:

Here's a function I wrote:

[paste function]

Suggest a refactor that makes it:
- Easier to test
- Easier to read
- Less likely to break when requirements change

Show me the refactored version and explain what changed and why.
Enter fullscreen mode Exit fullscreen mode

I don't always use the suggestion, but it almost always gives me a direction I hadn't considered.


What makes a prompt work

Three things:

1. Role context. "You are a senior engineer" or "you are a technical writer" changes the register of the response. It sounds dumb but it works.

2. Negative constraints. "No generic advice," "skip the marketing copy," "don't suggest things I already tried." Without these, you get hedge-everything responses.

3. Structured output. If you want bullet points, ask for bullet points. If you want code, ask for code. The model will match your format.


The time math

Before: code review took me 45-60 minutes per PR (my own and others').
Now: 15-20 minutes. The first pass is AI, the second pass is me confirming.

Before: writing docs for a module took 1-2 hours.
Now: 20 minutes, with better coverage than I'd have done manually.

Across a 40-hour week, this is probably 8-10 hours recovered. That's a real number.


Where to go from here

These 5 prompts are the ones I use most. I have about 500 more organized by use case — debugging, architecture decisions, testing, client communication, scope estimation, code explanation.

I put them all in a structured library because copy-pasting from Notes was annoying. It's $27 and you get instant access.

If you're a developer who wants to move faster without sacrificing quality, that's the shortcut I wish I'd had two years ago.

Get the prompt library ($27 instant download)

Top comments (0)