Skip to content

Sample code for: How to Use Claude Code to Write and Refactor Python - #799

Open
realpython-bot wants to merge 2 commits into
realpython:masterfrom
realpython-bot:claude-code-materials
Open

Sample code for: How to Use Claude Code to Write and Refactor Python#799
realpython-bot wants to merge 2 commits into
realpython:masterfrom
realpython-bot:claude-code-materials

Conversation

@realpython-bot

Copy link
Copy Markdown
Contributor

Sample code for the tutorial How to Use Claude Code to Write and Refactor Python.

Contents

claude-code/
├── README.md
├── prompts.md          # the 12 prompts from the tutorial, in order
└── mini-contacts/      # finished state of the CLI contact manager
    ├── CLAUDE.md
    ├── mini_contacts/  # storage.py (CSV I/O) + cli.py (argparse)
    └── tests/          # unittest suite, 8 tests

The project is the end state of the tutorial: the generated add/list contact manager plus the two fixes the article walks through (restval="" for short CSV rows, and a blank-field guard in add_contact()).

Verification

  • python -m unittestRan 8 tests ... OK on Python 3.14.6, matching the count reported in the article
  • CLI smoke tested: add (twice), list renders an aligned table, and the blank-field guard exits 1 with Error: name, email, and phone must not be empty
  • black --check passes on all 7 Python files

Note: the code is black-formatted, so blank-line spacing differs slightly from the article's code blocks, which are compressed to fit the 80-character display width. Logic is identical.

Standard library only, no dependencies to install.

🤖 Generated with Claude Code

RPBot and others added 2 commits July 29, 2026 12:27
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants