Nov 28, 2026 · 6 min · Dev Guides

Does Task Framing Change How Claude Code Works? A Preliminary Study

Does Task Framing Change How Claude Code Works? A Preliminary Study

Does Task Framing Change How Claude Code Works? A Preliminary Study

A common Claude Code failure looks deceptively simple: the agent opens three files, changes the wrong abstraction, runs the existing test suite, and reports success—while the requested behavior remains untested.

The code was not necessarily difficult. The task was framed poorly.

In practice, I have seen the same repository produce materially different outcomes depending on whether a request was framed as an outcome, a list of constraints, or a warning about what not to do. The underlying model does not change. What changes is the objective Claude optimizes for on every turn of its agent loop.

This is a preliminary practical study, not a model benchmark. I use the term “preliminary” deliberately: execution environment, repository state, tool permissions, and nondeterministic tool results all affect a coding-agent run. The useful question is not whether one prompt is universally best. It is whether task framing produces repeatable behavioral shifts developers can predict and exploit.

What “Task Framing” Means Here

Task framing is the structure and language used to define work for an AI coding agent.

Consider these three descriptions of the same task:

Outcome-first

Add a per-user rate limiter to the order endpoint. Return HTTP 429 when the limit is exceeded and include Retry-After in the response.

Constraint-first

Modify only the order creation path. Do not change authentication, persistence models, or public response schemas. Add tests for requests under and over the limit.

Prohibition-heavy

Avoid breaking authentication. Never modify the database schema. Be careful not to introduce race conditions or inconsistent behavior.

All three mention the same feature. They create different search spaces for the agent:

Claude Code does not receive a task as passive prose. It interprets the request through its system instructions, repository context, conversation history, available tools, and tool results. Framing influences which files it reads, which abstractions it considers, whether it asks a question, and how it decides that the task is complete.

A Small, Reproducible Evaluation Setup

For a meaningful preliminary comparison, use a tiny isolated problem rather than an entire feature request.

Suppose a Python service needs a rate limiter with this contract:

from collections import defaultdict, deque
from time import monotonic


class RateLimiter:
    def __init__(self, limit: int, window_seconds: float):
        self.limit = limit
        self.window_seconds = window_seconds
        self._requests = defaultdict(deque)

    def allow(self, user_id: str) -> bool:
        now = monotonic()
        requests = self._requests[user_id]

        while requests and requests[0] <= now - self.window_seconds:
            requests.popleft()

        if len(requests) >= self.limit:
            return False

        requests.append(now)
        return True

The acceptance test could be:

def test_rate_limiter_rejects_requests_over_limit():
    limiter = RateLimiter(limit=2, window_seconds=60)

    assert limiter.allow("user-1") is True
    assert limiter.allow("user-1") is True
    assert limiter.allow("user-1") is False


def test_rate_limiter_is_per_user():
    limiter = RateLimiter(limit=1, window_seconds=60)

    assert limiter.allow("user-1") is True
    assert limiter.allow("user-2") is True

A reasonable evaluation rubric includes:

For each prompt variant, begin from a clean checkout and a fresh Claude Code session. Otherwise, conversational history becomes a confounding variable: the second framing may perform better simply because the first run already revealed the relevant file.

What Tended to Change Across Framings

Framing styleAgent behaviorMain benefitMain risk
Outcome-firstMoves directly toward observable behaviorClear completion criteriaMay ignore architectural constraints
Constraint-firstInvestigates repository conventions before editingFewer out-of-scope changesCan become overcautious
Steps-firstExecutes an explicit sequencePredictable and auditableMay blindly follow an invalid plan
Prohibition-heavySpends more effort checking what could go wrongUseful for risky operationsCan delay progress or refuse useful work
Test-drivenEstablishes a failing test firstStronger verificationTest design can become a distraction
Repository-firstLocates patterns and adjacent implementationsBetter local consistencyMore exploration and token usage

The most effective version in my preliminary work was usually a hybrid: one outcome, a small number of hard boundaries, and executable acceptance criteria.

A better prompt for the rate-limiter task would be:

Implement the existing RateLimiter contract in ratelimit.py. It must allow up to 60 requests per user per rolling 60-second window and reject further requests. Add focused tests covering independent users, the request limit, and expiry of old requests. Do not modify the service API or persistence layer. Run the focused tests and report any assumptions about time handling.

This framing gives Claude four things:

  1. A concrete behavioral target.
  2. A file-level scope boundary.
  3. Verifiable examples.
  4. A completion instruction.

The “do not modify” sentence is useful because it names adjacent areas likely to be touched accidentally. It is not useful when it expands into a long catalog of everything the agent should fear.

A Common Gotcha: Negative Instructions Can Become Salient Goals

Negative framing is not inherently weaker. For destructive commands or security-sensitive changes, explicit boundaries are essential:

Do not access production credentials. Do not run database migrations. Work only in the staging fixture directory.

That is clearer than:

Be safe with data and careful around production systems.

However, stacking prohibitions can distort the agent’s search behavior. A prompt such as “never introduce a race condition” does not tell Claude how to design the implementation. It may prompt repeated inspection, an unnecessary rewrite, or a refusal to proceed without further information.

A better conversion is:

Protect the shared counter with a lock so concurrent requests cannot exceed the configured limit. Add a concurrency test if the project already has a pattern for them.

This replaces a vague fear with an implementable engineering requirement.

The same principle applies to scope:

Specificity is more useful than severity.

The Difference Between Framing and Tool Design

Prompt framing cannot overcome a poor agent environment.

In practice, a beautifully framed request still performs poorly when:

task framing
    + repository state
    + tool permissions
    + model capability
    + tool feedback
    = observed coding behavior

This distinction matters when moving from Claude Code to direct API useClaude Code provides a scaffold: it reads files, executes commands, observes errors, and continues from that feedback. A raw API request does not automatically reproduce that loop.

When translating a successful Claude Code interaction into an API workflow, preserve the task contract rather than copying conversational wording:

{
  "task": "Implement a rolling per-user rate limiter",
  "target_files": [
    "ratelimit.py",
    "tests/test_ratelimit.py"
  ],
  "constraints": [
    "Preserve the public function signature",
    "Do not modify persistence or authentication code"
  ],
  "acceptance_tests": [
    "Different users have independent limits",
    "Requests over the limit are rejected",
    "Requests outside the window are accepted"
  ],
  "required_verification": [
    "Run the focused test file",
    "Report unresolved assumptions"
  ]
}

For Claude’s Messages API, place stable task rules in the system prompt and the mutable repository state in the user message or tool results. GPT and Gemini APIs have different schemas and tool-calling conventions, but the principle is portable: encode the outcome, boundaries, evidence, and completion criteria.

Cost Changes When Framing Changes the Work

Prompt wording affects cost indirectly by changing tool use.

A vague task may trigger broad repository exploration. An outcome-first prompt with exact file targets may reduce search. A prohibition-heavy prompt may create extra loops of inspection and verification.

If one run sends approximately 1,600 input tokens and 3,200 output tokens across multiple turns, a simple cost calculation is:

cost = (input_tokens / 1,000,000) × input_rate
     + (output_tokens / 1,000,000) × output_rate

The important detail is that tool calls add more context on the next turn. A repository scan that adds 20,000 tokens may affect both cost and behavior more than the initial wording.

I therefore evaluate prompts on total successful work, not prompt elegance:

time claude
pytest -q tests/test_ratelimit.py

If you are running the same evaluation across Claude, GPT, and Gemini, multi-model API access can make the comparison practical. AI Prime Tech is one option for cheaper Claude/GPT/Gemini API access, particularly when a test matrix multiplies requests. The current model rate still matters, so calculate from the provider’s present pricing rather than assuming every model has the same economics.

Better Task Contracts for Real Development

For routine work, I use this structure:

1. State the observable outcome

Add idempotency handling to create_order so replaying the same request returns the original order instead of creating a duplicate.

2. Name the permitted change surface

Modify the order service and its tests. Do not alter the database schema.

3. Define edge cases as examples

Include concurrent requests with the same idempotency key and requests that reuse a key with a different payload.

4. Require evidence

Run the focused test suite and summarize any assumption that cannot be verified locally.

5. Separate required behavior from optional ideas

Keep the change small. Do not introduce a new framework or redesign the order module.

This format works well in Claude Code, but it also maps cleanly to API tool policiesClaude, GPT, and Gemini differ in how they plan, call tools, and respond to system instructions. They do not need identical prompting styles. They do need equally explicit success criteria.

Practical Takeaways

Claude Code Desk covers Claude Code, agents and developer workflows for Claude API Key. Check version-specific details such as model IDs, prices and limits against the official documentation before relying on them.

Get cheaper Claude API access

One API key for Claude Opus 4.8, Sonnet 4.6, Haiku 4.5, Fable 5, plus GPT & Gemini — up to 80% off official pricing, pay-as-you-go.

Get Your API Key →
AI Prime Tech is an independent third-party API gateway. Claude™ and Anthropic® are trademarks of Anthropic, PBC. No affiliation or endorsement is implied.