How to Use AI for Coding: Practical Workflows and Best Practices

Updated:

You spend half an hour adding up records in a spreadsheet and think, “Surely a script could do this.” AI produces one in seconds, but now you have another problem: deciding whether its totals are right.

A program can finish without an error and still leave out a day, count the wrong rows, or overwrite a file you needed. To catch those mistakes before relying on the report, this guide walks through developing one, from your first request to checking the weekly totals and fixing errors.

Start With a Task You Can Verify

Choose a task whose answer you can check without trusting the code. State what goes in, what should come out, and what must stay untouched.

“Automate my business” gives AI too much room to guess. “Read completed walks from a file and total the minutes for each dog during a selected week” gives you something you can inspect.

Start With A Task You Can Verify: Choose An Ai Coding Task You Can Verify; Automate My Business; Walk Records; Weekly Minutes Per Dog; Check By Hand

For the running example, imagine you run a dog-walking business and keep completed walks in a CSV, a plain-text file with one record per row. You want a Python script that produces weekly totals. The example records use made-up dog IDs and contain no customer contact details.

Keep the first version small:

  • Read an existing CSV.
  • Check every record.
  • Select one seven-day period.
  • Add up minutes for each dog.
  • Write a separate report.
Start With A Task You Can Verify: Keep Your First Ai Coding Project Small; Read Csv; Validate Every Row; Select 7 Days; Total By Dog; Write Separate Report; Add Other Features Later

Leave booking forms, invoices, email delivery, and scheduling for later. Each adds another place where something can break.

AI helps you develop this script, but the finished utility runs without calling an AI service. Adding numbers does not require a model subscription.

For a first project, I would choose this over payment processing or customer login code. Arrange experienced review before relying on generated code for payments, access control, sensitive records, or anything that deletes or changes important data.

Choose an AI Coding Assistant That Fits the Task

Choose the kind of help you need before comparing products.

What You NeedA Suitable ApproachWhat You Still Check
Explain unfamiliar code or draft a short scriptChat with an assistant such as ClaudeSupply relevant code and review the draft before running it
Get suggestions while writingGitHub Copilot suggests code inside VS Code, a code editorRead each proposed addition before accepting it
Make a bounded change across project filesClaude Code is an agent: an assistant that can read files, edit code, and run commandsReview its plan, changes, commands, and results

These approaches overlap. You can discuss a problem in chat, accept an editor suggestion, and use an agent for a focused change.

I used Claude Code to build a custom Python content pipeline that reduced my article production from days to hours. That was my experience with a particular workflow. For your first project, the useful question is whether you can understand, check, and maintain what the assistant produces.

Start with one assistant and one small task. I would skip paying for several tools until you can name a job your current setup cannot handle.

Check subscription costs and usage limits before paying. Keep those development costs separate from the finished application’s costs. A local reporting script may need no hosting or paid API, while a public web application may need both.

If you are changing an existing project, keep its language and tools. For our standalone report, Python, a code editor, and a working Python installation are enough.

Turn the Task Into a Testable Prompt

Define Inputs, Outputs, and Acceptance Criteria

Describe the behavior before asking for an implementation. Acceptance criteria are simply the conditions the finished code must meet.

Each input row records a dog ID, a walk date, and the duration in minutes. The selected week includes its start date and the following six days. All matching walks belong in the totals, grouped by dog ID.

Define Inputs, Outputs, And Acceptance Criteria: Weekly Walk Report: From Records To Totals; Day 1; Day 7; D001: 30 Min; D002: 20 Min; D001: 45 Min; Day 0: D001, 10 Min; Day 8: D002, 15 Min; D001: 30 + 45 = 75 Min

Save this sample as walks.csv:

dog_id,walk_date,minutes
D001,2026-11-02,30
D001,2026-11-08,45
D002,2026-11-04,20
D001,2026-11-01,10
D002,2026-11-09,15

For a week starting November 2, the report should contain:

dog_id,total_minutes
D001,75
D002,20
Define Inputs, Outputs, And Acceptance Criteria: Csv Reports: Invalid Input Vs. No Matches; Validate Every Row First; Invalid Row; Error: Row + Field; No New Report; Existing Files Unchanged; Dog_Id,Total_Minutes; Valid Input, No Matching Walks

The November 1 and November 9 walks fall outside the selected week.

I would require the script to check every row before opening the report for writing. Invalid input should trigger an error identifying the row and field, with existing files unchanged. Valid input with no walks in the selected week should instead produce a report containing only:

dog_id,total_minutes

When a request grows to include several changes, split it into smaller prompts, as GitHub’s prompting guidance recommends.

Supply Relevant Context and Boundaries

Tell the assistant where the code will run and what it may change. Include your operating system, Python version, sample files, and intended command. To check your Python version, open a terminal—the window where you type commands—and enter python3 --version; on Windows, try py --version.

Attach the sample walks.csv above, then adapt this prompt:

Build a Python command-line utility that totals walking minutes
per dog for a selected seven-day period. Use the attached walks.csv
in a project folder called walk-report.

Confirm my operating system and Python 3 version before giving
setup and run instructions.

Requirements:
- Require columns dog_id, walk_date, and minutes.
- Trim dog IDs, reject blank IDs, and preserve their case.
- Require real dates in exactly YYYY-MM-DD format and positive
  whole-minute durations.
- Include the start date and following six days.
- Count each row once; group totals by dog_id.
- Output dog_id,total_minutes, sorted by dog_id.
- For start 2026-11-02, the sample must yield D001,75 and D002,20.
- Validate every row, including those outside the week, before
  opening the report for writing. Errors must identify row and field,
  leave existing files unchanged, and create no report.
- Valid input with no matching walks must yield a header-only report.
- Reject output destinations pointing to the source file.

Boundaries:
Use only Python's standard library, its built-in modules.
Keep walks.csv unchanged. Edit only weekly_walks.py,
test_weekly_walks.py, and README.md. Use temporary files for tests.
Do not install packages, contact external services, or run generated
code before my review.

Verification:
Use unittest, Python's built-in test framework, to check totals,
date boundaries, invalid input, empty results, and file preservation.
Command interface:
python3 weekly_walks.py walks.csv --start 2026-11-02 --output weekly_totals.csv

First identify unresolved requirements and propose a short plan.
Do not edit files yet.
Supply Relevant Context And Boundaries: Build A Bounded Ai Coding Prompt; Python 3; Environment + Sample Files; Behavior + Expected Results; Edit Only Named Files; Protect The Input; No Installs Or External Calls; Plan Before Edits

For an existing project, replace the standalone setup with the relevant functions, the code that calls them, nearby tests, and project conventions.

Your files may need different rules from the dog-walking example. This AI Skill uses your sample records and expected result to draft a small automation with tests, so you have something concrete to review.

Lead Magnet Cover
FREE AI SKILL

Free AI Automation Code Studio

Use AI to turn the file cleanup or reporting you keep doing by hand into code you can reuse.
Send My AI Automation Code Studio ❯
Instantly delivered to your inbox
Customer Avatar 1
Customer Avatar 2
Customer Avatar 3
Customer Avatar 4
Rated highly by 1,200+ users
Supply Relevant Context And Boundaries: Share Useful Context With Your Ai Coding Assistant; Relevant Code + Tests + Conventions; Use Synthetic Records; Remove Private Values; Local Editor ≠ Local Ai Processing; Check Data Handling Settings

Ask for an explanation before edits when you do not understand the flow:

Trace how a walk row reaches the weekly total. Identify the relevant files and functions, explain the flow, and make no edits.

Remove credentials and private records before sharing context, and check the provider’s data handling and retention settings. A local editor does not necessarily keep AI context local: VS Code documents that file contents and terminal output can be sent to models and tools.

Build and Understand One Small Change at a Time

Prepare a Recoverable Working Environment

First, confirm that Python runs a simple file. Save this as hello.py:

print("Python is working")

Run it with python3 hello.py, or py hello.py on Windows. Resolve setup errors before adding reporting logic. Otherwise, you may spend an evening debugging code that never started.

Create a separate project folder and add the synthetic CSV. Save a known-good version of your code with Git, which records changes you can restore, or keep a clearly named backup copy. Back up input data separately.

Prepare A Recoverable Working Environment: Set Up A Recoverable Python Coding Project; Python3 Hello.py; Python Is Working; Confirm Python Runs; Use A Separate Project Folder; Back Up Input Data Separately; Save A Known-Good Code Version

For an agent, restrict access to the project folder and the commands it needs. Permissions decide which actions are allowed, while a sandbox restricts shell access to files and networks at the operating-system level. Claude Code documents how these controls work together.

Keep execution approval enabled while learning. Check the configuration because some modes automatically allow commands. A sentence asking the agent to wait is useful, but it does not replace enforced controls.

Before approving a command, understand whether it runs your script, installs software, deletes files, or contacts an outside service. Our report needs no package installation and no network connection.

Review the Code Before Running It

After reviewing the plan, request one small change:

Implement CSV reading and validation only. Show the changed lines and explain how I can check this part. Do not add report writing yet.

Then add filtering and totals, and finish with output writing. Each stage should have a runnable check, even before the whole utility is complete.

Review The Code Before Running It: Review Ai Code One Small Change At A Time; 1. Read + Validate; 2. Filter + Total; 3. Write Report; Review → Check → Checkpoint; Keep Unrelated Edits Out

Ask for the changed files, a short explanation, and instructions for your operating system. Inspect the diff, which shows added and removed lines. Look for unrelated edits, new dependencies, and changes to file destinations.

I once asked AI to tidy a small reporting script and accepted a much larger rewrite than I needed. It changed the output format, so the next tool could no longer read the file. I restored the working version and made the cleanup separately. Now I name the behavior that must survive a cleanup request.

For the walk report, trace the November 8 row through the code:

  • Does the date become a date value?
  • Does the selected period include November 8?
  • Does 45 become a whole number?
  • Is it added to D001, rather than replacing the earlier 30?
  • Where does the report get written?
Review The Code Before Running It: Trace One Csv Row Through Your Python Report; D001 · Final Day · 45 Minutes; Parse Date + Whole Minutes; Include The Final Day; D001; 30; 30 + 45 = 75; Weekly_Totals.csv

Use AI to explain anything you cannot follow:

Explain this function’s inputs, outputs, decisions, and failure behavior. Walk through D001,2026-11-08,45 and show where each requirement is enforced.

You need enough understanding to predict the result. A dictionary holds totals under dog IDs, a loop visits rows, conditions select dates, and exceptions stop processing when input is invalid.

If you cannot explain the current change in your own words, reduce it. Save a working checkpoint after each verified stage.

Test Against Independently Calculated Results

Work out the answers before asking AI to write tests. Otherwise, the implementation and its tests can agree on the same mistake.

For our sample, count only walks from November 2 through November 8. D001 has 30 and 45 minutes, so its total is 75. D002 has 20 minutes. Together, the included walks total 95 minutes.

Use those figures as fixed expectations. Ask AI to write checks against them, rather than derive expected answers using the same logic as the report.

Keep an existing project’s test framework. For a new Python script, the standard-library unittest framework avoids another dependency.

Test Against Independently Calculated Results: Test Ai Code Against Independent Answers; 30 + 45 = 75; D001; 20; D002; 75 + 20 = 95 Minutes; Calculate Expected Results First; D001 = 75; D002 = 20; Compare After Execution; Pending Until Run; Do Not

Use a compact test record like this. The execution columns remain pending until you run the checks; they are not results from a tested implementation.

ScenarioSample InputExpected ResultActual ResultPass/Fail
Full selected weekThe five-row sample aboveD001 = 75; D002 = 20Not runPending
Last included dayD001,2026-11-08,45D001 = 45Not runPending
Invalid row outside the weekD001,2026-11-09,0Row error; existing report unchangedNot runPending
No matching walksOnly D001,2026-11-01,10Header-only reportNot runPending
Source used as destinationInput and output both point to walks.csvError; source unchangedNot runPending

Add checks for missing columns, blank IDs, impossible dates, fractional or negative durations, and missing files. Test both the first included date and dates just outside the period.

Failure tests matter as much as totals. For example, put a recognizable line in an existing report, run the script with invalid input, and confirm that line survives unchanged. Repeat with no existing report and confirm none is created. Check that the source file stays unchanged in both cases.

Once the files are ready, run:

python3 -m unittest -v
Test Against Independently Calculated Results: Test Csv Report Failures And File Protection; Invalid Outside-Week Row Still Fails; Keep This Line; Existing Report Survives; No Report Created On Failure; Reject Source As Destination; Expected

Then run the complete script:

python3 weekly_walks.py walks.csv --start 2026-11-02 --output weekly_totals.csv

Use py instead of python3 on Windows if that is how your installation starts Python. Read the test output and open weekly_totals.csv yourself. A message saying “report saved” proves very little about its contents.

AI review can provide another check, but investigate its findings before accepting changes. GitHub warns that Copilot review can miss problems and report problems that do not exist.

When you first use real records, compare the report with a manual calculation for the same period.

Debug With Evidence Instead of Repeated Guesses

When something fails, stop adding features. Find the smallest input that reproduces the problem.

Keep a short record of:

  • The exact command.
  • The smallest failing input.
  • The complete error message, if there is one.
  • The expected and actual results.
  • Relevant software versions.

Remove private values before sharing it. Then ask for a diagnosis and one check that could confirm it.

Debug With Evidence Instead Of Repeated Guesses: Give Your Ai Debugger Evidence, Not Guesses; Exact Command; Smallest Failing Input; Complete Error, If Present; No Error Message; Expected: D001,75; Actual: D001,30; Relevant Software Versions; Ask

Suppose the sample report shows D001 = 30 instead of 75. A useful request would be:

Command:
python3 weekly_walks.py walks.csv --start 2026-11-02 --output weekly_totals.csv

Smallest failing input:
dog_id,walk_date,minutes
D001,2026-11-02,30
D001,2026-11-08,45

Expected: D001,75
Actual: D001,30
No error message appeared.

Identify the likely cause and one check that would confirm it.
Inspect the parsed dates and reporting boundaries first.
Explain the evidence before proposing the smallest correction.
Do not rewrite unrelated code.

The missing November 8 walk suggests a date-boundary problem, but it does not prove one. Inspect the parsed date and the condition that selects rows.

If end_date is November 8, this comparison includes the final day:

start_date <= walk_date <= end_date
Debug With Evidence Instead Of Repeated Guesses: Debug A Missing Final Day In A Weekly Report; Expected: 75 Min; Actual: 30 Min; 45 Min; Inspect Parsed Date; Inspect Boundary Condition; Boundary Bug Is A Hypothesis; Start_Date &Lt;= Walk_Date &Lt;=

Changing aggregation code would not help if the row never reaches it.

Add a regression test, a check that reproduces this specific failure, before applying the fix. Then rerun that test and the existing checks.

If each correction creates another failure, return to the last working version and reassess the assumptions. For an unfamiliar function or API, check its official documentation. A fifth speculative patch is still a guess, just with more code attached.

Improve Working Code Without Losing Its Behavior

Once the report works, establish passing checks before changing its structure. Refactoring means reorganizing code while preserving its behavior.

Ask for one concrete improvement:

Extract weekly aggregation into a function without changing inputs, outputs, dependencies, or error behavior. Keep validation before report writing. Explain the diff and run the existing tests.

Improve Working Code Without Losing Its Behavior: Refactor Ai Code Without Changing Its Behavior; Working Script + Passing Checks; Extract Weekly Aggregation; D001: 75; D002: 20; Same Inputs, Outputs, Dependencies, Errors; Validation Before Writing

Review the change and rerun the same checks. I would skip performance work until you have measured a slow operation using representative input. A clear script that finishes comfortably within your available time does not need cleverness added as a hobby.

Ask AI to update the usage instructions with:

  • Required software and setup.
  • Input columns and accepted values.
  • Run and test commands.
  • Output location.
  • What happens on invalid input or other errors.

Follow those instructions yourself from a fresh project copy. Missing setup steps become obvious when you stop relying on your memory.

Improve Working Code Without Losing Its Behavior: Verify Your Python Report Before Scheduling It; Follow Instructions From A Fresh Copy; Save Code, Tests, Instructions, Rules; Run Manually On Representative Records; Plan Errors, Stopping, And

Save the reviewed code, tests, and instructions together. Record the project rules for future AI sessions: standard library only, input files protected, seven inclusive dates, and no report changes after validation failure.

Run the utility manually on representative records before scheduling it. For unattended use, decide where errors will appear, how you will stop the job, and how you will restore the working version.

If you already use n8n to connect business tools, it can sit around a tested utility later. I would get the report right first. Scheduling incorrect totals simply makes them arrive more reliably.

What Next?

Choose one recurring spreadsheet task and write down its input, expected output, and one result you can calculate by hand. Use those notes to request a plan before requesting code.

Use the social buttons to share this workflow when you want to make checking AI-generated code part of the conversation about building faster.

Which small task would you trust yourself to verify first, and what would make you confident enough to use the result? Leave your answer, along with any other questions, in the comments.

Share this post with your friends & followers:
Abhishek is a data scientist by day & an online entrepreneur by night. He is known for his ability to simplify complex concepts and make them accessible to a wider audience. He started Passive Book to share his insights and experiences on how to effectively build an online business, which has quickly become a go-to resource for anyone looking to bootstrap an online business from scratch.

Leave a Comment

Build an Online Business 
Without Quitting Your Job

Join 10,000+ solopreneurs building six-figure online businesses from scratch with limited time & tight budgets using smart systems & AI automations.
Optin Form - Main

Free Bonus: Get access to our AI workflows & cheat sheets
Person sitting with laptop in home office environment with launching rocket, coffee mug, sleeping dog, bookshelf, and house plant illustrating work-from-home online business lifestyle. Decorative image.
Thank you for sharing

Follow Us On: