Prompt
How do I speed up boilerplate coding without making the code worse?
Latest observation
To speed up boilerplate coding without making the code worse, aim to reduce repetitive work while keeping the codebase consistent, readable, and easy to change.
1) Standardize the common patterns
Create a few blessed patterns for things you repeat often:
- file structure
- naming conventions
- error handling
- logging
- request/response shapes
- test layout
When everyone uses the same pattern, you can write faster and review faster.
2) Use templates and generators
For repetitive files, use:
- code snippets
- scaffolding scripts
- CLI generators
- project templates
Good use cases:
- controllers/routes
- data models
- CRUD endpoints
- test files
- config files
This reduces typing while keeping output predictable.
3) Prefer small abstractions over copy-paste
If you notice the same logic repeated 3+ times, extract it into:
- a helper
- a base class
- a shared function
- a reusable component
But keep abstractions simple. If the abstraction is harder to understand than the repetition, don’t do it yet.
4) Automate formatting and linting
Use tools like:
- formatter
- linter
- import sorter
- type checker
- pre-commit hooks
This removes time spent on style decisions and catches mistakes early, so you can move faster with less mental overhead.
5) Use editor features aggressively
A good editor setup can save a lot of time:
- snippets
- multi-cursor editing
- auto-imports
- rename symbol
- jump to definition
- code actions
- refactoring tools
Learn the 10–15 shortcuts you use most often.
6) Reduce context switching
Boilerplate gets slower when you keep re-deciding things. Make decisions once:
- preferred libraries
- standard folder layout
- default test framework
- default error handling style
The fewer choices you make per file, the faster you go.
7) Write “boring” code on purpose
For boilerplate, optimize for:
- clarity
- consistency
- predictable structure
- easy review
Avoid cleverness. Boilerplate is where “simple and standard” beats “smart and compact.”
8) Keep examples close by
Maintain:
- reference implementations
- a starter repo
- a “golden” example for each common pattern
Then you can copy the shape, not the logic.
9) Use tests as guardrails
If boilerplate is easy to generate but easy to break, add:
- template tests
- integration tests for generated code
- shared test helpers
This lets you speed up generation without fear.
10) Measure where time goes
If boilerplate is still painful, identify the actual bottleneck:
- typing?
- searching docs?
- deciding on structure?
- debugging generated code?
- waiting on builds?
Then fix the right problem instead of generalizing everything.
A good rule of thumb
If a task is:
- repeated often,
- mostly mechanical,
- and has a stable pattern,
then automate it.
If it changes often or needs judgment, keep it explicit.
Practical strategy
A strong workflow is:
- write the pattern once manually
- refine it until it’s stable
- turn it into a snippet/template/generator
- enforce it with linting/tests
- reuse it everywhere
That way speed comes from repetition and automation, not from cutting corners.
If you want, I can also give you:
- a boilerplate-killing checklist
- a good folder/template setup
- or examples for a specific language/framework