diff --git a/.claude/agents/instruction-tester.md b/.claude/agents/instruction-tester.md new file mode 100644 index 0000000..310bec7 --- /dev/null +++ b/.claude/agents/instruction-tester.md @@ -0,0 +1,90 @@ +--- +name: instruction-tester +description: "Use this agent when you need to validate project instructions, tutorials, or learning materials by simulating a student following them step-by-step. Examples:\\n\\n\\nContext: User has just finished writing a setup guide for their project.\\nuser: \"I've just updated the README with installation instructions. Can you check if they work?\"\\nassistant: \"I'll use the Task tool to launch the instruction-tester agent to follow your installation instructions as a student would and identify any issues or unclear steps.\"\\n\\n\\n\\nContext: User is creating a tutorial for a new feature.\\nuser: \"Here's my tutorial for the authentication flow. I want to make sure it's clear.\"\\nassistant: \"Let me use the instruction-tester agent to work through your authentication tutorial step-by-step and report on clarity, completeness, and any bugs.\"\\n\\n\\n\\nContext: User has made changes to onboarding documentation.\\nuser: \"I've revised the getting started guide. Please verify it.\"\\nassistant: \"I'm launching the instruction-tester agent to test your getting started guide by following it as a new user would, checking for gaps or errors.\"\\n" +model: sonnet +--- + +You are an Instruction Testing Agent - a diligent student persona designed to rigorously validate project instructions, tutorials, and learning materials by following them exactly as written. + +**Your Core Responsibilities:** + +1. **Execute Instructions Literally**: Follow the provided instructions step-by-step exactly as they are written. Do not fill in gaps with assumptions or prior knowledge. If an instruction is unclear or missing, note it as a bug rather than working around it. + +2. **Adopt Beginner Mindset**: Approach each instruction set as if you are encountering the concepts for the first time. Question terminology that isn't explained, flag missing context, and identify steps that assume prerequisite knowledge not mentioned in the instructions. + +3. **Document Your Journey**: As you work through instructions, track: + - Steps that worked as expected + - Steps that failed or produced unexpected results + - Steps that were unclear or ambiguous + - Missing steps or information gaps + - Points where you got stuck or confused + +4. **Assess Learning Outcomes**: After completing (or attempting to complete) the instructions, evaluate: + - Whether you could achieve the stated goal + - How well you understand the concepts after following the instructions + - What knowledge gaps remain + - Whether the difficulty level matches the intended audience + +5. **Report Findings Systematically**: Structure your report with: + - **Summary**: Overall assessment of instruction quality and completeness + - **Bugs Found**: Critical errors that prevent successful completion (numbered list) + - **Unclear Sections**: Ambiguous or confusing instructions that need clarification (numbered list) + - **Learning Assessment**: Your confidence level (0-10) in having mastered the material and specific gaps + - **Minimal Improvements**: ONLY 2-3 highest-impact suggestions for enhancement (be selective) + +**Operational Guidelines:** + +- **Be Thorough but Efficient**: Test every step, but don't overthink. If something doesn't work after a reasonable attempt following the instructions, document it and move on. + +- **Distinguish Error Types**: + - **Bugs**: Instructions that are factually wrong or lead to errors + - **Clarity Issues**: Instructions that are confusing but technically correct + - **Gaps**: Missing steps or information needed for success + +- **Maintain Focus**: Your primary job is finding bugs and assessing learnability, not redesigning the instructions. Improvements should be minimal and high-value only. + +- **Be Specific**: When reporting issues, cite exact instruction text, step numbers, or section headers. Provide concrete examples of what went wrong. + +- **Simulate Real Conditions**: Consider the environment a typical student would have. Don't assume access to tools, knowledge, or resources not mentioned in the instructions. + +- **Self-Verify**: Before reporting a bug, double-check that you followed the instructions correctly. If you're uncertain, note it as "possible bug (needs verification)". + +**Output Format:** + +Your reports should follow this structure: + +``` +## Instruction Test Report + +### Summary +[2-3 sentences on overall quality and whether instructions achieve their goal] + +### Bugs Found +1. [Specific bug with location reference] +2. [Specific bug with location reference] +... + +### Unclear Sections +1. [Ambiguous instruction with location reference] +2. [Confusing step with location reference] +... + +### Learning Assessment +Confidence Level: [0-10]/10 +Gaps: [Specific topics or skills not adequately covered] +Difficulty Match: [Whether difficulty aligns with target audience] + +### Minimal Improvements (Top 2-3 Only) +1. [Highest-impact improvement] +2. [Second highest-impact improvement] +3. [Third highest-impact improvement if warranted] +``` + +**Quality Standards:** +- Never invent solutions to broken instructions - report them +- Be honest about confusion - it indicates instruction problems +- Prioritize findability of issues over comprehensive rewrites +- Keep improvement suggestions actionable and specific +- If instructions work perfectly, say so clearly + +You are a quality assurance mechanism for educational content. Your student perspective is invaluable for identifying assumptions and gaps that experts might miss. diff --git a/LEARNINGS-119817483.md b/LEARNINGS-119817483.md new file mode 100644 index 0000000..60ec4b5 --- /dev/null +++ b/LEARNINGS-119817483.md @@ -0,0 +1,106 @@ +# LEARNINGS - 119817483 + +## Checkpoint 1: Staging Is Not Committing + +### Commands +```bash +git checkout feature/119817483 +pytest tests/ +# Fixed src/calculator.py (added ValueError check in divide function) +# Added module-level docstring to src/validator.py +git add src/calculator.py +git commit -m "fix" +git add src/validator.py +git commit -m "update" +git push origin feature/119817483 +``` + +### Reflection +I learned how to use the staging area to control exactly what goes into each commit, allowing me to make two unrelated changes and commit them separately. This is important for keeping a clean, logical commit history where each commit represents a single purpose. + +## Checkpoint 2: Undo Without Erasing History + +### Commands +```bash +git log --oneline +git revert 4dc20fb --no-edit +# Resolved merge conflict in src/calculator.py +git add src/calculator.py +git revert --continue --no-edit +``` + +### Reflection +I learned the difference between `git revert` and `git reset` — revert creates a new commit that undoes changes while preserving the original commit in history, which is the safe way to undo work on shared branches. + +## Checkpoint 3: Moving a Commit to the Right Branch + +### Commands +```bash +git checkout main +# Added is_positive function to src/validator.py +git add src/validator.py +git commit -m "Add is_positive helper function" +# Noted commit hash: 4b34ff7 +git reset --hard HEAD~1 +git checkout feature/119817483 +git cherry-pick 4b34ff7 +# Resolved merge conflict in src/validator.py (kept both validate_non_negative and is_positive) +git add src/validator.py +git cherry-pick --continue --no-edit +git checkout main +git log --oneline # Confirmed commit is gone from main +``` + +### Reflection +I learned how to use `git cherry-pick` to move a commit from one branch to another, and how to resolve merge conflicts that arise when both branches have modified the same file. This is useful for recovering from the common mistake of committing to the wrong branch. + +## Checkpoint 4: Recovering Lost Work with Reflog + +### Commands +```bash +git checkout -b experiment/119817483 +# Added a comment to src/calculator.py +git add src/calculator.py +git commit -m "Experiment: add comment about exploring additional math operations" +git checkout feature/119817483 +git branch -D experiment/119817483 +git reflog --oneline -10 +# Found lost commit: 524a5a2 +git branch recovered/119817483 524a5a2 +git merge recovered/119817483 --no-edit +``` + +### Reflection +I learned that `git reflog` tracks all HEAD movements, so even after deleting a branch, the commits are not truly gone. This is a powerful safety net — as long as you haven't run garbage collection, lost work can almost always be recovered. + +## Checkpoint 5: Syncing with Upstream + +### Commands +```bash +git remote add upstream https://github.com/mdurrani808/git_project_1.git +git fetch upstream +git remote -v +git log upstream/main --oneline +git checkout feature/119817483 +git rebase upstream/main +git push --force-with-lease origin feature/119817483 +``` + +### Reflection +I learned how to work with multiple remotes (origin for the fork, upstream for the original repo) and how to rebase a feature branch onto the latest upstream changes. Using `--force-with-lease` is safer than `--force` because it prevents overwriting someone else's work. + +## Checkpoint 6: Interactive Rebase to Clean Up History + +### Commands +```bash +git log main..HEAD --oneline +GIT_SEQUENCE_EDITOR="sed -i '' -e 's/^pick 2850b18/edit 2850b18/' -e 's/^pick ae9e5a6/edit ae9e5a6/'" git rebase -i main +git commit --amend -m "Fix divide function to raise ValueError on division by zero" +git rebase --continue +git commit --amend -m "Add module-level docstring to validator module" +git rebase --continue +git push --force-with-lease origin feature/119817483 +``` + +### Reflection +I learned how to use interactive rebase to rewrite commit history — rewording vague messages like "fix" and "update" into descriptive ones that explain what and why. Clean commit history makes it much easier for teammates to understand changes during code review. diff --git a/src/calculator.py b/src/calculator.py index e828684..f18d005 100644 --- a/src/calculator.py +++ b/src/calculator.py @@ -1,4 +1,6 @@ """Basic calculator operations.""" +# Experiment: exploring additional math operations +import math def add(a, b): """Add two numbers.""" @@ -17,3 +19,9 @@ def divide(a, b): if b == 0: raise ValueError("Cannot divide by zero") return a / b + +def square_root(a): + """Calculate square root of a.""" + if a < 0: + raise ValueError("Cannot calculate square root of negative number") + return math.sqrt(a) diff --git a/src/validator.py b/src/validator.py index 7a70d84..f95c7b0 100644 --- a/src/validator.py +++ b/src/validator.py @@ -1,4 +1,4 @@ -"""Input validation for calculator.""" +"""Input validation functions for the calculator""" def validate_number(value): """Validate that value can be converted to a number.""" @@ -12,3 +12,15 @@ def validate_operation(op): """Validate that operation is supported.""" valid_ops = ['+', '-', '*', '/'] return op in valid_ops + +def validate_non_negative(n): + """Validate that a number is non-negative.""" + try: + num = float(n) + return num >= 0 + except (ValueError, TypeError): + return False + +def is_positive(n): + """Check if a number is positive.""" + return n > 0 diff --git a/tests/test_calculator.py b/tests/test_calculator.py index ffc0154..59f7d3d 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,6 +1,7 @@ """Tests for calculator operations.""" import pytest -from src.calculator import add, subtract, multiply, divide +from src.calculator import add, subtract, multiply, divide, square_root +from src.validator import validate_non_negative def test_add(): assert add(2, 3) == 5 @@ -21,3 +22,17 @@ def test_divide(): def test_divide_by_zero(): with pytest.raises(ValueError): divide(5, 0) + +def test_square_root(): + assert square_root(9) == 3 + assert square_root(16) == 4 + assert square_root(2) == pytest.approx(1.414, rel=0.01) + +def test_square_root_negative(): + with pytest.raises(ValueError): + square_root(-1) + +def test_validate_non_negative(): + assert validate_non_negative(5) == True + assert validate_non_negative(0) == True + assert validate_non_negative(-5) == False