← Back to list

The Best AI Coding Hack I Found Wasn’t a Prompt. It Was a Boundary.

You will learn a simple boundary framework for AI-assisted coding: what files the agent can touch, what it must not touch, how it should…

Sukhpinder Singh in Write A Catalyst · 2026-06-09 18:57 · 123 claps · 6.2 min read paywalled
#ai #programming #software-development #github-copilot #developer-productivity
Open on Medium ↗
Wiki topics: LLM · Large Language Models AGT · AI Agents AI · AI · General 💻 · Programming 🔓 · Open Source ⏱️ · Productivity

The Best AI Coding Hack I Found Wasn’t a Prompt. It Was a Boundary.

You will learn a simple boundary framework for AI-assisted coding: what files the agent can touch, what it must not touch, how it should validate changes, and when it should stop.

Cover image created with AI image generation.

Cover image created with AI image generation.

They fail because the task is too open.

A model that can search files, edit code, run commands, read tool output, and continue making decisions is not just answering a question. It is operating inside your project.

The useful move is not always “write a better prompt.”

Sometimes the useful move is smaller:

Tell the agent where the fence is.

A prompt asks for work. A boundary defines the work area.

Most developers already know the bad version of AI-assisted coding.

You ask:

Refactor this service to make it cleaner.

The agent reads too much, changes too much, invents a pattern, touches unrelated files, and gives you a confident summary that sounds better than the diff actually is.

The problem was not grammar.

The problem was permission.

Here is the practical difference.

Weak AI coding request:

Refactor this service and make it cleaner.

Boundary-based request:

Refactor only the validation logic in this service. Do not change public method names, request/response contracts, database models, migrations, or tests unless you explain why first. If the change requires more than three files, stop and propose a plan

The second version is not more clever.

It is safer.

It tells the AI what success looks like, what danger looks like, and when to stop.

The boundary is the real interface.

When developers talk about AI coding, they often focus on the visible sentence they type into the chat box.

But for agentic tools, the real interface is larger than the prompt.

It includes:

  • which files the agent can read
  • which files it can edit
  • which commands it can run
  • which tests count as validation
  • which architectural rules are non-negotiable
  • when it should stop and ask for review

This matters more as coding assistants become more agent-like.

A chat response is easy to ignore. A tool-using agent can create a branch, edit files, call external tools, or act on information pulled from the repo.

That means the quality of the result depends less on clever wording and more on the shape of the sandbox.

A small example

Bad task:

Fix the failing tests.

Better task:

Fix only the failing tests related to InvoiceTotalCalculator. Do not update snapshots. Do not change production behavior unless a test proves the current behavior is wrong. First identify the failing assertion, then propose the smallest code change. Stop after one implementation attempt and show the diff.

The second version gives the AI less room to perform.

That is the point.

The goal is not to make the model feel trusted. The goal is to make the work reviewable.

A useful AI coding task should have a blast radius small enough that a tired developer can still review it.

The pattern to look for

The pattern is simple:

If the AI needs to understand the whole codebase to complete the task, the task is probably too large.

That does not mean the tool is bad.

It means the work has the wrong shape.

A coding agent is much easier to review when it is solving one bounded problem instead of “improving” a system.

This is where many AI coding workflows go wrong. The request sounds normal to a human:

Clean this up. Fix the tests. Improve this module. Make this easier to maintain.

Those are not small tasks for an agent.

They are open invitations.

Boundaries beat vibes.

A lot of AI coding advice sounds like this:

Be specific. Give context. Ask it to think step by step.

That advice is not wrong.

It is just incomplete.

Specificity helps the model understand the request. Boundaries help the developer trust the result.

Those are different goals.

A prompt improves output.

A boundary protects the codebase.

For coding work, protection matters because the output is not an essay. It is a diff that may change runtime behavior, tests, dependencies, configuration, or deployment assumptions.

The more access the assistant has, the more important the fence becomes.

The four boundaries worth defining

Before asking an AI coding tool to make a change, define four things.

1. File boundary

Tell it what it can touch.

Example:

You may edit only files under /src/billing/. Do not edit shared contracts, migrations, generated files, or CI configuration.

This avoids the classic “helpful” change where the agent solves a local problem by changing a global abstraction.

2. Behavior boundary

Tell it what must remain true.

Example:

Preserve existing public API behavior. Do not change request or response shapes. Do not rename exported functions.

This matters when the model finds an easier fix by changing the contract instead of the implementation.

3. Validation boundary

Tell it what proof is required.

Example:

Run the existing unit tests for this module. If tests cannot run, explain exactly why and provide the command that failed.

Without this, the agent may summarize intent instead of proving the change.

4. Stop boundary

Tell it when to stop.

Example:

If the fix requires touching more than three files, stop and propose a plan instead of editing.

This is the most underrated one.

An AI coding agent can keep digging long after a human would pause and ask, “Why is this getting bigger?”

Use a plan-first rule for risky work

For risky work, use a plan-first rule:

Do not edit yet. First inspect the relevant files, explain the likely change, list the files you would touch, and wait for approval.

This one rule prevents a surprising amount of damage.

It separates diagnosis from execution.

That matters because many AI coding mistakes happen when the agent guesses the design too early and starts editing before the problem is understood.

Plan-first mode is especially useful when the task touches:

  • authentication
  • payments
  • migrations
  • permissions
  • public APIs
  • deployment scripts
  • shared libraries
  • generated files
  • test snapshots

The rule is simple:

If the cost of a wrong edit is high, make the agent explain before it acts.

The boundary checklist

Before asking an AI coding tool to touch code, answer six questions:

  • Which files can it edit?
  • Which files are off-limits?
  • What behavior must stay unchanged?
  • What command proves the change worked?
  • What should it do if the task grows?
  • What summary do you need to review the diff quickly?

If you cannot answer those, you probably should not ask the agent to edit yet.

Ask it to investigate first.

A safer first request is:

Read the relevant files and explain the likely cause. Do not edit anything yet.

That sounds slower.

It usually saves time.

You get a map before you get a diff.

Where repo instructions help

One-off boundaries can live in the task prompt.

Recurring boundaries should live closer to the repo.

For example, a project can document:

  • build commands
  • test commands
  • lint rules
  • architectural constraints
  • folders the agent should not edit
  • generated files that should never be hand-modified
  • review expectations for risky changes

That kind of instruction is not decoration. It turns tribal knowledge into an operating manual for both humans and agents.

GitHub Copilot supports repository-level and path-specific custom instructions, including instruction files such as .github/copilot-instructions.md and AGENTS.md depending on the surface being used.

Claude Code also documents permission controls such as edit allow/deny rules, read deny rules, sandbox-related filesystem controls, and subagent capability controls.

The point is not to make the AI “understand the whole codebase.”

The point is to stop it from rediscovering the same rules badly every time.

The tradeoff

Boundaries can make the agent slower.

Sometimes it will stop instead of solving the whole problem. Sometimes it will ask for a plan review. Sometimes it will refuse to touch a file that would have made the fix easier.

That can feel annoying.

But the alternative is worse: a large diff that looks coherent until you realize it changed the wrong layer.

The best AI coding workflow is not the one where the agent writes the most code.

It is the one where the human can still understand the change.

A useful default template

Use this as a starting point:

Task:
[Describe the change.]

Scope:
You may edit only:
- [file or folder]

Do not edit:
- [off-limits files, folders, generated code, migrations, contracts]

Behavior rules:
- Preserve existing public behavior unless explicitly stated.
- Do not rename public APIs.
- Do not introduce new dependencies without asking.

Validation:
- Run [specific command].
- If validation fails, show the exact error and stop.

Stop rule:
- If the change requires more than [N] files or changes the design, stop and propose a plan first.

Review summary:
- List files changed.
- Explain why each file changed.
- Mention any risk or follow-up.

This template will not make every AI coding result good.

It will make bad results easier to catch.

That is already a win.

The real hack

The next time an AI coding tool gives you a messy diff, do not only blame the prompt.

Ask a sharper question:

Did I give the agent too much freedom?

Before asking for code, define the fence:

  • where it can work
  • what it cannot change
  • what behavior must stay stable
  • how it must prove the result
  • when it must stop

That is the habit worth building.

Not because boundaries make AI coding perfect.

Because they make the output small enough, clear enough, and boring enough for a human to review.

And in real software work, reviewable beats impressive.


메타데이터
post_id
71c7bba2e46c
slug
the-best-ai-coding-hack-i-found-wasnt-a-prompt-it-was-a-boundary-71c7bba2e46c
url
https://medium.com/write-a-catalyst/the-best-ai-coding-hack-i-found-wasnt-a-prompt-it-was-a-boundary-71c7bba2e46c
canonical_url
https://medium.com/write-a-catalyst/the-best-ai-coding-hack-i-found-wasnt-a-prompt-it-was-a-boundary-71c7bba2e46c
author_url
https://medium.com/@singhsukhpinder
status
ok
fetched_at
2026-06-11 10:13:20