Back to Coding

How Much Code Should You Paste?

How Much Code Should You Paste?
AI Tutorials Team 24 April 2026

Paste one line and the answer is about that line in general. Paste the whole project and the relevant part sits in the middle of an enormous input where attention is weakest. The right amount is specific and easy to determine.

What is the rule?

The function containing the error, everything it calls that you wrote, and the code that called it. That is usually two or three functions, and it covers where the bad value could have originated.

Why is more not better?

Because attention is finite and spread across the input. Material in the middle of a very long prompt is attended to least reliably, which is precisely where your relevant function ends up when you paste everything.

It also costs more and takes longer, on any metered arrangement.

What can be summarised instead?

  • What a called function returns. Rather than its implementation.
  • The shape of the data. Rather than the whole record.
  • What a library does. Rather than its source.
  • The general structure. Rather than every file.

Three sentences of accurate summary are worth more than three hundred lines of code that push the relevant part out of focus.

What should always be included?

The complete error, the actual values involved if you know them, and the versions. Those are short and they are the things people trim, which is the wrong way round.

What about a whole file?

Reasonable if it is a few hundred lines, and worth trimming beyond that. A file where the relevant function is at the bottom of a thousand lines is better sent as the function plus a summary of what else is in there.

What is the check before pasting?

Read the code you are about to send for credentials, keys, connection strings, personal data and internal addresses. This is the most common accidental exposure route in ordinary development.

It takes ten seconds and it is worth making automatic, since the natural thing to do when frustrated is to paste the whole file.

What if you do not know which part is relevant?

Ask. Describing the symptom and asking which parts of the code would be worth looking at produces a list, and sending those is faster than sending everything.

Does a tool with repository access change this?

It changes the mechanism and not the principle. Pointing a tool at three relevant files produces better results than granting access to everything, for exactly the same reason.

Does it help to say what the code should do?

More than including additional code. A sentence describing the intended behaviour gives the reader a standard to compare against, where code alone only supports questions about whether it is internally consistent.

This is what makes the difference between an answer about whether the code is reasonable and an answer about whether it does what you wanted. The two are entirely different and the second requires you to have stated the intention, which people leave implicit because it is obvious to them.

What is the summary?

Send what somebody would need to answer, and nothing else. If a colleague could diagnose it from what you pasted, it is enough; if they would have to ask what a function returns, that is the thing to add.