Give ChatGPT Your Stack and Conventions Up Front
What it is
A prompting habit: before asking for code, state your language, framework and versions, plus the conventions the code must follow — so what comes back fits your project instead of a generic template.
Why it works
Without a stack, ChatGPT picks defaults: the latest syntax, popular libraries, its own naming. That code compiles but clashes with your project, and you spend the saved time reconciling style. Front-loading the stack and rules makes the first output paste-ready far more often.
When to use it
Any code that has to live in an existing codebase with established patterns — a component in your design system, an endpoint matching your API style, a query in your ORM.
When not to use it
Throwaway scripts or standalone snippets where fit doesn't matter, and quick 'how do I do X' syntax questions where conventions are irrelevant.
Prompt
Stack: <language + version>, <framework + version>, <key libraries>.
Conventions: <naming, error handling, patterns to follow or avoid>.
Task: <what the code should do>.
Match the conventions exactly; if something's ambiguous, ask before assuming.Example
'Stack: TypeScript 5, React 18, TanStack Query; conventions: no default exports, errors via Result type' — the generated hook fits the codebase with no reformatting.
Advanced version
Paste one representative file from your codebase as a style exemplar and say 'match this file's structure and naming' — the model mirrors your patterns better than any written rule list.
Common mistakes
- Omitting versions and getting syntax your toolchain rejects.
- Not naming your libraries, so it reinvents what you already use.
- Describing conventions vaguely ('clean code') instead of concretely.