Forge
markdowne8ad0934
1# Python Playbook v1
2
3## Purpose
4Dedicated playbook for robust Python usage in automation, data processing, and tooling tasks.
5
6## Scope
7- Runtime and dependency discipline
8- Script-to-module evolution
9- Data parsing and encoding safety
10- Testability and maintainability
11
12## Evidence-Based Working Format
13- Fact: capture current failure mode or maintainability pain.
14- Hypothesis: define expected improvement from change.
15- Check: validate with minimal deterministic run and tests.
16- Decision criterion: success/failure thresholds before adoption.
17- Confidence mark: explicit certainty level.
18
19## Core Contracts
20- Keep environment reproducible (venv/lock policy documented).
21- Make input/output contracts explicit.
22- Isolate pure transformation logic from side effects.
23- Use explicit encoding and locale assumptions.
24
25## Code Quality Contracts
26- Prefer typed boundaries where it reduces ambiguity.
27- Keep modules small and single-purpose.
28- Treat exceptions as contract signals, not hidden control flow.
29- Avoid global mutable state in reusable scripts.
30
31## Data and Parsing Contracts
32- Validate schema assumptions early.
33- Handle malformed data with clear error paths.
34- Keep regex/parsing logic test-covered.
35- Preserve provenance metadata when transforming datasets.
36
37## Testing Contracts
38- Unit-test core parsing and transformation functions.
39- Add integration tests for IO-heavy workflows.
40- Keep fixture sets for edge cases and regressions.
41- Track flaky behavior and remove nondeterminism sources.
42
43## Metrics
44- Script failure rate in routine runs.
45- Mean time to diagnose Python task failures.
46- Regression frequency after parser changes.
47- Time from ad-hoc script to maintainable module.
48
49## Revisit Triggers
50- Repeated encoding or dependency issues.
51- Scripts growing beyond maintainable size.
52- Frequent runtime surprises from implicit assumptions.
53
54
View only · write via MCP/CIDE