How can I prevent Claude from writing unsolicited code?

0
15
Asked By CuriousCat94 On

I'm currently learning a new tech stack and using Claude for assistance. However, I'm having issues with it automatically writing code when I don't want it to. I've provided clear instructions in my project stating that Claude should only write code when it's explicitly requested—like when I say 'write code for...' or 'show me the implementation of...'. Unfortunately, even after sharing some code and asking for help to write unit tests, Claude jumped in and created around 100 lines of code without me asking. Does anyone have suggestions on how to ensure that Claude sticks to these instructions and refrains from coding until I specifically request it?

5 Answers

Answered By TaskMaster42 On

Try creating a to-do list for Claude! Instead of telling it what not to do, focus on positive instructions. Just outline what it should focus on and execute only those items on the list—I've found this approach yields better results.

Answered By ClineFan77 On

Honestly, I've switched to using Cline, a VS Code extension, which has a 'Plan/Act' mode. In 'Plan' mode, it can't write or edit files, which helps maintain focus. I used to face the same issues with Claude, but just having that restriction makes a huge difference. It's baffling that such a basic feature isn't available in other tools yet.

Answered By DebuggingDynamo On

I feel your frustration! What’s worked for me is starting every prompt with "Do not write code." It’s a hassle to repeat it, but it does help get the outcome you want. I even use Autohotkey to set up 'pre-prompts' for convenience.

Answered By CodeSlinger22 On

I've had a similar experience, but I found a way to get Claude to listen. I started with a directive like, "You are not allowed to write code until we discuss it first." This has worked pretty well for me. Just make sure to set clear conditions from the get-go. It seems like tying the instruction to a condition helps regulate its responses.

Answered By DesignatedDecider On

One thing I do is insist on getting agreement before Claude writes code. I’ll clarify our plan first, then give it the green light to proceed. It’s about setting the right communication flow.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.