> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zerotwo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt Engineering Overview

> Learn how to craft effective prompts to get the best results from ZeroTwo's AI models

Prompt engineering is the art and science of crafting effective instructions for AI models. In ZeroTwo, well-designed prompts help you achieve more accurate, relevant, and useful responses across all supported models.

## What is prompt engineering?

Prompt engineering involves structuring your requests to AI models in ways that optimize their responses. Rather than treating the AI as a search engine, effective prompting treats it as a collaborative partner that needs clear context, goals, and constraints.

<Tip>
  The quality of AI responses directly correlates with the quality of your prompts. Investing time in prompt engineering pays dividends in productivity and output quality.
</Tip>

## Core principles of effective prompts

### Be specific and clear

Vague prompts lead to vague responses. Provide concrete details about what you need.

<CodeGroup>
  ```text Poor prompt theme={null}
  Write code for a website.
  ```

  ```text Better prompt theme={null}
  Create a React component for a responsive navigation bar with a logo on the left, menu items in the center, and a "Sign In" button on the right. Use Tailwind CSS for styling and include mobile hamburger menu functionality.
  ```
</CodeGroup>

### Provide context

Help the AI understand the broader situation and constraints.

```text Example with context theme={null}
I'm building a SaaS application for project management. I need to design a database schema for tracking tasks, projects, team members, and their assignments. The system should support multiple workspaces per user and role-based permissions. Can you suggest a PostgreSQL schema?
```

### Specify the desired format

Tell the AI how you want the response structured.

<Tabs>
  <Tab title="Code output">
    ```text theme={null}
    Generate a Python function that validates email addresses. Return only the function code with docstring comments.
    ```
  </Tab>

  <Tab title="Step-by-step">
    ```text theme={null}
    Explain how OAuth 2.0 works. Provide a numbered step-by-step breakdown suitable for a beginner developer.
    ```
  </Tab>

  <Tab title="Comparative">
    ```text theme={null}
    Compare PostgreSQL and MongoDB for a social media application. Present your analysis in a table with columns for Feature, PostgreSQL, MongoDB, and Recommendation.
    ```
  </Tab>
</Tabs>

### Set the appropriate tone

Indicate the expertise level and style you need.

```text theme={null}
Explain async/await in JavaScript as if I'm a junior developer who just learned callbacks. Use simple analogies and provide code examples with detailed comments.
```

## Prompt components in ZeroTwo

ZeroTwo constructs the full prompt sent to AI models by combining several elements:

<Steps>
  <Step title="System prompt">
    The base instructions that define the AI's behavior, capabilities, and constraints. This is set automatically but can be customized through [custom instructions](/chat/custom-instructions) or [assistants](/assistants/overview).
  </Step>

  <Step title="Custom instructions">
    Your personal or project-level instructions that persist across conversations. These augment the system prompt with your preferences.
  </Step>

  <Step title="Conversation history">
    Recent messages that provide context for continuing the conversation coherently.
  </Step>

  <Step title="Your current message">
    The specific request or question you're asking right now.
  </Step>

  <Step title="Tool and file context">
    Additional context from attached files, images, or enabled tools like web search or code interpreter.
  </Step>
</Steps>

## Prompt strategies by task type

### For code generation

<AccordionGroup>
  <Accordion title="Specify language and framework">
    Always mention the programming language, framework versions, and any relevant libraries.

    ```text theme={null}
    Create a Next.js 14 server action using TypeScript that handles user registration. Use Zod for validation and return properly typed responses.
    ```
  </Accordion>

  <Accordion title="Include error handling requirements">
    ```text theme={null}
    Write a Python function to fetch data from an API endpoint. Include proper error handling for network timeouts, 404 errors, and invalid JSON responses. Use the requests library.
    ```
  </Accordion>

  <Accordion title="Specify code style preferences">
    ```text theme={null}
    Refactor this function to use functional programming principles. Avoid mutations, use pure functions, and prefer map/filter/reduce over loops.
    ```
  </Accordion>
</AccordionGroup>

### For analysis and research

Use the [Deep Research](/tools/deep-research) tool for comprehensive research, or structure your prompt for focused analysis:

```text theme={null}
Analyze the pros and cons of microservices architecture for a startup with 5 developers. Consider factors like development velocity, operational complexity, and scalability needs. Provide specific recommendations.
```

### For creative content

Provide style references, target audience, and key messaging:

```text theme={null}
Write a product announcement blog post for our new AI code assistant feature. Target audience is professional developers. Tone should be informative but exciting. Include a section on key benefits and use cases. Aim for 500-700 words.
```

### For documentation

Specify documentation standards and audience:

```text theme={null}
Document this API endpoint using OpenAPI 3.0 specification. Include request/response examples, all possible error codes, and rate limiting information. Assume the audience is experienced API consumers.
```

## Advanced prompting techniques

### Chain of thought

Ask the AI to show its reasoning process:

```text theme={null}
Let's debug this React component step by step. First, identify potential issues. Then, explain why each is problematic. Finally, provide the corrected code with explanations for each change.

[paste code here]
```

### Role-based prompting

Assign the AI a specific expertise role:

```text theme={null}
Act as a senior database architect. Review this SQL query for performance issues and security vulnerabilities. Provide optimization recommendations with explanations.

[paste query here]
```

### Iterative refinement

Build on previous responses:

```text theme={null}
Take the component you just created and:
1. Add TypeScript types
2. Implement error boundaries
3. Add unit tests using Jest and React Testing Library
```

## Model-specific considerations

Different models excel at different tasks. ZeroTwo supports [multiple AI providers](/overview/models-and-providers) with varying strengths.

<CardGroup cols={2}>
  <Card title="OpenAI GPT-4" icon="brain">
    Excellent for complex reasoning, code generation, and instruction following. Works well with structured prompts.
  </Card>

  <Card title="Claude (Anthropic)" icon="sparkles">
    Superior for long-form content, analysis, and nuanced understanding. Responds well to conversational prompts.
  </Card>

  <Card title="Gemini (Google)" icon="google">
    Strong multimodal capabilities. Excels at tasks involving images, videos, and code analysis.
  </Card>

  <Card title="Specialized models" icon="rocket">
    Use reasoning models (o1, o3) for complex problem-solving. Use fast models (GPT-4o-mini, Claude Haiku) for simple tasks.
  </Card>
</CardGroup>

## Common pitfalls to avoid

<Warning>
  **Avoid these common mistakes:**

  * **Overly broad requests**: "Tell me about programming" is too vague
  * **Missing constraints**: Not specifying requirements, limitations, or edge cases
  * **Assuming context**: The AI doesn't remember previous sessions unless using [Memory](/tools/memory)
  * **Ignoring token limits**: Very long prompts may be truncated. See [tokens and limits](/prompts/tokens-and-limits)
  * **Not iterating**: First responses may not be perfect—refine and clarify
</Warning>

## Testing and refining prompts

<Steps>
  <Step title="Start with a clear goal">
    Define exactly what you want to achieve before writing your prompt.
  </Step>

  <Step title="Try your prompt">
    Submit your prompt and evaluate the response quality.
  </Step>

  <Step title="Identify gaps">
    What's missing? What's unclear? What's incorrect?
  </Step>

  <Step title="Refine and retry">
    Adjust your prompt based on the gaps you identified. Add more context, constraints, or examples.
  </Step>

  <Step title="Save successful patterns">
    Use [custom instructions](/chat/custom-instructions) or [create an assistant](/assistants/create) to preserve effective prompt patterns.
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="Structured techniques" icon="sitemap" href="/prompts/structured-techniques">
    Learn advanced structuring methods for complex tasks
  </Card>

  <Card title="Few-shot learning" icon="graduation-cap" href="/prompts/few-shot-and-demos">
    Improve results by providing examples
  </Card>

  <Card title="Custom instructions" icon="sliders" href="/prompts/custom-instructions-patterns">
    Create reusable prompt patterns
  </Card>

  <Card title="Token limits" icon="gauge" href="/prompts/tokens-and-limits">
    Understand context windows and token usage
  </Card>
</CardGroup>

## Additional resources

<Info>
  For assistance-specific prompting, see [Assistant Behavior and Tone](/assistants/behavior-and-tone). For setting persistent preferences, explore [Custom Instructions](/chat/custom-instructions).
</Info>
