Coding
Continuous code simplification
Find overly complex functions each night and propose simpler rewrites for human review.
[ workflow / coding ]
Continuous code simplification
Complexity grows one condition at a time. Each night, Cosmos scores recently changed files for cognitive complexity, rewrites functions over the threshold with established simplification patterns, and opens a draft PR. A human reviewer adjusts or approves before merge so intent stays intact.
07 nodes
05 edges
Cron: 03:00 UTC
Files changed in last 30 days
Decision
Score > threshold?
All files within threshold
Decision
Score > threshold?
All files within threshold
Guard clauses · extraction · decomposition
Verify behavior unchanged
Side-by-side score comparison
Workflow prompt
Paste this into Augment to reproduce the workflow end-to-end.
Cosmos, each night identify all functions modified in the past 30 days whose cognitive complexity score exceeds 15. For each, attempt a simplification rewrite using patterns such as early-return guard clauses, extracted helper functions, and loop decomposition. Verify behavior is unchanged by running the existing test suite against the rewrite. Open a draft PR per file with a side-by-side complexity score comparison and an explanation of each transformation applied. Do not merge automatically: flag for human review.