Skip to main content

사용자 지정 지침을 사용하여 코필로트 코드 검토의 기능 잠금 해제

GitHub Copilot에서 보다 관련성 있고 실행 가능한 코드 리뷰를 제공하는 데 도움이 되는 효과적인 커스텀 지침 작성 방법을 알아봅니다.

소개

GitHub Copilot 코드 검토를 명령 파일을 사용하여 사용자 지정하여 팀의 요구 사항 및 코딩 표준에 맞게 검토 환경을 조정할 수 있습니다. 그러나 효과적인 사용자 지정 지침을 작성하려면 Copilot가 이러한 지침을 처리하는 방법과 가장 적합한 방법을 이해해야 합니다.

이 자습서에서는 Copilot에서 보다 관련성이 있는 코드 검토를 제공하는 데 도움이 되는 명확하고 효과적인 사용자 지정 지침을 작성하는 방법을 알아봅니다. 지침 구조화에 대한 모범 사례, 피해야 할 일반적인 문제 및 다양한 파일에서 지침을 구성하기 위한 전략을 검색합니다.

이 자습서에서는 Copilot 코드 검토에 대한 사용자 지정 지침을 사용하는 방법에 대해 설명합니다. 사용자 지정 지침 사용에 대한 보다 일반적인 소개는 GitHub Copilot에 대한 사용자 지정 지침 구성을 참조하세요.

학습할 내용

이 자습서를 마치면 다음을 이해할 수 있습니다.

  • 코드 검토를 위한 간결하고 효과적인 사용자 지정 지침을 작성하는 방법입니다.
  • 리포지토리 전체 및 경로별 지침 간의 차이점입니다.
  • Copilot 코드 검토와 잘 작동하는 일반적인 패턴들.
  • 현재 지원되지 않는 명령 유형입니다.
  • 최상의 결과를 위해 지침을 구성하는 방법.

필수 조건

  • Copilot 코드 검토에 액세스합니다.
  • 사용자 지정 명령 파일을 만들 수 있는 GitHub 리포지토리입니다.
  • Markdown 구문에 대한 기본적인 숙지입니다.

GitHub Copilot의 코드 검토 과정 지침 이해

사용자 지정 지침을 작성하기 전에 Copilot 코드 검토이 사용자 지정 지침을 어떻게 사용하는지 이해하는 것이 유용합니다. 끌어오기 요청을 검토할 때 Copilot는 명령 파일을 읽고 이를 사용하여 분석을 수행합니다. 그러나 다른 AI 시스템과 마찬가지로 다음과 같은 제한 사항이 있습니다.

  •         **비결정적 동작**: Copilot는 매번 모든 명령을 완벽하게 따르지 않을 수 있습니다.
    
  •         **컨텍스트 제한**: 명령 파일이 매우 길면 일부 지침이 간과될 수 있습니다.
    
  •         **특이성 문제**: 명확하고 구체적인 지침은 모호한 지시문보다 더 잘 작동합니다.
    

지침을 작성할 때 이러한 요소를 염두에 두면 현실적인 기대치를 설정하고 보다 효과적인 지침을 작성하는 데 도움이 됩니다.

효과적인 사용자 지정 지침 작성

성공적인 사용자 지정 지침의 핵심은 명확하고 간결하며 구체적이어야 합니다. 따라야 할 핵심 원칙은 다음과 같습니다.

지침을 짧고 집중된 상태로 유지

짧은 지시 파일은 Copilot에 의해 완전히 처리될 확률이 높습니다. 최소한의 지침 집합으로 시작하고 작동하는 내용에 따라 더 반복적으로 추가합니다.

          **모범 사례**: 단일 명령 파일을 최대 약 1,000줄로 제한합니다. 이 외에도 응답의 품질이 저하 될 수 있습니다.

명확한 구조 및 서식 사용

Copilot 다음과 같은 잘 구성된 지침의 이점을 누릴 수 있습니다.

  • 서로 다른 토픽을 구분하는 고유 제목입니다.
  • 쉽게 훑어보고 참조할 수 있는 글머리 기호.
  • 긴 설명 단락이 아닌 짧고 명령적인 지시문입니다.

예를 들어 다음을 작성하는 대신 다음을 수행합니다.

When you're reviewing code, it would be good if you could try to look for
situations where developers might have accidentally left in sensitive
information like passwords or API keys, and also check for security issues.

쓰기:

## Security Critical Issues

- Check for hardcoded secrets, API keys, or credentials
- Look for SQL injection and XSS vulnerabilities
- Verify proper input validation and sanitization

구체적인 예제 제공

동료에게 개념을 설명할 때와 마찬가지로, 예제는 Copilot이 사용자가 의미하는 바를 이해하는 데 도움이 됩니다. 올바른 패턴과 잘못된 패턴을 모두 보여 주는 코드 조각을 포함합니다.

다음은 그 예입니다.

## Naming Conventions

Use descriptive, intention-revealing names.

```javascript
// Avoid
const d = new Date();
const x = users.filter(u => u.active);

// Prefer
const currentDate = new Date();
const activeUsers = users.filter(user => user.isActive);
```

파일 간 지침 구성

Copilot 코드 검토는 다음 두 가지 유형의 명령 파일을 지원합니다.

  1.        **
           `copilot-instructions.md`
           **: 모든 파일에 적용되는 리포지토리 전체 지침입니다.
    
  2.        **
           `*.instructions.md`
           **: 특정 파일 또는 디렉터리에 적용되는 경로별 지침입니다.
    

경로별 지침을 사용하여 Copilot에 초점을 맞추고 잘못된 파일에 언어별 규칙을 적용하지 못하도록 합니다.

리포지토리 전체 지침을 사용하는 경우

다음 용도로 copilot-instructions.md를 사용하십시오.

  • 일반 팀 표준 및 지침

  • 범용 보안 요구 사항

  • 오류 처리 철학과 같은 횡단 관심사

  • 문서화 기대 사항

            **
            `copilot-instructions.md`의 예제 구조:**
    
# General Code Review Standards

## Code Quality Essentials

- Functions should be focused and appropriately sized
- Use clear, descriptive naming conventions
- Ensure proper error handling throughout

## Security Standards

- Never hardcode credentials or API keys
- Validate all user inputs
- Use parameterized queries to prevent SQL injection

## Documentation Expectations

- All public functions must include doc comments
- Complex algorithms should have explanatory comments
- README files must be kept up to date

경로별 지침을 사용하는 경우

다음과 같은 목적을 위해 *.instructions.md 파일을 applyTo frontmatter 속성과 함께 사용합니다.

  • 언어별 코딩 표준

  • 프레임워크별 패턴

  • 기술 관련 보안 문제

  • 코드베이스의 여러 부분에 대한 다양한 규칙

            **예제: Python 관련 지침**
    

디렉터리 .github/instructionspython.instructions.md 파일을 만듭니다.

---
applyTo: "**/*.py"
---

# Python Coding Conventions

## Naming Conventions

- Use snake_case for variables and functions
- Use PascalCase for class names
- Use UPPERCASE for constants

## Code Style

- Follow PEP 8 style guidelines
- Limit line length to 88 characters (Black formatter standard)
- Use type hints for function signatures

## Best Practices

- Use list comprehensions for simple transformations
- Prefer f-strings for string formatting
- Use context managers (with statements) for resource management

```python
# Avoid
file = open('data.txt')
content = file.read()
file.close()

# Prefer
with open('data.txt') as file:
    content = file.read()
```
          **예: 프런트 엔드 관련 지침**

디렉터리 .github/instructionsfrontend.instructions.md라는 파일을 만듭니다.

---
applyTo: "src/components/**/*.{tsx,jsx}"
---

# React Component Guidelines

## Component Structure

- Use functional components with hooks
- Keep components small and focused (under 200 lines)
- Extract reusable logic into custom hooks

## State Management

- Use useState for local component state
- Use useContext for shared state across components
- Avoid prop drilling beyond 2-3 levels

## Accessibility

- All interactive elements must be keyboard accessible
- Include appropriate ARIA labels
- Ensure color contrast meets WCAG AA standards

복잡한 명령 집합 분리

다양한 관심사가 있는 대규모 리포지토리의 경우, 지침을 여러 개의 집중된 파일로 분할합니다.

.github/
  copilot-instructions.md          # General standards

.github/instructions/
  python.instructions.md           # Python-specific
  javascript.instructions.md       # JavaScript-specific
  security.instructions.md         # Security-specific
  api.instructions.md              # API-specific

필요한 경우 각 파일에는 명확하고 구체적인 용도와 적절한 applyTo 프런트매터가 있어야 합니다.

Copilot 코드 검토에서 잘 작동하는 것을 바탕으로, 지침을 구성하는데 권장되는 템플릿은 다음과 같습니다.

---
applyTo: "**/*.{js,ts}"  # If this is a path-specific file
---

# [Title: Technology or Domain Name] Guidelines

## Purpose

Brief statement of what this file covers and when these instructions apply.

## Naming Conventions

- Rule 1
- Rule 2
- Rule 3

## Code Style

- Style rule 1
- Style rule 2

```javascript
// Example showing correct pattern
```

## Error Handling

- How to handle errors
- What patterns to use
- What to avoid

## Security Considerations

- Security rule 1
- Security rule 2

## Testing Guidelines

- Testing expectation 1
- Testing expectation 2

## Performance

- Performance consideration 1
- Performance consideration 2

특정 요구 사항에 맞게 이 구조를 조정하지만 명확한 단면 및 글머리 기호 형식을 유지합니다.

사용자 지정 지침에 포함하지 않을 내용

현재 지원되지 않는 Copilot 코드 검토를 이해하면 작동하지 않는 지침에 시간을 낭비하지 않도록 방지할 수 있습니다.

지원되지 않는 명령 유형

Copilot 코드 검토는 현재 다음을 시도하는 지침을 지원하지 않습니다.

          **사용자 환경 또는 서식을 변경합니다.**
  • Use bold text for critical issues

  • Change the format of review comments

  • Add emoji to comments

            **끌어오기 요청 개요 주석을 수정합니다.**
    
  • Include a summary of security issues in the PR overview

  • Add a testing checklist to the overview comment

            **GitHub Copilot의 핵심 함수를 변경**합니다.
    
  • Block a PR from merging unless all Copilot 코드 검토 comments are addressed

  • Generate a changelog entry for every PR

            **외부 링크를 따릅니다.**
    
  • Review this code according to the standards at https://example.com/standards

    해결 방법: 관련 콘텐츠를 명령 파일에 직접 복사합니다.

            **모호한 품질 향상**:
    
  • Be more accurate

  • Don't miss any issues

  • Be consistent in your feedback

이러한 유형의 지침은 정확하고 일관된 검토를 제공하도록 이미 최적화되어 있으므로 Copilot의 효율성을 개선하지 않고 노이즈를 추가합니다.

지침을 테스트하고 반복 작업하기

효과적인 사용자 지정 지침을 만드는 가장 좋은 방법은 작게 시작하고 결과에 따라 반복하는 것입니다.

최소 명령 집합으로 시작

가장 일반적인 검토 요구 사항을 다루는 10~20개의 특정 지침으로 시작하고, 그것들이 의도한 대로 Copilot 코드 검토에 영향을 미치는지 테스트합니다.

실제 끌어오기 요청으로 테스트

지침을 만든 후:

  1. 리포지토리에서 끌어오기 요청을 엽니다.
  2. Copilot에서 검토를 요청합니다.
  3. 어떤 지침이 효과적으로 따르는지 관찰합니다.
  4. 지속적으로 누락되거나 잘못 해석되는 모든 지침을 확인합니다.

결과에 따라 반복

한 번에 하나씩 또는 소규모 그룹으로 새 지침을 추가합니다.

  1. Copilot이(가) 더 잘 검토할 수 있는 패턴을 식별합니다.
  2. 해당 패턴에 대한 특정 명령을 추가합니다.
  3. 새 끌어오기 요청으로 테스트합니다.
  4. 결과에 따라 명령을 구체화합니다.

이 반복적인 접근 방식을 사용하면 작동하는 항목을 이해하고 명령 파일을 집중적으로 유지할 수 있습니다.

예: 코드 검토를 위한 사용자 지정 지침 완료

다음은 이 자습서의 모든 모범 사례를 통합하는 전체 예제입니다.

          **파일: `.github/copilot-instructions.md`**
# General Code Review Standards

## Purpose

These instructions guide Copilot 코드 검토 across all files in this repository.
Language-specific rules are in separate instruction files.

## Security Critical Issues

- Check for hardcoded secrets, API keys, or credentials
- Look for SQL injection and XSS vulnerabilities
- Verify proper input validation and sanitization
- Review authentication and authorization logic

## Performance Red Flags

- Identify N+1 database query problems
- Spot inefficient loops and algorithmic issues
- Check for memory leaks and resource cleanup
- Review caching opportunities for expensive operations

## Code Quality Essentials

- Functions should be focused and appropriately sized (under 50 lines)
- Use clear, descriptive naming conventions
- Ensure proper error handling throughout
- Remove dead code and unused imports

## Review Style

- Be specific and actionable in feedback
- Explain the "why" behind recommendations
- Acknowledge good patterns when you see them
- Ask clarifying questions when code intent is unclear

## Testing Standards

- New features require unit tests
- Tests should cover edge cases and error conditions
- Test names should clearly describe what they test

Always prioritize security vulnerabilities and performance issues that could impact users.
          **파일: `.github/instructions/typescript.instructions.md`**
---
applyTo: "**/*.{ts,tsx}"
---

# TypeScript Development Standards

## Type Safety

- Avoid using `any` type—use `unknown` or specific types instead
- Use strict null checks (no `null` or `undefined` without explicit handling)
- Define interfaces for all object shapes

```typescript
// Avoid
function processData(data: any) {
    return data.value;
}

// Prefer
interface DataShape {
    value: string;
}

function processData(data: DataShape): string {
    return data.value;
}
```

## Naming Conventions

- Use PascalCase for types, interfaces, and classes
- Use camelCase for variables, functions, and methods
- Use UPPER_CASE for constants

## Modern TypeScript Patterns

- Use optional chaining (`?.`) and nullish coalescing (`??`)
- Prefer `const` over `let`; never use `var`
- Use arrow functions for callbacks and short functions

## React-Specific (for .tsx files)

- Use functional components with TypeScript props interfaces
- Type all props and state explicitly
- Use proper event types (e.g., `React.ChangeEvent<HTMLInputElement>`)

일반적인 문제 해결

Copilot 코드 검토이(가) 예상대로 지침을 따르지 않는 경우, 다음 해결 방법을 시도해 보세요.

문제: 지침이 무시됨

          **가능한 원인:**
  • 명령 파일이 너무 깁니다(1,000줄 이상).

  • 지침은 모호하거나 모호합니다.

  • 지침이 서로 충돌합니다.

            **해결 방법**:
    
  • 덜 중요한 지침을 제거하여 파일을 줄입니다.

  • 보다 구체적이고 실행 가능하도록 모호한 지침을 다시 작성합니다.

  • 충돌하는 지침을 검토하고 가장 중요한 지침의 우선 순위를 지정합니다.

문제: 잘못된 파일에 적용되는 언어별 규칙

          **가능한 원인:**
  • 프런트매터가 없거나 applyTo에 잘못되었습니다.

  • 경로별 파일 대신 리포지토리 전체 파일의 규칙입니다.

            **해결 방법**:
    
  • 경로별 지침 파일에 applyTo frontmatter를 추가합니다.

  • 언어별 규칙을 copilot-instructions.md에서 적절한 *.instructions.md 파일로 이동합니다.

문제: 리뷰에서 일관되지 않은 동작

          **가능한 원인:**
  • 지침이 너무 많습니다.

  • 지침에는 특이성이 부족합니다.

  • AI 응답의 자연스러운 가변성.

            **해결 방법**:
    
  • 우선 순위가 가장 높은 지침에 집중합니다.

  • 의도를 명확히 하기 위한 구체적인 예제를 추가합니다.

  • AI 시스템의 경우 약간의 가변성이 정상임을 인정합니다.

결론

효과적인 사용자 지정 지침은 Copilot 코드 검토에서 팀의 표준에 맞게 보다 관련성이 높고 실행 가능한 피드백을 제공하는 데 도움이 됩니다. 이 자습서의 원칙에 따라 지침을 간결하게 유지하고, 명확한 구조를 제공하고, 구체적인 예제를 사용하고, 여러 파일을 구성하면 코드 검토 환경을 크게 향상시킬 수 있습니다.

효과적인 지침을 만드는 것은 반복적인 프로세스입니다. 포커스가 있는 소규모 지침 집합으로 시작하고, 실제 끌어오기 요청으로 테스트하고, 팀에 적합한 항목에 따라 점진적으로 확장합니다.

다음 단계