{"meta":{"title":"Your first custom instructions","intro":"Create and test your first custom instruction with this simple example.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/copilot","title":"GitHub Copilot"},{"href":"/en/copilot/tutorials","title":"Tutorials"},{"href":"/en/copilot/tutorials/customization-library","title":"Customization library"},{"href":"/en/copilot/tutorials/customization-library/custom-instructions","title":"Custom instructions"},{"href":"/en/copilot/tutorials/customization-library/custom-instructions/your-first-custom-instructions","title":"Your first custom instructions"}],"documentType":"article"},"body":"# Your first custom instructions\n\nCreate and test your first custom instruction with this simple example.\n\n> \\[!NOTE]\n>\n> * The examples in this library are intended for inspiration—you are encouraged to adjust them to be more specific to your projects, languages, and team processes.\n> * For community-contributed examples of custom instructions for specific languages and scenarios, see the [Awesome GitHub Copilot Customizations](https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md) repository.\n> * You can apply custom instructions across different scopes, depending on the platform or IDE where you are creating them. For more information, see \"[About customizing GitHub Copilot responses](/en/copilot/concepts/response-customization).\"\n\n## About customizations\n\nYou can customize GitHub Copilot's responses using two types of files:\n\n* **Custom instructions** provide ongoing guidance for how GitHub Copilot should behave across all your interactions.\n* **Prompt files (public preview)** define reusable prompts for specific tasks that you can invoke when needed. Prompt files are only available in VS Code, Visual Studio, and JetBrains IDEs. For an introductory example, see [Your first prompt file](/en/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file).\n\nWhile custom instructions help to add context to each AI workflow, prompt files let you add instructions to a specific chat interaction.\n\nRepository custom instructions are the most commonly used and supported, but you can also define personal and organization custom instructions, only for GitHub Copilot Chat in GitHub. You can create repository custom instructions in two ways:\n\n* **Repository-wide instructions**: Create a single `copilot-instructions.md` file at the repository root that applies to all files in the repository.\n* **Path-specific instructions**: Create one or more `.instructions.md` files with an `applyTo` field that apply only to specific files or directories. Path-specific instructions are currently supported for **Copilot Chat** in Visual Studio Code, Visual Studio, and **Copilot cloud agent**.\n\n## Your first instructions\n\nStart with these core custom instructions that helps GitHub Copilot understand your coding preferences.\n\n### Instructions on writing functions\n\n```markdown copy\nWhen writing functions, always:\n- Add descriptive JSDoc comments\n- Include input validation\n- Use early returns for error conditions\n- Add meaningful variable names\n- Include at least one example usage in comments\n```\n\nThese instructions will change how GitHub Copilot generates functions.\n\n## Test it out\n\nTo quickly test out the difference that custom instructions can make, you can use personal custom instructions in Copilot Chat.\n\n1. First, go to [github.com/copilot](https://github.com/copilot?ref_product=copilot\\&ref_type=trial\\&ref_style=text) and enter this prompt:\n\n   `Create a JavaScript function that calculates the area of a circle`\n\n   **Without custom instructions**, you might get:\n\n   ```javascript\n   function areaOfCircle(radius) {\n       if (typeof radius !== 'number' || radius < 0) {\n           throw new Error('Radius must be a non-negative number');\n       }\n       return Math.PI * radius * radius;\n   }\n   ```\n\n2. Now access your personal custom instructions by clicking on your profile picture in the bottom left of the page, then click **Personal instructions**. Paste the above instructions into the text box, then click **Save**.\n\n   Now enter the same prompt that you entered previously.\n\n   **With custom instructions**, you'll get something like:\n\n   ```javascript\n   /**\n    * Calculates the area of a circle given its radius.\n    *\n    * @param {number} radius - The radius of the circle. Must be a positive number.\n    * @returns {number|null} The area of the circle, or null if the input is invalid.\n    *\n    * @example\n    * // returns 78.53981633974483\n    * areaOfCircle(5);\n    *\n    * @example\n    * // returns null (invalid input)\n    * areaOfCircle(-2);\n    */\n   function areaOfCircle(radius) {\n     if (typeof radius !== \"number\" || isNaN(radius) || radius <= 0) {\n       // Invalid input: radius must be a positive number\n       return null;\n     }\n\n     const area = Math.PI * Math.pow(radius, 2);\n     return area;\n   }\n\n   // Example usage:\n   console.log(areaOfCircle(5));   // 78.53981633974483\n   console.log(areaOfCircle(-2));  // null\n   ```\n\n## Further reading\n\n* [About customizing GitHub Copilot responses](/en/copilot/concepts/response-customization) - Overview of response customization in GitHub Copilot\n* [Add custom instructions for Copilot](/en/copilot/how-tos/configure-custom-instructions) - How to configure custom instructions\n* [Awesome GitHub Copilot Customizations](https://github.com/github/awesome-copilot/blob/main/README.md) - Repository of community-contributed custom instructions and other customizations for specific languages and scenarios"}