I use AI tools every day, mainly for the parts of frontend work that are high-volume and low-ambiguity: scaffolding, repetitive refactors, test structure, documentation and the first pass at an unfamiliar API. I do not treat the output as authored code. It is a draft from a fast, confident colleague who has not read the ticket, cannot run the application, and will not be on call if it breaks.
1. Use it where the feedback loop is fast
AI assistance pays off when a wrong answer is cheap to detect. Good candidates:
- Boilerplate with a known shape: a component skeleton, a test file, a typed API client following an existing pattern.
- Mechanical refactors: renaming, extracting a function, converting a callback to async/await, updating a deprecated API across many files.
- Explanation: summarising an unfamiliar module, explaining a stack trace, or mapping a legacy pattern to its modern equivalent.
- Test ideas: edge cases you might not have listed, as long as you verify each one.
- Documentation cleanup: turning working notes into a readable README or changelog.
It is weaker where correctness is expensive to check: complex state machines, security boundaries, performance-critical rendering, accessibility semantics, and anything whose requirements live in a conversation rather than the prompt.
2. Know the failure modes
The risks are consistent enough to name:
| Failure | What it looks like | Gate |
|---|---|---|
| Hallucinated APIs | A method that does not exist, or exists with different arguments in this version. | Compile, run, read the docs for the exact version. |
| Phantom dependencies | A plausible package name that is not the real library — or is a malicious lookalike. | Dependency allowlist and manual install. |
| Insecure defaults | innerHTML with user data, disabled TLS checks, secrets in sample code. |
Security lint, review checklist, secret scanning. |
| Accessibility regressions | Clickable divs, missing labels, focus traps that do not release. |
Automated a11y tests plus manual keyboard passes. |
| Tests that assert the bug | A test generated from the implementation, which passes whether or not the behaviour is right. | Write the expectation first; review tests as carefully as code. |
| Licence contamination | Copied code with an incompatible licence, or attribution stripped. | Provenance check for anything non-trivial. |
3. Give the model your constraints, not just the task
Generic prompts produce generic code. The context that improves output is the same context a new teammate would need:
- The framework and exact major version, and the patterns already used in the repository.
- The test runner, lint rules and type strictness.
- The accessibility requirements and the design-system components to use.
- The public contract: inputs, outputs, error states and what must not change.
- An example of an existing file that is considered good.
Ask for a plan before the patch on anything larger than a single function. Reviewing a five-line plan is cheaper than reviewing a 400-line diff that solved the wrong problem.
4. Keep the engineering gates exactly where they are
The speed-up is real only if it survives the same quality system as handwritten code. That means:
- Types, lint and formatting pass with no blanket suppressions added.
- Unit and integration tests cover the behaviour, not just the happy path.
- A human reviews the diff for correctness, security, accessibility and fit.
- New dependencies are approved and pinned, with a real package and a maintained release history.
- The bundle and performance budgets still pass.
- No secrets, customer data or proprietary source is pasted into a third-party tool without approval.
If a team finds itself weakening a gate to keep the velocity, the tool is not the problem. The workflow is.
5. A workflow that holds up
This is the loop I use for a non-trivial change:
- Write the contract first. Types, function signature, expected behaviour and the failing test. This is the part I do not delegate.
- Ask for a plan. Two or three options, with trade-offs, before any code.
- Generate the smallest diff that satisfies the contract. One concern per change.
- Run it. Compile, test, and exercise the real UI, including keyboard and error states.
- Review as if a colleague wrote it. Because in effect one did. Assume the comment “this looks right” is not a review.
- Record the decision. If the generated approach is non-obvious, leave a short note in the pull request or the code.
Disclose substantial generation in the pull request. Reviewers calibrate their attention differently when they know a large part of the diff was machine-drafted. That is not bureaucracy; it is how review stays effective.
6. Measure the gain honestly
Lines of code generated is not a useful metric; it measures output, not outcome. Track:
- Lead time for comparable changes, before and after adoption.
- Change failure rate and rework, to catch quality debt early.
- Review time and review comments per change.
- Defects found in production that trace back to generated code.
- Time spent on repetitive tasks that the team would rather not do.
If lead time improves and failure rate does not, you have found a good use. If both improve for a quarter and then quality collapses, look for skipped review and tests.
7. Team norms worth writing down
- AI output is a draft, not an authority. The engineer who submits it owns it.
- Do not paste secrets, personal data or unreleased proprietary code into tools that are not approved for it.
- Verify every API against the documentation for the version in use.
- Never let a model choose a dependency; approve it like any other supply-chain decision.
- Use AI to raise the floor — tests, docs, consistency — before using it to raise the ceiling.
The teams that benefit most are not the ones generating the most code. They are the ones with strong tests, clear contracts, fast feedback and reviewers who read carefully. AI amplifies that system. It also amplifies the absence of one.
Related reading: the quality gates that make AI-assisted work safe overlap with the Angular performance checklist and the WCAG 2.2 component checklist.