Demo, all content is generated
Question

'Prompt is too long' but I only typed one sentence??

Solved · 4201 views · asked by nordic_nick · edited

Getting this now whenever I send anything:

Prompt is too long

My message is literally "now add a logout button". Before that Claude was reading log files and a big JSON export to debug an import. Do I have to start over and lose everything?

What I’ve tried

Tried a shorter message, same error. Restarted Claude Code and used --continue, same error.

Comment
Had this last week after it read a 3MB CSV. Same thing. dental_dave · edited

3 answers

Marked as helpful by the asker
sergio_ruiz · edited

"Prompt" here means the whole conversation, not your sentence. Every message sends everything so far, including those log files and the JSON export. You're over the model's context window.

  • /compact shrinks it into a summary. If even that fails because it's too big, go to 2.
  • /clear (or a fresh claude) and continue with a short summary: what the task was, what you found about the import, what's next. --continue resumes the same oversized conversation, so that won't help.

To avoid it: never let it read big files whole. "Show me the first 50 lines of the export" or "grep for the failing id in the logs". /context shows what's filling it up.

Comment
/compact failed, /clear with a summary worked. The logout button is there. Thanks! nordic_nick · edited
The --continue part is why I was stuck for an hour yesterday. Thanks. hugo_l · edited
Adding 'never read files over 500 lines whole, use head or grep' to my CLAUDE.md now. kimberly_j · edited
thandeka · edited

Also, for debugging data imports: have Claude write a small script that analyzes the file and prints a summary, instead of reading the file itself. The script output is 20 lines, the file is 3MB.

Comment
Didn't know it could write a script to analyze the file. Much better. nordic_nick · edited
leo_prompts · edited

Before /clear, ask it to write the summary into a file (NOTES.md) if it can still respond. Otherwise write 5 lines yourself. That's enough.

Comment