AI completion is making me faster and more confused at the same time

I have been using code completion more on small scripts and it is definitely useful for repetitive parts. The problem is that I sometimes accept a 10-line block because it looks reasonable, then five minutes later I cannot explain why one condition is there.

A recent example was a file-processing script. The completion added an exception branch and a fallback value. Both looked sensible, so I kept them. Later I changed another part of the script and realized I had no idea which errors the branch was supposed to catch. Nothing was technically “wrong”; I had just skipped the thinking step.

I am not trying to avoid the tool. I want a way to use it without slowly turning my own code into something I only recognize visually.

One thing I have started doing is accepting smaller chunks and rewriting any block I cannot explain in plain language. I also try to run the code after each meaningful change instead of accepting three suggestions in a row.

That is slower, but maybe that is the point while I am still learning. What habits have actually helped people keep track of generated code rather than just supervise it?

  • ai-coding
  • learning
  • code-completion
23

7 replies · Sort: Best

Best
  1. BC
    benjamin.clark
    6 points

    1 reply

    Running after each meaningful change is the habit I trust most. It breaks the spell a bit, which is useful when you’re tempted to accept thr...

    61 reply

    Running after each meaningful change is the habit I trust most. It breaks the spell a bit, which is useful when you’re tempted to accept three neat-looking things in a row.

    6
    1. ED
      dora-e
      0 points

      I like the “spell” wording. That’s exactly what it feels like when the code looks fine but my brain has checked out.

      0
  2. IT
    tagliafierro-i
    6 points

    2 replies

    I’ve started deleting more of the suggestion than I keep. The tool is good at filling in obvious stuff, but I don’t want it deciding structu...

    62 replies

    I’ve started deleting more of the suggestion than I keep. The tool is good at filling in obvious stuff, but I don’t want it deciding structure for me unless I already know the shape.

    6
    1. xiao.si
      2 points

      This. I only accept generated code if I can predict the next line before I read it. If I can’t, I slow down and write it myself.

      2

        That’s a good test. Predicting the next line feels like a decent line between “helpful” and “I’m just nodding at the screen.”

    2. EG
      eva_georg
      4 points

      1 reply

      Smaller chunks is the big one for me too. If I can’t restate the block in one sentence, I don’t let it stay as-is for long.

      41 reply

      Smaller chunks is the big one for me too. If I can’t restate the block in one sentence, I don’t let it stay as-is for long.

      4
      1. CS
        charles_5
        3 points

        I also name the branch in a comment when it matters. Not fancy documentation, just enough to remind me why that thing exists when I come back later.

        3