# Using AI Coding Assistants Well (and Safely)

> How to get reliable results from AI coding tools on data projects: give context, ask for small changes, verify with tests, and protect secrets.

- Source: https://akshaythakare.com/notes/ai-tools/ai-coding-assistants
- Topic: AI Tools
- Level: beginner
- Reading time: 2 min
- Tags: ai-tools, productivity, coding, best-practices
- Updated: 2026-10-11

## What they are good at

- Boilerplate: DAG skeletons, schemas, CLI wiring, test scaffolding
- Explaining unfamiliar code or an error message
- Translating between SQL dialects or from pandas to PySpark
- First drafts of documentation and tests

## What to watch

- Plausible but wrong code: APIs that do not exist, wrong defaults, subtle logic bugs
- Outdated library versions
- Over-engineered solutions to simple problems

## A workflow that works

1. **Give context**: the file, the schema, the error, the constraint ("must be idempotent").
2. **Ask for small, specific changes** rather than whole systems.
3. **Run it**: tests, linters, a dry run on sample data.
4. **Read the diff** before committing, as you would review a colleague's code.

```text
Write a PySpark function that keeps the latest row per order_id by updated_at.
Input schema: order_id string, updated_at timestamp, amount decimal(18,2).
Include a pytest with a duplicate key and a null updated_at.
```

## Protect secrets and data

- Never paste credentials, tokens or customer data into prompts.
- Check your organisation's policy on which tools may see source code.
- Review generated code for hard-coded secrets and unsafe SQL string building.

> **Tip: Treat output as a draft**
>
> You are responsible for the code you commit. Tests and review turn a fast draft into reliable work.
