Prompt engineering: How to fix instructions that AI ignores

Prompt engineering: How to fix instructions that AI ignores

While running automation pipelines on my Mac mini, I hit a recurring wall: the AI simply wouldn't follow directions. Whether generating articles or summarizing text, I spent hours tweaking prompts to get the length, tone, and structure right. Through this trial and error, I realized that while AI is great at creation, it struggles with strict constraints.

Prompt engineering: How to fix instructions that AI ignores

At first, I tried simple requests like "Summarize this within 300 characters. Use a strong tone." The results were consistently over the limit, often hitting 400 or 600 characters. To fix this, I tried aggressive commands like "Strictly adhere to 300 characters!" or "Do not exceed the limit by even one character." It didn't help much. I learned that for an AI, numbers aren't precise constraints; they are just a general "vibe."

To solve this, I stopped trying to control length via the prompt and moved it to post-processing code. Regardless of the AI's output length, I simply trimmed it to the desired size using Python:

ai_output_text = "A very long sentence the model produced..."  # what the AI returned
max_length = 300  # the ceiling you actually want

if len(ai_output_text) > max_length:
    trimmed_text = ai_output_text[:max_length]
else:
    trimmed_text = ai_output_text

print(trimmed_text)

While this can occasionally cut a sentence in half, I refined the process to count by sentences and keep only the last complete one. Trimming the result directly is far more reliable than endlessly editing a prompt.

Next, I tackled the tone. Requesting a "strong tone" often resulted in text that sounded rude or aggressive, rather than confident and decisive. I tried descriptors like "persuasively" or "with conviction," but the AI still drifted across the entire spectrum of "strong." I discovered that positive instructions alone leave too much room for interpretation. By defining the boundaries—telling the AI what *not* to do—the results stabilized. Adding "Use a strong and persuasive tone, but absolutely avoid being rude or accusatory" finally gave me the professional yet firm voice I wanted.

Finally, I stopped increasing the volume of instructions and started defining the structure. Previously, I gave detailed sequential orders: "Put this in the first sentence, then that, and end with this." The AI would often mix these up or skip parts entirely to follow its own perceived "optimal flow." I realized the AI is much better at filling in blanks than following a list of demands.

I shifted my focus to structural templates, specifying exactly what the first sentence should be, how many points to include in the body, and how to close. For example:

"Write a blog post on the following topic. Follow this structure:

1. Intro: Start with a problem to build empathy and briefly introduce the topic. (Max 2 sentences)

2. Body 1: Explain the cause and background with one specific example. (Max 3 sentences)

3. Body 2: Provide a specific solution in steps. Each step must be one short sentence. (Max 4 steps)

  • Step 1: [Explanation]
  • Step 2: [Explanation]
  • Step 3: [Explanation]

4. Conclusion: Summarize key points and end with a lesson or call to action. (Max 2 sentences)"

By providing this framework, the AI filled the slots with surprising accuracy. Even if the internal phrasing varied slightly, the overall flow was exactly as intended. I applied this same logic to Shorts scripts by analyzing successful channels and mirroring their structures in my prompts (more on this in /19).

Now, when building a prompt, I assume the AI might ignore me. I handle hard constraints, like character counts, with code and narrow the tone by setting boundaries. Most importantly, I provide a structure for the AI to fill rather than a list of contents to include.

Define the structure and handle the constraints with code.

Related posts

This post is the English edition of a Korean write-up: 원문 보기

Comments

Popular posts from this blog

npm command not found on Windows: fix the PATH

Claude CLI 401 Unauthorized Refresh Token Issue

Tailscale without sudo: what userspace mode actually costs you