# GitHub 문제에서 기능 구현

GitHub 이슈를 GitHub Copilot CLI에 할당한 다음, 대화를 이끌어 해당 기능을 구현하세요.

GitHub Copilot CLI 는 GitHub 문제를 읽고, 구현 계획을 제안하고, 요구 사항을 충족하는 코드 변경 초안을 작성할 수 있습니다. 대화형 워크플로이기 때문에 잘못된 전제를 바로잡고, 관련 파일을 지정하고, GitHub Copilot CLI가 작업하는 동안 접근 방식을 다듬을 수 있습니다.

## 예제 시나리오

고객 구독을 지원하는 내부 Node.js 청구 API를 유지하는 플랫폼 팀에서 일한다고 상상해 보십시오. 제품 관리자는 단위 테스트 및 OpenAPI 사양 업데이트와 함께 지정된 구독에 연결된 계획을 반환하는 새 `GET /subscriptions/{id}/plan` 엔드포인트를 요청하는 문제를 엽니다. 이 문제에는 원하는 응답 셰이프, 누락되거나 취소된 구독에 대한 오류 사례 및 패턴으로 따를 기존 `/subscriptions/{id}` 엔드포인트에 대한 링크가 포함됩니다. 문제를 GitHub Copilot CLI에 넘겨 경로, 컨트롤러, 테스트를 스캐폴딩하게 한 다음 풀 리퀘스트를 열 수 있습니다.

## 예시 워크플로

GitHub Copilot CLI 에서 GitHub직접 문제를 읽고, 작업을 계획하고, 코드를 작성하고, 테스트를 실행하고, 끌어오기 요청을 열 수 있습니다.

### 컨텍스트로 문제 끌어오기

리포지토리 루트에서 시작하여 URL 또는 `owner/repo#number`로 이슈를 참조하세요.
GitHub Copilot CLI 는 GitHub MCP 서버를 사용하여 문제 본문, 주석 및 연결된 항목을 가져온 다음 해당 컨텍스트를 세션의 나머지 부분에 대해 사용할 수 있도록 유지합니다.

```text copy
Read octo-org/billing-api#482 and any issues or PRs it links to. 
Summarize what needs to be implemented before we plan the work.
```

### 다음을 사용하여 구현 계획 초안 작성 `/plan`

계획 모드로 전환하여 GitHub Copilot CLI 파일을 터치하기 전에 변경 내용을 확인합니다.

```text copy
/plan Implement the subscription lookup endpoint described in the issue. 
Follow the same conventions as the existing GET /subscriptions/{id} endpoint.
```

> \[!NOTE] 다음 응답이 예제입니다. Copilot Chat 응답은 비결정적이므로 여기에 표시된 응답과 다른 응답을 얻을 수 있습니다.

GitHub Copilot CLI 는 다음과 유사한 계획을 반환합니다.

```text
1. Add a `getPlanForSubscription` method in `src/services/subscriptionService.ts` that reuses the existing billing client, throws `NotFoundError` when the subscription or plan does not exist, and throws `CancelledSubscriptionError` when the subscription has been cancelled.
1. Add a `GET /subscriptions/:id/plan` route in `src/routes/subscriptions.ts`, mirroring the error handling in the sibling `GET /subscriptions/:id` route and mapping `CancelledSubscriptionError` to a `410` response.
1. Update `openapi/subscriptions.yaml` with the new path, response schema, and `404` and `410` responses.
1. Add unit tests in `test/services/subscriptionService.test.ts` and `test/routes/subscriptions.test.ts` covering the success case, missing subscription, cancelled subscription, and missing plan.
1. Run the test suite and update the changelog entry.
```

계획을 검토하고, 이상해 보이는 부분이 있으면 이의를 제기한 뒤, 승인하기 전에 GitHub Copilot CLI에 수정을 요청하세요. 예를 들어 응답으로 `Use the existing error classes in src/errors—NotFoundError for missing subscriptions or plans and CancelledSubscriptionError for cancelled subscriptions rather than introducing new ones`을 보내 영향을받는 단계를 업데이트할 수 있습니다.

### 구현 시작 및 필요에 따라 조정

코딩을 시작하도록 계획을 승인합니다.
GitHub Copilot CLI 은 한 번에 1단계를 진행하여 적용하기 전에 각 편집을 표시합니다. 잘못된 방향으로 이동하면 중단 및 리디렉션합니다.

예를 들어 팀에서 표준화된 청구 클라이언트를 다시 사용하는 대신 메서드에 새 데이터베이스 쿼리 GitHub Copilot CLI 를 추가한다고 가정 `getPlanForSubscription` 합니다. 중지하고 조종할 수 있습니다.

```text copy
Don't add a new query here. The billing client in 
src/clients/billingClient.ts already exposes a getPlan method. 
Use that and update the service to handle its NotFound response.
```

GitHub Copilot CLI 코드를 수정하고 나머지 계획 단계를 계속합니다.

### 단위 테스트 생성 및 실행

테스트 단계에 도달하면 GitHub Copilot CLI 기존 테스트 파일의 패턴과 일치하는 테스트를 스캐폴드합니다. 계획 엔드포인트의 경우 다음과 같은 사례를 추가할 수 있습니다.

* 활성 구독의 요금제 레코드를 반환합니다.
* 구독이 존재하지 않으면 `404`를 반환합니다.
* 구독이 취소된 경우 `410`을 반환합니다.
* 구독에 연결된 요금제가 없으면 `404`를 반환합니다.

테스트를 GitHub Copilot CLI 작성한 후 터미널에서 실행하여 결과를 즉시 볼 수 있습니다.

```text copy
Run the test suite for the new endpoint and fix any failures.
```

테스트가 실패 GitHub Copilot CLI 하면 실패 출력을 읽고, 구현을 업데이트하고, 테스트 도구 모음이 녹색이 될 때까지 다시 실행됩니다. 각 수정 사항을 검토하여 근본 원인을 마스킹하는 대신 해결하는지 확인합니다.

### 다음을 사용하여 변경 내용을 검토합니다. `/diff`

세션 전체의 변경 내용에 대한 통합 보기를 확인하는 데 사용합니다 `/diff` .

```text copy
/diff
```

문제가 있는 경우 커밋하기 전에 수정해 달라고 요청 GitHub Copilot CLI 합니다. 예를 들어, diff 범위를 의도한 변경 사항으로 다시 한정하기 위해 `Revert the formatting changes in src/routes/subscriptions.ts to only keep the new route handler`라고 회신할 수 있습니다.

### 끌어오기 요청 열기

기능이 구현되고 테스트 및 검토가 완료되면 GitHub Copilot CLI에게 풀 리퀘스트를 열도록 요청하세요. GitHub MCP 서버를 사용하여 분기를 푸시하고 끌어오기 요청을 만듭니다

```text copy
Commit the changes on a new branch, push it, and open a pull request 
against main. Link it to octo-org/billing-api#482 and summarize the 
implementation, the tests added, and any follow-up work.
```

GitHub Copilot CLI 끌어오기 요청의 URL을 사용하여 다시 보고하므로 여기에서 앞으로 이동할 수 있습니다.

## 추가 읽기

* [GitHub Copilot CLI](/ko/copilot/how-tos/copilot-cli)