Prompt
Choose descriptive, domain-specific names that clearly communicate intent and prevent confusion. Avoid generic names when more specific alternatives exist, especially when working alongside similar types or concepts from external libraries.
Key principles:
- Prefix with domain/library name when extending or wrapping external types (e.g.,
StagehandPageinstead ofPageto distinguish from Playwright’sPage) - Use semantically clear parameter names (e.g.,
systemPromptinstead ofinstructions) - Create custom types with descriptive names (e.g.,
StagehandContainerforHTMLElement | Window) - Add suffixes like
Schemato distinguish type definitions from runtime values
Example:
// Avoid generic names that could cause confusion
export interface Page extends PlaywrightPage { ... }
// Use descriptive, domain-specific names
export interface StagehandPage extends PlaywrightPage { ... }
// Avoid ambiguous parameter names
function configure(instructions?: string) { ... }
// Use semantically clear names
function configure(systemPrompt?: string) { ... }
This approach makes code self-documenting and reduces cognitive load when working with multiple similar concepts or external dependencies.