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

# Creating a task

> Making your first task

{/*

<Steps>
<Step title="First Step">
  These are instructions or content that only pertain to the first step.
</Step>
<Step title="Second Step">
  These are instructions or content that only pertain to the second step.
</Step>
<Step title="Third Step">
  These are instructions or content that only pertain to the third step.
</Step>
</Steps>

*/}

<Steps>
  <Step title="Create a new task">
    Type `workflowai task new` into the terminal and press `enter`
  </Step>

  <Step title="Enter a description for your task">
    Enter a description of the task that defines the inputs and outputs for the task.

    In this context, the input is the information and data you will give you the AI, and the output is what the AI will give back to you.

    <AccordionGroup>
      <Accordion title="Tips on optimizing task descriptions">
        To make sure that the input and output is defined correctly, note the following in your description:

        * What would you give to the task as input?
        * What do you expect as output?
        * Are there any edge cases or constraints to be mindful of?
      </Accordion>

      <Accordion title="See an example task description">
        *Given a city, output the country that city exists within*
      </Accordion>
    </AccordionGroup>

    <Tip>For more example tasks check out our [task of the week](https://blog.workflowai.ai/tag/task-of-the-week/) blog posts</Tip>
  </Step>

  <Step title="Review the generated task">
    1. WorkflowAI will generate a class for both the input and output (as well as a class for the task description).

    <Accordion title="See example generated task">
      ```Python theme={null}
      from pydantic import Field                                                                                
      from core.domain import AbstractTaskIO, Task                                                              
                                                                                                    
      """This code was originally generated by Workflow AI based on the following task description:             
      'Given a city output the country that city exists within'"""                                              

      class CityToCountryTaskInput(AbstractTaskIO):
      city: str = Field(
      description='The name of the city for which the country is to be determined',
      examples=['Paris', 'Tokyo', 'New York'],
      )

      class CityToCountryTaskOutput(AbstractTaskIO):
      country: str = Field(
      description='The country in which the specified city is located',
      examples=['France', 'Japan', 'United States'],
      ) 

                                                                                                                                 
      class CityToCountryTask(Task[CityToCountryTaskInput, CityToCountryTaskOutput]):                                                   
      input_class: type[CityToCountryTaskInput] = CityToCountryTaskInput                                                            
      output_class: type[CityToCountryTaskOutput] = CityToCountryTaskOutput                                                         
      instructions: str = """To complete the task, you need to determine the country in which a specified city is located. You will 
      receive an input JSON object containing a single field named 'city', which is a string representing the name of the city. Your    
      output should be a JSON object with a single field named 'country', which is a string representing the name of the country where  
      the city exists. For example, if the input is {"city": "Paris"}, the output should be {"country": "France"}. Ensure that the      
      output strictly adheres to the provided output JSON schema."""                                                                    
                                                                                                                            
      ```
    </Accordion>

    2. Review, the input and output for the task:
       * If you are happy with the generated task, enter `Y` to save
       * If not, enter `n` and start at step 1

    <Info>Note: it's more important to make sure the input and output are correct at this stage. The task description is less important for now.</Info>
  </Step>

  <Step title="(Optional) Refine your task description">
    Here are some steps to refine your description to get better results

    1. a
    2. b
    3. c
    4. d
    5. e
  </Step>
</Steps>
