Contents

Rather than giving Claude Code detailed steps, clearly state what it must not do and how to verify its work. Including the reasons for restrictions and the scope of the task helps reduce unnecessary changes and unverified claims.

Key Points#

  • Use NEVER and DO NOT to explicitly prohibit unwanted behavior.
  • Have it report what it actually verified after the task, rather than saying “looks fine.”
  • Define the scope to prevent it from adding features or complex mechanisms you did not request.
  • Separate rules by role and situation, and combine only those you need.

Define Restrictions First#

Broad instructions like “write good code” do little to convey what to avoid. Turn common failures into specific restrictions and provide them at the start of the task. Strong wording alone does not guarantee accuracy, but it sets clearer boundaries than vague requests.

For example, when requesting code changes, you could write:

  • NEVER add features that were not requested. They expand the scope of changes.
  • DO NOT report that tests passed without running them. Keep actual results separate from assumptions.
  • CRITICAL explain why before changing files other than those specified. This prevents unintended changes.

Include reasons for restrictions. Reasons make it easier to understand a rule’s intent even in situations it does not explicitly cover. There is no need to add defensive code for extreme edge cases or abstractions you did not request. Prioritize small changes that directly serve the goal.

Make Verification Part of the Task#

Do not stop at “check it”; specify what to check and how. Have it report the commands it ran and the results it observed after the task. If it cannot verify something, have it state why and list the checks it did not perform.

Ask reviewers to look for problems rather than offer reassurance. Ask again: “What evidence shows that this change works?” “Have any conditions been overlooked?” “What did the test results confirm?” Do not treat another AI’s opinion as automatically correct; assess it against the original changes and results.

This verification does not justify exceeding the scope defined earlier. Treat it as a procedure for checking the requested work.

Separate Reporting and Permissions#

In completion reports, distinguish what was done, what was verified, and what could not be done. If tests were not run, have it write “not run” rather than fill the gap with wording that implies success. Conversely, once the necessary checks are complete, there is no need to demand unsupported caveats such as “there may still be problems.”

Define permissions for each task as well. Asking it to edit a file does not also authorize deleting related files or sending anything externally. State how far changes may go and what to do if additional operations are needed. For example: “Edit the specified file, and explain why first if related files also need changes.”

Combine Small Sets of Rules#

Rather than rewriting a long prompt every time, separate common rules from rules for specific situations. Managing roles, scope, restrictions, verification methods, and report formats separately lets you select only what you need.

Start with these four:

  • Common rules: Do not report unverified information as fact.
  • Code changes: Explain the reason for changes beyond the specified scope.
  • Reviews: Identify problems and supporting evidence.
  • Reports: Separate changes, verification results, and work not performed.

Too many rules can bury the instructions relevant to the current task. Record failures that actually occur, and add only rules that prevent them from recurring. When using tools, specify dedicated tools suited to the task and how to use them, so the results can be traced.

Next Step#

Choose one task to ask Claude Code to do next, add one item each for “restrictions,” “verification method,” and “report format,” and adjust the rules based on the results.

Source: https://www.bingjie.vip/index.php/archives/220/

Contents