Prompt Best Practices
Get the most out of Nexus Prompts with these proven patterns and recommendations.
Organizing Your Prompts
Create a Prompt Hierarchy
Build prompts that progressively specialize:
Level 0: Base Prompts
├── typescript-fundamentals
├── testing-fundamentals
└── devops-fundamentals
Level 1: Technology Stacks
├── react-typescript (extends typescript-fundamentals)
├── node-typescript (extends typescript-fundamentals)
└── fullstack-typescript (extends both)
Level 2: Project-Specific
├── my-saas-frontend (extends react-typescript)
└── my-saas-backend (extends node-typescript)One Prompt Per Concern
Rather than one large prompt, use multiple focused prompts:
# Multiple active prompts for a testing session
nexus prompt activate react-typescript-expert
nexus prompt activate testing-qa-engineer
# Prompts are merged: React knowledge + Testing expertisePriority Ordering
When multiple prompts are active, earlier prompts take precedence for conflicts:
# Priority 1 (highest)
nexus prompt activate react-typescript-expert --priority 1
# Priority 2
nexus prompt activate testing-qa-engineer --priority 2Writing Effective System Prompts
Be Specific About Constraints
Instead of:
Be careful with security.Write:
Security Requirements:
- Always sanitize user inputs before database queries
- Use parameterized queries, never string concatenation
- Validate file uploads: check MIME types, limit size to 5MB
- Hash passwords with bcrypt (cost factor 12+)Include Anti-Patterns
Tell the AI what NOT to do:
## Avoid These Patterns
- Never use `any` type; use `unknown` with type guards
- Don't use `var`; prefer `const`, then `let`
- Avoid default exports; use named exports
- Don't mutate state directly; use immutable patternsProvide Context
Explain WHY, not just WHAT:
## Why These Choices
We use Zustand instead of Redux because:
- Smaller bundle size for our performance requirements
- Simpler API for our team's experience level
- Better TypeScript inference
This context helps you make consistent recommendations.Leveraging Prompt Inheritance
Create Reusable Base Prompts
# Base: typescript-strict
System Prompt:
- Use TypeScript strict mode conventions
- Explicit return types for all exported functions
- No implicit any
- Prefer interfaces over type aliases for objectsOverride Only What Changes
Child prompts should add, not repeat:
# Child: react-typescript (extends typescript-strict)
System Prompt:
# React-Specific Additions
- Use functional components with hooks
- Prefer composition over inheritance
- (TypeScript rules are inherited automatically)Document Inheritance
Add comments explaining the chain:
# Prompt: react-testing
# Extends: react-typescript -> typescript-strict
# Purpose: React component testing with VitestManaging Prompt Preferences
Match Team Conventions
Align preferences with your team's style guide:
{
"verbosity": "balanced",
"codeStyle": "documented",
"responseFormat": "full"
}Project-Specific Preferences
Different projects may need different settings:
| Project | Verbosity | Code Style |
|---|---|---|
| Greenfield | Detailed | Documented |
| Maintenance | Concise | Minimal |
| Documentation | Detailed | Verbose |
Auto-Activation Patterns
Project Configuration
Create .nexus/config.json in your project root:
{
"defaultPrompt": "my-project-prompt",
"autoActivate": true
}Monorepo Setup
For monorepos, configure per-package:
my-monorepo/
├── .nexus/config.json # Base config
├── packages/
│ ├── frontend/
│ │ └── .nexus/config.json # Frontend-specific prompt
│ └── backend/
│ └── .nexus/config.json # Backend-specific promptMemory Integration
Prompt-Specific Learning
When saving memories, associate them with prompts:
// Memory is automatically tagged with active prompts
save -
memory({
title: "React Query caching pattern",
content: "...",
// promptId is automatically added based on active prompts
});Recall by Prompt
Query memories in prompt context:
recall -
memories({
query: "caching patterns",
// Automatically prioritizes memories from active prompts
});Performance Tips
Limit Active Prompts
Each active prompt adds to context size. Aim for 2-3 active prompts maximum.
Use Focused Libraries
Include only necessary documentation:
Good: react, react-query, zod
Bad: react, vue, angular, svelte, solid... (everything)Streamline System Prompts
Keep prompts under 2000 tokens for optimal performance.
Troubleshooting Prompts
Unexpected Behavior
- Check active prompts:
nexus prompt active - Review merged configuration
- Verify priority order
- Check for conflicting instructions
Prompt Not Taking Effect
- Ensure prompt is activated
- Check inheritance chain
- Verify you're authenticated
- Try deactivating/reactivating
Context Overload
If responses seem unfocused:
- Reduce number of active prompts
- Trim system prompts
- Remove unnecessary libraries
- Use more specific prompts
Common Patterns
The "Project Onboarding" Prompt
# System Prompt
When starting work on this project:
1. Read README.md for project overview
2. Check package.json for dependencies
3. Review .nexus/config.json for project conventions
4. Look for existing patterns in src/ before creating new ones
Key conventions:
- [Project-specific rules here]The "Code Review" Prompt
# System Prompt
When reviewing code:
1. Check for type safety issues
2. Verify error handling
3. Look for performance concerns
4. Ensure accessibility compliance
5. Validate test coverage
Output format:
- List issues by severity (Critical > High > Medium > Low)
- Include line numbers
- Provide fix suggestionsThe "Documentation" Prompt
# System Prompt
When writing documentation:
1. Start with a one-line summary
2. Include usage examples
3. Document all parameters
4. Add error scenarios
5. Include related functions/components
Style:
- Use present tense
- Be concise but complete
- Include TypeScript types in examplesNext Steps
- Prompt CLI Commands - Full CLI reference
- MCP Tools - Programmatic prompt management
- Creating Prompts - Build custom prompts