- Lab
-
Libraries: If you want this lab, consider one of these libraries.
AI Ready: Advanced AI-assisted Development Lab
You will use Claude Code to assist in development of a shopping codebase to enable coupon functionality.
Lab Info
Table of Contents
-
Challenge
Research before writing
Research context and constraints
Paste the following prompt. Keep the same Claude session for later steps. Use Claude Code's permission prompts to reject edits during research.
Read only `README.md`, `AGENT_RULES.md`, `src/cart.py`, and `tests/test_cart.py`. Do not modify files or run shell commands. Research the current cart behavior and propose **two** implementation approaches for `SAVE10`. Explain trade-offs, invalid-code behavior, discount stacking, rounding, and regression risks. Recommend one option with a file-by-file plan. Stop and wait for my approval before any edit.Note: If desired, you could specify a save location for Claude's research to reference later in the lab.
-
Challenge
AI review and plan correction
In the same Claude session, paste in the following prompt:
Act as a requirements reviewer. Recheck your proposed plan against `README.md` and `AGENT_RULES.md`. Explicitly address whether `SAVE10` may stack with silver/gold tiers, unknown coupons, rounding, and backwards compatibility. List unsupported assumptions. Revise the plan **without editing files**. End with a numbered implementation checklist and wait for my approval.AI review can easily suffer from preexisting bias and foundational flaws, therefore it's important to check the plan against the project requirements. Request revisions if necessary until satisfied with the results.
-
Challenge
Single-agent role chaining
Using a single agent, you will chain together the implement → validate → correction (if needed) workflow into a single session.
The same Claude agent now receives the approved plan as its input. This is sequential role chaining, and is not using separate agents or having independent reviewers.
Ask Claude to work only on the allowed files. Continue to enter the following prompts in the same Claude session.
Implementation prompt:
IMPLEMENTER ROLE. Follow the plan I approved. Add optional `coupon_code=None` support to `total()` in `src/cart.py`. `SAVE10` is valid only for `regular`; it cannot stack with silver or gold. Unknown coupon codes must raise `ValueError`. Preserve existing behavior and use `Decimal` with `ROUND_HALF_UP`. Add focused tests in `tests/test_cart.py`. Edit **only** these two files. Before each proposed edit, explain what you will change and ask me to approve it through the CLI permission prompt. Do not modify any other files. When done, summarize your changes and stop.Review Claude Code's permission requests before accepting writes. If the agent requests an unrelated command or file change, deny it. Do not enable bypass-permissions mode.
Validation prompt:
VALIDATOR ROLE. Inspect the actual diff and the two changed files against `README.md` and `AGENT_RULES.md`. Run `python -m pytest -q tests` if I approve the command. Report defects, missed cases, unsupported assumptions, and any deviations from the plan. Do not edit files. Present a severity-ranked findings list.Correction prompt:
CORRECTOR ROLE. Use the validator findings and the independent test results I will provide. Propose the smallest fixes, explain each change, and request permission before editing. Touch only `src/cart.py` and `tests/test_cart.py`. Re-run the tests only with my approval.An AI agent may overlook defects in its own implementation or generate tests based on incorrect assumptions. Independent testing provides an additional layer of validation.The tests within artifacts check requirements beyond the starter tests. Run them after Claude implements the feature:
- Open a second Terminal: click the + beside the existing Terminal tab > New tab > Terminal.
- In the second Terminal at the bash prompt (
$) runcd artifacts, then runpython3 -m pytest test_loyalty.py test_coupons.py test_currency.py -v - Paste failures from the tests into the Claude prompt (in the first Terminal).
- You'll at this point need to allow Claude access to the
artifactsdirectory, including perhaps creating some new test files. Do so, although keep any changes minimal. - Repeat until all tests pass.
- You'll at this point need to allow Claude access to the
-
Challenge
Recover from incorrect context and convention records
Then correct the conversation explicitly:
The stacking claim was incorrect. Treat `README.md` and `AGENT_RULES.md` as authoritative. Restate the correct rule. Explain how you would avoid repeating the mistake when context is compacted or the session is resumed.To persist team guidance for future Claude Code sessions, use the CLI to create or update
CLAUDE.mdin the project root after reviewing the content. This file is a Claude Code project-memory convention; the existingAGENT_RULES.mdis a lab requirements document. Ask Claude to summarize the stable conventions intoCLAUDE.md, with your approval, rather than relying on chat history alone.Draft a short `CLAUDE.md` using verified conventions from `AGENT_RULES.md`. Include currency rounding, no discount stacking, allowed edit scope, and human approval requirements. Show me the proposed text first; wait for approval before writing it.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.