Skip to main content

첫 번째 사용자 지정 지침

이 간단한 예시를 사용하여 첫 번째 사용자 지정 지침을 만들고 테스트합니다.

참고 항목

  • 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.
  • For community-contributed examples of custom instructions for specific languages and scenarios, see the Awesome GitHub Copilot Customizations repository.
  • You can apply custom instructions across different scopes, depending on the platform or IDE where you are creating them. For more information, see "GitHub Copilot Chat 응답 사용자 지정 정보."

사용자 지정 정보

두 가지 유형의 파일을 사용하여 GitHub Copilot의 응답을 사용자 지정할 수 있습니다.

  • 사용자 지정 지침은 GitHub Copilot이 모든 상호 작용에서 어떻게 작동해야 하는지에 대한 지속적인 지침을 제공합니다.
  • 프롬프트 파일(공개 미리 보기) 은 필요할 때 호출할 수 있는 특정 작업에 대한 재사용 가능한 프롬프트를 정의합니다. 프롬프트 파일은 VS Code에서만 사용할 수 있습니다. 소개 예시는 첫 번째 프롬프트 파일을(를) 참조하세요.

사용자 지정 지침은 각 AI 워크플로에 컨텍스트를 추가하는 데 도움이 되지만 프롬프트 파일을 사용하면 특정 채팅 상호 작용에 지침을 추가할 수 있습니다.

가장 일반적으로 사용되고 지원되는 것은 리포지토리 사용자 지정 지침이지만, GitHub의 GitHub Copilot 채팅에 대해서만 개인 및 조직 사용자 지정 지침을 정의할 수도 있습니다. You can create repository custom instructions in two ways:

  • Repository-wide instructions: Create a single copilot-instructions.md file at the repository root that applies to all files in the repository.
  • 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 and GitHub Copilot coding agent.

첫 번째 지침

GitHub Copilot이 코딩 기본 설정을 이해하는 데 도움이 되는 핵심 사용자 지정 지침부터 시작해 보세요.

함수 작성 지침

Markdown
When writing functions, always:
- Add descriptive JSDoc comments
- Include input validation
- Use early returns for error conditions
- Add meaningful variable names
- Include at least one example usage in comments

이 지침은 GitHub Copilot이 함수를 생성하는 방식을 변경합니다.

테스트

사용자 지정 지침이 가져올 수 있는 차이점을 빠르게 테스트하려면 Copilot Chat의 몰입형 보기에서 개인 사용자 지정 지침을 사용할 수 있습니다.

  1. 먼저, github.com/copilot으로 이동하여 이 프롬프트를 입력하세요.

    Create a JavaScript function that calculates the area of a circle

    사용자 지정 지침이 없으면 다음과 같은 결과가 발생할 수 있습니다.

    function areaOfCircle(radius) {
        if (typeof radius !== 'number' || radius < 0) {
            throw new Error('Radius must be a non-negative number');
        }
        return Math.PI * radius * radius;
    }
    
  2. 이제 페이지 왼쪽 하단에 있는 프로필 사진을 클릭하고 Personal instructions를 클릭하여 개인 사용자 지정 지침에 액세스하세요. 위의 지침을 텍스트 상자에 붙여넣은 다음, Save를 클릭합니다.

    이제 이전에 입력한 것과 동일한 프롬프트를 입력합니다.

    사용자 지정 지침을 사용하면 다음과 같은 결과를 받게 됩니다.

    /**
     * Calculates the area of a circle given its radius.
     *
     * @param {number} radius - The radius of the circle. Must be a positive number.
     * @returns {number|null} The area of the circle, or null if the input is invalid.
     *
     * @example
     * // returns 78.53981633974483
     * areaOfCircle(5);
     *
     * @example
     * // returns null (invalid input)
     * areaOfCircle(-2);
     */
    function areaOfCircle(radius) {
      if (typeof radius !== "number" || isNaN(radius) || radius <= 0) {
        // Invalid input: radius must be a positive number
        return null;
      }
    
      const area = Math.PI * Math.pow(radius, 2);
      return area;
    }
    
    // Example usage:
    console.log(areaOfCircle(5));   // 78.53981633974483
    console.log(areaOfCircle(-2));  // null
    

Further reading