Training Course Module 2: CLAUDE.md Day 8
Day 8

Writing Effective Instructions

Master the art of writing rules that Claude follows consistently — the difference between helpful and frustrating.

0 / 8 tasks

Be specific and imperative

Vague instructions produce vague behavior. 'Write good code' does nothing. 'Always add type hints to function parameters and return values' is actionable. Write instructions as direct commands, not preferences.

Patterns that work

markdown
## Rules

### Always
- Use `pathlib.Path` instead of `os.path`
- Prefer list comprehensions over `map()` and `filter()`
- Add `# type: ignore` comments with a reason when suppressing mypy errors
- Use `httpx` not `requests` for HTTP calls (async support)

### Never
- Add `# TODO` or `# FIXME` comments — open a GitHub issue instead
- Use `except Exception` — catch specific exceptions
- Import from `typing` when `collections.abc` has the same type (Python 3.12+)
- Write `if x == True` — write `if x:`

### Error Handling
- Raise custom exceptions from `app/exceptions.py`
- Always log exceptions before re-raising with `logger.exception()`
- HTTP endpoints return RFC 7807 problem detail objects on error
💡 Test every rule. Write the rule, then explicitly ask Claude to write code that would normally violate it. If it still violates it, reword the rule to be more specific.

Practice Tasks

0 / 8
← Day 7: What is CLAUDE.md? ↑ Module overview Day 9: Project Context Documentation →