---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# General guidelines for code generation

# General guidelines for code generation {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Use these general guidelines for code generation to get better code suggestions and create useful and accurate scripts.

## Writing prompts {#general-guidelines-code-generation__prompting}

Write clear and specific but concise prompts
:   Specify the expected outcome and context, including necessary details like task requirements, specific APIs if you know them, and any constraints.

Experiment with different prompts

:   As you refine and experiment, the Now LLM Service uses this feedback to learn and improve.

    * Try adjusting task instructions and incorporating examples, and then observe how code suggestions differ with different prompt styles and levels of detail.
    * Try including a short code snippet as an example of how to start the script with a single-shot prompt.
    * Keep track of your prompts, including any modifications, and instructions for generating prompts to meet your specifications. This tracking enables easy regeneration of past results for comparative analysis.
    {#general-guidelines-code-generation__ul_zpm_rxj_dyb}
{#general-guidelines-code-generation__table_ryd_22l_yxb__entry__3}

| Strong prompt | Weak prompt | Notes |
|-|-|-|
| Get incidents with related tasks | Get incidents with tasks | Includes sufficient detail. |
| Use glide aggregate to count number of P1 incidents closed between 3rd March to 13 April assigned to admin | Count P1 incidents between 3-3 and 4-13 | Includes the API name and more specific language. |
| If open change request is P1, do not allow reducing the severity unless it's the creator | Don't allow changing P1 change requests | Includes more specific instructions on what shouldn't change. |
| Gliderecord of the most recent change | Latest change | Includes the API name and more specific language. |
[Table 1. Example prompts for code generation]

{#general-guidelines-code-generation__table_ryd_22l_yxb}

## Reviewing code {#general-guidelines-code-generation__gg-overview}

Review code
:   Implement strict and detailed reviews of the AI-generated code to determine its accuracy, efficiency, and how well it adheres to your coding standards.

Test code
:   Validate the code by running it against test cases in controlled environments to ensure that it functions according to your requirements.

