<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: bhutano</title>
    <description>The latest articles on DEV Community by bhutano (@bhutano).</description>
    <link>https://dev.to/bhutano</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3982593%2F8c93cc36-2d1d-4737-a2b3-bc00b861e7b0.png</url>
      <title>DEV Community: bhutano</title>
      <link>https://dev.to/bhutano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bhutano"/>
    <language>en</language>
    <item>
      <title>Claude Code Hook That Engineers Every Prompt for You — Automatically</title>
      <dc:creator>bhutano</dc:creator>
      <pubDate>Sat, 13 Jun 2026 11:34:13 +0000</pubDate>
      <link>https://dev.to/bhutano/claude-code-hook-that-engineers-every-prompt-for-you-automatically-o7</link>
      <guid>https://dev.to/bhutano/claude-code-hook-that-engineers-every-prompt-for-you-automatically-o7</guid>
      <description>&lt;h1&gt;
  
  
  I Built a Claude Code Hook That Engineers Every Prompt for You — Automatically
&lt;/h1&gt;

&lt;p&gt;Most developers using Claude Code write prompts like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add rate limiting to the auth endpoints
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That works. But it's leaving a lot on the table.&lt;/p&gt;

&lt;p&gt;Anthropic's own prompt engineering documentation says that a well-structured prompt — with role assignment, explicit context, constraints, output format, and examples — dramatically improves response quality. The problem? Writing prompts that way every time takes 5–10 minutes. Nobody does it.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;steelprompt&lt;/strong&gt;: a Claude Code hook that silently restructures every prompt using Anthropic's 7 official principles, before Claude even sees it.&lt;/p&gt;




&lt;h2&gt;
  
  
  What it actually does
&lt;/h2&gt;

&lt;p&gt;steelprompt intercepts every prompt via a &lt;code&gt;UserPromptSubmit&lt;/code&gt; hook and runs a 3-tier decision protocol:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 1 — Bypass&lt;/strong&gt;: slash commands, prompts under 5 words, and atomic tasks pass through unchanged. No overhead on simple stuff.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 2 — Ask&lt;/strong&gt;: if critical information is missing, steelprompt asks 1–2 targeted questions before guessing. No more "which file?" moments after Claude produces the wrong output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 3 — Apply&lt;/strong&gt;: for every clear, non-trivial prompt, steelprompt restructures it inline using the full framework — zero added latency, zero extra tokens billed, because Claude does the restructuring during its own inference.&lt;/p&gt;




&lt;h2&gt;
  
  
  The before/after
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;You type:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add rate limiting to the auth endpoints
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What steelprompt injects internally:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You are a senior backend security engineer.

&amp;lt;context&amp;gt;
Project: Express.js API with JWT authentication
Endpoints: POST /auth/login, POST /auth/refresh, POST /auth/register
Environment: Node.js 20, Redis already in use for session storage
&amp;lt;/context&amp;gt;

&amp;lt;task&amp;gt;
1. Add per-IP rate limiting: max 5 requests/minute on /login and /register
2. Add per-user rate limiting: max 20 requests/hour on /refresh
3. Return 429 with Retry-After header on limit exceeded
4. Do not affect non-auth endpoints
&amp;lt;/task&amp;gt;

&amp;lt;constraints&amp;gt;
- Reuse existing Redis connection
- Do not modify JWT validation logic
- Rate limit state must survive server restarts
&amp;lt;/constraints&amp;gt;

&amp;lt;output_format&amp;gt;
1. New middleware file
2. Diff showing changes to auth routes
3. Two Jest test cases: limit hit + normal flow
&amp;lt;/output_format&amp;gt;

Think through this step by step before answering.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What Claude produces:&lt;/strong&gt; a complete, production-ready implementation with tests — not a generic overview of rate limiting options.&lt;/p&gt;




&lt;h2&gt;
  
  
  Beyond the 7 principles: 5 advanced patterns
&lt;/h2&gt;

&lt;p&gt;steelprompt also detects situations where extra patterns help:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chain detection&lt;/strong&gt;: when a task spans multiple sequential steps ("refactor auth.py, add tests, update docs"), steelprompt shows the full plan and asks for confirmation before running.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agentic safety&lt;/strong&gt;: when a task involves irreversible operations (deleting records, dropping tables), safety constraints are automatically injected — show affected row count, require confirmation, do not touch unspecified tables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Long context ordering&lt;/strong&gt;: when tasks reference long files, steelprompt moves the file content &lt;em&gt;before&lt;/em&gt; the task description — matching Anthropic's guideline that long data should precede the query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prefill anchors&lt;/strong&gt;: for rigidly critical output formats (JSON, YAML, SQL), steelprompt adds a prefill character (&lt;code&gt;{&lt;/code&gt;, &lt;code&gt;---&lt;/code&gt;, &lt;code&gt;SELECT&lt;/code&gt;) to lock Claude into the correct format from the first token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Negative examples&lt;/strong&gt;: for ambiguous format tasks, steelprompt generates &lt;code&gt;&amp;lt;bad_example&amp;gt;&lt;/code&gt; blocks alongside &lt;code&gt;&amp;lt;example&amp;gt;&lt;/code&gt; blocks — showing what &lt;em&gt;not&lt;/em&gt; to produce reduces hallucinations on format-sensitive tasks.&lt;/p&gt;




&lt;h2&gt;
  
  
  Modes
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/steelprompt mode full      &lt;span class="c"&gt;# default: full 3-tier protocol&lt;/span&gt;
/steelprompt mode preview   &lt;span class="c"&gt;# shows engineered prompt before running&lt;/span&gt;
/steelprompt mode ask-only  &lt;span class="c"&gt;# clarifying questions only&lt;/span&gt;
/steelprompt mode off       &lt;span class="c"&gt;# disable entirely&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;preview&lt;/code&gt; mode is particularly useful for learning — you see exactly what gets injected, and you can edit or cancel before Claude runs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude plugin marketplace add bhutano/bhutano-marketplace
claude plugin &lt;span class="nb"&gt;install &lt;/span&gt;steelprompt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Requirements: Claude Code 2.0.22+ · Python 3.8+&lt;/p&gt;

&lt;p&gt;No API keys. No configuration. No external calls. Defaults to &lt;code&gt;full&lt;/code&gt; mode.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why a hook, not a wrapper
&lt;/h2&gt;

&lt;p&gt;The design choice I'm most happy with: steelprompt runs &lt;em&gt;inside&lt;/em&gt; Claude's inference, not before it. There's no separate API call, no added latency, no extra cost. The restructuring happens as part of the same inference that produces the response.&lt;/p&gt;

&lt;p&gt;This also means it works with all of Claude Code's native features — slash commands, context files, multi-turn conversations — without interference.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Support for custom principle profiles per project&lt;/li&gt;
&lt;li&gt;Integration with &lt;code&gt;.claude&lt;/code&gt; project context files&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;diff&lt;/code&gt; view comparing original vs engineered prompt side by side&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contributions welcome: &lt;a href="https://github.com/bhutano/steelprompt" rel="noopener noreferrer"&gt;github.com/bhutano/steelprompt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you try it, I'd genuinely like to know what breaks. Open an issue or find me on the Anthropic Discord.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>promptengineering</category>
      <category>python</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
