Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 4 min read

How to Use AI to Improve Your Development Workflow

Most advice about "AI for developers" optimises the wrong step. Typing code was never the slow part. The slow parts are reading code you did not write, remembering how a module behaves under a weird input, and writing th

How to Use AI to Improve Your Development Workflow

Most advice about "AI for developers" optimises the wrong step. Typing code was never the slow part. The slow parts are reading code you did not write, remembering how a module behaves under a weird input, and writing the test that proves a fix actually works.

An assistant is useful when it is pointed at one of those slow parts with tight context and an output you can check. It is noise when it is pointed at "make this better". Below are four concrete places where it earns its place in a normal working day, a few places where the trade is bad, and the guardrails that keep the diff reviewable.

Here is the loop that keeps it useful:

A practical AI-assisted loop: gather context, write the prompt, read the draft, prove it, and review before committing

1. Reading code you did not write

Before asking a model anything, spend thirty seconds finding the real entry point yourself with ripgrep:

rg -n "def parse|class Parser" src/
rg -n "parse\(" src/ --type py

Then paste only the two or three files that matter. Pasting a whole repository makes it easier for the model to grab the wrong symbol, and it also leaks whatever else happened to live in those files.

A prompt that works for this task names all four slots explicitly:

Files: src/parser.py, tests/test_parser.py
Goal: parse_records() returns [] for malformed JSON instead of raising.
Constraint: keep the public signature; do not change what I/O errors raise.
Output: quote the exact lines you changed, then explain why.

The "quote the exact lines" instruction is doing real work. It makes a hallucinated edit visible immediately, because every line it claims to have changed can be looked up in the file you pasted.

2. Turning a vague bug report into a failing test

The reliable order is test first, written by a human and reviewed before any implementation exists:

import pytest

from app.parser import parse_records

@pytest.mark.parametrize("payload", ["", "{", '{"rows": "not-a-list"}'])
def test_malformed_payload_returns_empty(payload: str) -> None:
    assert parse_records(payload) == []

Now the prompt has a target that can be checked mechanically. The pattern above comes straight from the pytest parametrize documentation.

tests/test_parser.py::test_malformed_payload_returns_empty fails with json.JSONDecodeError.
Change app/parser.py only. Do not edit the test. Do not add dependencies.
If the test looks wrong, stop and say so instead of rewriting it.

That last line matters. Faced with a contradiction, a model will often rewrite the assertion, and you end up with a green suite that proves nothing.

3. Reviewing your own diff before a human sees it

This is the cheapest win and the most skipped step. Before opening a pull request:

git diff --staged
Here is a staged diff. Review it like a reviewer from another team.
Report only: (1) bugs, (2) missing tests, (3) names that will confuse the next reader.
Skip style preferences. If a category is empty, write "none: <category>".

Two details make the output usable:

  • a fixed, small set of categories instead of an open-ended "review this";
  • an explicit instruction to write "none", which stops the model from padding an answer on a diff that is genuinely fine.

Treat the result as a checklist, not a verdict. Everything it flags still gets checked, and everything it approves still gets read.

4. Explaining an intermittent failure

For flaky failures the useful question is not "what is the bug" but "which state could produce this log". Give the model the log, the function, and a sample input:

Traceback (most recent call last):
  File "app/sync.py", line 88, in sync_batch
    record_id = payload["id"]
KeyError: 'id'

Payload sample: {"ID": "abc123", "title": "..."}

Which upstream change would produce this? List the three most likely causes,
and give one log line that would distinguish each of them.

Asking for discriminating log lines turns a plausible story into a testable hypothesis. That is the difference between a suggestion and a diagnosis.

Where an assistant is a bad trade

  • Production data migrations. The failure mode is silent and expensive; write those by hand and review them twice.
  • Anything with secrets or customer data. A context window is not a safe place for credentials or personal records.
  • Learning an area from scratch. Reading the documentation once is more reliable than auditing three confident, subtly wrong answers.
  • A rename across a large codebase. Use the compiler and the type checker; they do not hallucinate.

A short checklist before you accept a change

  1. Can I point at the changed line and say why it is there?
  2. Is there a test that fails without this change?
  3. Does the code call an API that actually exists? Run it instead of skimming it.
  4. Does the commit message explain intent, not just mechanics?
pytest -q && git add -A && git commit -m "return [] on malformed payload"

Closing

The tool shortens the mechanical parts; the judgement about what ships stays with you. A suggestion that cannot be justified in one sentence to a colleague is not ready to merge, however green the suite looks.

If you only try one thing from this post, make it step 3. Reviewing your own diff is the highest ratio of value to effort on this list.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.