Home/Blog/Coding & Data
Coding & Data · 11 min read

How to use AI coding assistants safely and well in a team

The short answer

To use AI coding assistants safely, give them a short instruction file and a clear task with testable acceptance criteria, ask for a plan before code, make tests the stop condition, enforce the rules that must never break with deny rules, sandboxing and CI rather than prose, review every diff tests-first by risk, and measure change against a baseline instead of trusting how fast it feels.

Want the tools, not just the method? The The Claude Code and AI Coding Assistants Playbook kit turns this guide into ready-to-use templates, spreadsheets and printables, with an instant download.

Key takeaways
  • Write down only what the code cannot tell the assistant; keep instruction files short.
  • Rules that must never break belong in settings, hooks and CI, not in sentences.
  • Ask for a plan above a threshold; arguing with a plan is cheaper than arguing with a diff.
  • Tests are the clearest prompt and the only reliable stop condition.
  • Review by risk, tests first, with a size limit.
  • Controlled studies disagree; measure your own team against a baseline.

What are the steps to use an AI coding assistant safely?

Most problems with AI coding assistants are not caused by a weak model. They come from missing context, missing limits and missing checks. An agentic assistant works in a loop: it reads context, picks an action, uses a tool such as editing a file or running a command, looks at the result and decides again. Anthropic describes Claude Code as an agentic coding tool that reads your codebase, edits files, runs commands and integrates with your development tools. GitHub's Copilot cloud agent works the same way inside an ephemeral environment and opens a pull request per task.

So the method is about shaping that loop. Eight steps cover it, and each one is small.

  • 1. Choose tools by workflow and control, and start every new tool in a read-only or planning mode on a branch.
  • 2. Add a short instruction file (AGENTS.md, CLAUDE.md or your tool's equivalent) with commands and the rules the code cannot show.
  • 3. Put rules that must never break into deny rules, hooks and CI.
  • 4. Write a task card: goal, context, constraints, testable acceptance criteria including failure cases, and the evidence you want back.
  • 5. Ask for a plan above a threshold and check it before any code changes.
  • 6. Make tests the specification: write them, see them fail, then ask for the smallest change.
  • 7. Review every diff by risk, tests first, under a size limit.
  • 8. Measure throughput, stability, review load and cost against a baseline.

What should go in an instruction file such as AGENTS.md or CLAUDE.md?

Only what the assistant cannot learn by reading the code. Anthropic's best-practice guide suggests a two-question test: could it find this by reading the code, and would it actually look? If both answers are yes, leave it out. What remains is usually short: the exact command to run one test file, a pattern the code still contains but new code must not copy, a decision made in a meeting, and your definition of done.

Keep it short because it is read on every task. Claude Code's memory documentation recommends under 200 lines per file. GitHub Copilot reads .github/copilot-instructions.md, path-specific instruction files and AGENTS.md files, where the nearest one wins. Cursor reads project rules in .cursor/rules and AGENTS.md. A single shared AGENTS.md, imported or pointed to from each tool's own file, keeps your rules in one place.

Security lines help when they are specific. The Open Source Security Foundation's guide for AI code assistant instructions recommends lines such as never including secrets in output and never adding malicious or hallucinated dependencies.

Why should rules that must never break live in settings rather than prompts?

Because the model reads prompts and instruction files and usually follows them, with no guarantee. Anthropic's guide draws the line clearly: prompts, CLAUDE.md and skills are non-deterministic; hooks, deny rules and managed settings are enforced by the tool every time. Its documentation adds that deny rules hold in every permission mode.

This matters most for prompt injection. Researchers showed in 2023 that applications built on language models blur the line between data and instructions, so text hidden in a web page, document or issue can steer an agent. OWASP's guidance says no fool-proof prevention is known and recommends least privilege, human approval for privileged actions and keeping untrusted content clearly separated. A deny rule on secret files does not care how persuasive the hidden text is.

How do you write a task an AI assistant can finish?

Use a five-part task card: a one-sentence goal in behaviour terms, the context (files, patterns, decisions), the constraints (what must not change), three to seven checkable acceptance criteria, and the evidence you want back, usually the test command and its output plus the diff. Write the failure cases yourself. Assistants handle the happy path without help; what happens on empty, negative, duplicated or unauthorised input is where your card earns its keep.

For anything that touches more than one file, a money or auth path, or code you could not sketch from memory, ask for a plan first and check six things: files, reuse of existing code, small steps, tests, risk areas and scope. Anthropic's cost guide notes that plan mode prevents expensive rework when the first direction is wrong.

How should you test and review AI-written code?

Tests are the clearest prompt you can give an assistant and the only reliable signal that it is done. Write the test, watch it fail, then ask for the smallest change that makes it pass without editing the tests. Research on test-driven development found that small, steady steps mattered more for quality than whether tests came first, which is exactly what keeps AI changes reviewable.

Review is where most teams slip. A Microsoft study of code review found that understanding the change is the heart of reviewing. Security research found vulnerable code in a large share of generated programs for high-risk scenarios, and a Stanford study found people using an assistant wrote less secure code while believing it was more secure. Automated reviewers help, with limits: in one company's deployment most automated comments were resolved, but pull requests took longer to close and engineers reported irrelevant comments.

A practical rule set: a size limit (many teams pick a few hundred changed lines), tests read first, review depth by risk, a second reviewer for money, auth, secrets, data export and dependencies, and never approving a line you cannot explain.

Do AI coding assistants actually make developers faster?

The controlled evidence is mixed, and the settings explain much of the spread. A lab study by GitHub, Microsoft and MIT researchers found developers finished one standard HTTP-server task 55.8% faster with Copilot. Randomised field experiments with 4,867 developers at Microsoft, Accenture and a Fortune 100 company found 26.08% more completed tasks, a throughput count rather than a quality measure, with larger gains for less experienced developers. A trial with 96 Google engineers using internal tools in 2024 estimated about 21% less time on one task, with a wide confidence interval. A trial with 16 experienced open-source developers in their own mature repositories, using early-2025 tools, found AI made them 19% slower, while they believed it had made them 20% faster. METR's 2026 follow-up found small speed-ups whose confidence intervals include zero, which it called very weak evidence.

Two lessons follow. Self-reported speed is not evidence. And one number misleads: track throughput, stability, review load and cost together, against a baseline taken before the change.

Metric (worked example, SAMPLE)Baseline: 4 weeksLast 4 pilot weeksChange
PRs merged per week30.541+34%
Median cycle time (hours)5238-27%
Change failure rate8.5%7.25%peak 14% in week 4
Median PR size (lines)178208peak 410
Tool spend per engineer per monthn/a$230within the vendor's reported range
Measure where you are

Reading helps; measuring tells you what to work on. These AI-graded assessments on AssessAll pair with this topic:

How do you build an honest business case?

Use four cases and show the low one first. In the worked example, an eight-engineer squad at a loaded $95 an hour spends 114 hours on set-up, security review, training and measurement, a one-off $10,830. If engineers save one hour a week but spend 45 minutes checking AI output, the net is -$1,177 a month and it never pays back. With three hours saved and one spent checking, the net is $4,747 a month and break-even comes in about 2.3 months. Every input is an estimate, and saying so is what makes leaders trust it.

Anthropic's cost documentation reports enterprise averages of around 13 dollars per developer per active day and 150 to 250 dollars per developer per month for Claude Code, and recommends a small pilot to set your own baseline. Seat-priced tools publish plan prices; check the vendor page on the day you decide.

How do you roll out AI coding assistants to a team and onboard new developers?

Run a pilot before a rollout. Pick one squad and one or two repositories, freeze four weeks of baseline metrics, get a one-page sign-off with a spend limit and an end date, and agree in advance what would make you stop. Write the decisions down as you go: which tools, which default permission mode for which folders, where AI is off-limits (secrets, production configuration and customer data are the usual answers), and the pull-request size limit. A short decision log is what lets you explain the curve later.

Train before you measure. A 45-minute briefing that covers how agents work, a live demo of plan mode and test-first prompting, and a pair exercise reviewing a planted AI-written patch gives everyone the same habits. Then give people small practice tasks with known answers before they work on production code, so the first mistakes happen where they are cheap.

Protect learning for new joiners and students. A randomised skills experiment with 52 developers, published as a preprint by researchers in Anthropic's Fellows Program, found that AI use while learning a new library lowered quiz scores on understanding and debugging unless learners stayed engaged, for example by asking the assistant to explain rather than write. A simple onboarding rule works: in the first weeks, use the assistant to map the codebase and answer 'why' questions, write your own tests, and ask for code only after you can say what it should do. Pair each new joiner with a reviewer who asks them to explain their AI-written lines, kindly and every time. Students should follow their institution's academic-integrity rules first and declare how they used any assistant.

Finally, decide expansion with a go/no-go gate: critical items such as deny rules, secret scanning, tests on every pull request and reviewed vendor data terms must all be in place, and non-critical gaps get an owner and a date.

What are the most common mistakes teams make?

  • Asking an agent to 'make the test pass' instead of describing correct behaviour, then not noticing it edited the test.
  • Writing a long instruction file instead of enforcing the few rules that matter in settings.
  • Approving plans and diffs that were skimmed, not read.
  • Letting the assistant write both the tests and the code in one go.
  • Accepting a confident bug explanation without the command output that proves it.
  • Refactoring and changing behaviour in the same pull request.
  • Installing a suggested package without checking it exists and is approved.
  • Reporting a survey as the productivity result.

Which rules apply in the US, UK, EU, Canada and Australia?

Most guidance on AI coding tools is voluntary and practical. In the US, NIST's Secure Software Development Framework and its generative AI profile describe secure-development practices, and the Copyright Office concluded that AI output is protected only where a human determined sufficient expressive elements. In the UK, the NCSC's guidelines for secure AI system development and the AI Cyber Security Code of Practice set baselines. In the EU, the AI Act's AI literacy duty applied from February 2025 and, since the 2026 AI Omnibus (Regulation (EU) 2026/1744), requires providers and deployers to take measures to support their staff's AI literacy rather than guarantee a level; the Cyber Resilience Act brings security duties for software products with obligations phasing in from 2026 to 2027, and the GDPR applies to personal data in prompts. Canada's federal guide warns about putting sensitive data into unmanaged tools and about licence issues in generated code. Australia's Guidance for AI Adoption sets out six essential practices.

This is educational, not legal advice. Check the official sources and your adviser, because dates and duties change.

Bodhih Pro Kit

Get the files for every step

The Claude Code and AI Coding Assistants Playbook includes a real practice project with ten exercises, instruction files for three tools, a review checklist, a pilot dashboard and a business case calculator. Turn your gaps into a development plan with Jobulary.

Common questions

Questions people ask next

What is an agentic coding assistant?

An AI tool that works in a loop: it reads context, uses tools such as editing files and running commands, checks results and repeats until it judges the task done. Claude Code, Copilot's cloud agent and agent modes in IDEs are examples.

Is it safe to let an AI agent run commands on my laptop?

It can be, with limits: a considered permission mode, deny rules for secrets, a sandbox or container for risky work, and no bypass-style modes outside isolated environments. Anthropic's documentation says its bypass mode offers no protection against prompt injection.

Should AI write the tests too?

It can suggest edge cases, but you should decide intended behaviour and see each test fail before code exists. An assistant that writes tests and code together can encode the same misunderstanding twice.

How big should an AI-written pull request be?

Small enough to review properly in one sitting. Many teams set a limit of a few hundred changed lines and split larger work.

What is a hallucinated package?

A dependency name an assistant suggests that does not exist. A large study found invented names in at least 5.2% of packages suggested by commercial models and 21.7% by open-source models; an attacker can register such names.

Can students use AI coding assistants?

Only as their institution's academic-integrity rules allow. Where it is allowed, declaring use, writing your own tests and asking the assistant to explain rather than write protects your learning; research found AI use impaired understanding when learners disengaged.

How can I assess my team's code review judgement?

AssessAll's Code Review Assessment for Software Engineering Teams gives a measured starting point you can repeat after a pilot.