이슈 조회 및 관리
프로그래밍으로 이슈를 가져오고 생성하며 라벨을 지정하고 닫습니다.
이슈 조회 및 관리은(는) CoddyKit의 무료 AI Agents 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Agents 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Agents 강의에는 총 4개의 강의가 포함되어 있습니다.
저장소에서 이슈 가져오기
repo.get_issues()를 사용하여 이슈를 나열하십시오. 기본적으로 열린 이슈를 반환하며, 다른 상태를 가져오려면 state='closed' 또는 state='all'을 전달하십시오. 결과는 PaginatedList이므로 각 이슈를 처리하면서 반복하십시오.
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
# Open issues (default)
open_issues = repo.get_issues(state='open')
print(f'Open issues: {open_issues.totalCount}')
# Process first 20
for issue in open_issues[:20]:
print(f'#{issue.number}: {issue.title}')
print(f' Labels: {[l.name for l in issue.labels]}')
print(f' Assignee: {issue.assignee.login if issue.assignee else None}')
print(f' Created: {issue.created_at.date()}')이슈 필터링
get_issues()는 여러 필터 매개 변수를 지원합니다. state, labels, assignee, milestone, since, sort를 사용할 수 있습니다. 이들을 조합하여 에이전트가 처리해야 하는 이슈만 정확하게 가져오십시오.
import datetime
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
# Issues with the 'bug' label, sorted by newest
bug_issues = repo.get_issues(
state='open',
labels=['bug'],
sort='created',
direction='desc'
)
# Issues updated in the last 7 days
cutoff = datetime.datetime.now() - datetime.timedelta(days=7)
recent_issues = repo.get_issues(
state='open',
since=cutoff
)
# Issues assigned to a specific user
my_issues = repo.get_issues(
state='open',
assignee='username'
)
print(f'Bug issues: {bug_issues.totalCount}')
print(f'Recent issues: {recent_issues.totalCount}')이슈 속성에 액세스하기
각 Issue 객체에는 번호, 제목, 본문, 레이블, 담당자, 마일스톤, 상태, 댓글 수, 타임스탬프와 같은 다양한 속성이 있습니다. Python 속성으로 이러한 값에 액세스하십시오. 본문은 원시 Markdown 텍스트입니다.
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
issue = repo.get_issue(42) # get by number
print(f'Number: #{issue.number}')
print(f'Title: {issue.title}')
print(f'State: {issue.state}') # 'open' or 'closed'
print(f'Author: {issue.user.login}')
print(f'Body length: {len(issue.body or "")}')
print(f'Labels: {[l.name for l in issue.labels]}')
print(f'Assignees: {[a.login for a in issue.assignees]}')
print(f'Milestone: {issue.milestone.title if issue.milestone else None}')
print(f'Comments: {issue.comments}')
print(f'Reactions: {issue.get_reactions().totalCount}')
print(f'URL: {issue.html_url}')새 이슈 만들기
repo.create_issue()를 사용하여 프로그래밍 방식으로 새 이슈를 만드십시오. 필수 필드는 title 하나뿐입니다. body(Markdown), labels(이미 존재해야 함), assignees(GitHub 사용자 이름), milestone(마일스톤 객체)을 추가할 수 있습니다.
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
# Create a bug report
bug_body = (
'## Bug Report\n\n'
'**Observed:** Login fails with 500 error\n'
'**Expected:** Successful login\n'
'**Steps to reproduce:**\n'
'1. Navigate to /login\n'
'2. Enter valid credentials\n'
'3. Click Submit\n\n'
'**Environment:** Production, v2.3.1'
)
issue = repo.create_issue(
title='Login endpoint returns 500 for valid credentials',
body=bug_body,
labels=['bug', 'priority:high'],
assignees=['alice'], # must be repo collaborators
)
print(f'Created issue #{issue.number}: {issue.html_url}')이슈 편집(업데이트)
issue.edit()를 사용하여 기존 이슈의 모든 속성을 업데이트할 수 있습니다. 한 번의 호출로 제목, 본문, 상태, 레이블, 담당자 또는 마일스톤을 변경할 수 있습니다. 변경할 필드만 전달하십시오. 나머지 필드는 그대로 유지됩니다.
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
issue = repo.get_issue(42)
# Update title and add new labels
issue.edit(
title='[URGENT] Login endpoint returns 500',
labels=['bug', 'priority:critical', 'needs-hotfix']
)
# Close the issue
issue.edit(state='closed')
print(f'Issue #{issue.number} closed')
# Reopen it
issue.edit(state='open')
# Assign to a user
from github import NamedUser
issue.edit(assignees=['bob', 'carol'])
# Update the body
issue.edit(body=issue.body + '\n\n**Update:** Hotfix deployed to production.')레이블 관리
레이블은 이슈를 정리하는 데 사용됩니다. repo.get_labels()로 저장소의 모든 레이블을 가져오고, repo.create_label()로 새 레이블을 만들며, issue.add_to_labels()와 issue.remove_from_labels()로 이슈에 레이블을 추가하거나 제거하십시오.
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
# List all labels
for label in repo.get_labels():
print(f'{label.name}: #{label.color}')
# Create a new label if it doesn't exist
existing_names = {l.name for l in repo.get_labels()}
if 'agent-reviewed' not in existing_names:
repo.create_label(
name='agent-reviewed',
color='0075ca', # hex without #
description='Reviewed by AI agent'
)
print('Created label: agent-reviewed')
# Add a label to an issue
issue = repo.get_issue(42)
issue.add_to_labels('agent-reviewed')
# Remove a label
issue.remove_from_labels('needs-triage')이슈 댓글 읽기
issue.get_comments()를 사용하여 이슈의 모든 댓글을 가져오십시오. 각 댓글에는 작성자(user.login), 본문 텍스트, 타임스탬프가 있습니다. 순서대로 반복하면 대화 기록을 확인할 수 있습니다.
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
issue = repo.get_issue(42)
# Get all comments
comments = list(issue.get_comments())
print(f'Comments on #{issue.number}: {len(comments)}')
for comment in comments:
print(f'\n{comment.user.login} ({comment.created_at.date()}):')
print(comment.body[:200])
# Get only recent comments
for comment in issue.get_comments(since=cutoff):
print(f'Recent: {comment.user.login}: {comment.body[:100]}')이슈에 댓글 추가하기
issue.create_comment(body)를 사용하여 댓글을 게시하십시오. 본문은 Markdown을 지원합니다. 자동화된 에이전트 댓글에는 자동으로 작성된 댓글임을 분명히 밝히고, 기대치를 명확히 하기 위해 "🤖 Automated analysis" 헤더를 포함해야 합니다.
from github import Github
import os
import datetime
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
issue = repo.get_issue(42)
# Add an agent comment with clear attribution
agent_comment = (
'**Automated Analysis** (via code-review agent)\n\n'
'---\n'
f'**Issue classified as:** Critical Bug\n'
f'**Suggested priority:** P0\n'
f'**Suggested assignee:** @backend-team\n\n'
'**Analysis:**\n'
'The login 500 error matches pattern #12 in our known issues database.\n'
'Likely cause: database connection pool exhaustion during peak traffic.\n\n'
'**Suggested fix:** Increase pool size in `db_config.py` or add circuit breaker.\n\n'
f'_Generated at {datetime.datetime.now().strftime("%Y-%m-%d %H:%M UTC")}_'
)
comment = issue.create_comment(agent_comment)
print(f'Comment added: {comment.html_url}')대량 이슈 분류 에이전트
분류 에이전트는 새 이슈를 자동으로 처리합니다. 제목과 본문을 읽고, LLM을 통해 분류하고, 적절한 레이블을 추가하고, 적절한 팀에 할당한 다음, 초기 댓글을 게시합니다. 이를 통해 엔지니어가 수동으로 분류하는 데 드는 시간을 크게 줄일 수 있습니다.
import anthropic
import json
import os
from github import Github
g = Github(token=os.environ['GITHUB_TOKEN'])
client = anthropic.Anthropic(api_key=os.environ['ANTHROPIC_API_KEY'])
def triage_issue(repo, issue):
prompt = (
'Classify this GitHub issue. Return JSON only:\n'
'{"type": "bug|feature|question|docs", '
'"priority": "critical|high|medium|low", '
'"team": "backend|frontend|infra|ml", '
'"summary": "one sentence"}\n\n'
f'Title: {issue.title}\n'
f'Body: {(issue.body or "")[:1000]}'
)
response = client.messages.create(
model='claude-opus-4-5',
max_tokens=200,
messages=[{'role': 'user', 'content': prompt}]
)
try:
return json.loads(response.content[0].text)
except json.JSONDecodeError:
return {'type': 'question', 'priority': 'medium', 'team': 'backend', 'summary': 'Needs manual review'}이슈에 분류 결과 적용하기
LLM의 분류 결과를 이슈에 적용하십시오. 유형과 우선순위에 따라 레이블을 설정하고, 적절한 팀 리더에게 할당한 다음, 분류 댓글을 게시합니다. 사용자 지정 레이블로 분류가 완료된 이슈를 추적하여 다시 처리하지 않도록 하십시오.
TEAM_ASSIGNEES = {
'backend': 'alice',
'frontend': 'bob',
'infra': 'carol',
'ml': 'dave'
}
def apply_triage(repo, issue, classification):
issue_type = classification.get('type', 'question')
priority = classification.get('priority', 'medium')
team = classification.get('team', 'backend')
summary = classification.get('summary', '')
# Apply labels
labels_to_add = [f'type:{issue_type}', f'priority:{priority}', 'agent-triaged']
issue.edit(labels=labels_to_add)
# Assign to team lead
assignee = TEAM_ASSIGNEES.get(team, 'alice')
issue.edit(assignees=[assignee])
# Post triage comment
comment = (
f'**Automated Triage**\n\n'
f'Type: `{issue_type}` | Priority: `{priority}` | Team: `{team}`\n'
f'Summary: {summary}\n\n'
f'Assigned to @{assignee} for follow-up.'
)
issue.create_comment(comment)
print(f'Triaged #{issue.number}: {issue_type}/{priority} -> {assignee}')
# --- demo: minimal stand-in for a GitHub Issue object ---
class _FakeIssue:
number = 501
def edit(self, **kwargs):
print(f'[github] issue.edit({kwargs})')
def create_comment(self, body):
print(f'[github] comment posted:\n{body}')
classification = {'type': 'bug', 'priority': 'high', 'team': 'backend',
'summary': 'Login fails with 500 when email has a plus sign'}
apply_triage('coddy-agents', _FakeIssue(), classification)
오래된 이슈 자동 종료
오래된 이슈 관리는 일반적인 자동화 작업입니다. 일정 기간 동안 활동이 없는 열린 이슈를 찾고, 경고 댓글을 게시한 다음, 유예 기간 안에 응답이 없으면 이슈를 종료합니다. issue.updated_at으로 활동을 확인하고 issue.edit(state='closed')로 종료하십시오.
import datetime
from github import Github
import os
g = Github(token=os.environ['GITHUB_TOKEN'])
repo = g.get_repo('myorg/myrepo')
STALE_DAYS = 90
GRACE_DAYS = 14
now = datetime.datetime.utcnow()
stale_cutoff = now - datetime.timedelta(days=STALE_DAYS)
for issue in repo.get_issues(state='open'):
last_updated = issue.updated_at.replace(tzinfo=None)
if last_updated > stale_cutoff:
continue
# Check if stale warning already posted
comments = list(issue.get_comments())
stale_warned = any('stale' in c.body.lower() for c in comments)
if not stale_warned:
issue.create_comment(
'This issue has been inactive for 90 days. '
'It will be closed in 14 days unless there is activity.'
)
issue.add_to_labels('stale')
print(f'Stale warning: #{issue.number}')빠른 확인: issue.edit()와 create_issue() 비교
GitHub 이슈 관리에 대한 이해도를 확인해 보십시오.
이슈 관리 복습
이제 에이전트가 GitHub 이슈를 처음부터 끝까지 관리할 수 있습니다.
- repo.get_issues(state, labels, assignee, since) — 이슈를 필터링하고 나열합니다.
- repo.get_issue(number) — 번호로 특정 이슈를 가져옵니다.
- repo.create_issue(title, body, labels, assignees) — 새 이슈를 엽니다.
- issue.edit(state, title, labels, assignees) — 모든 필드를 업데이트합니다.
- issue.create_comment(body) — Markdown 댓글을 추가합니다.
- repo.create_label() / issue.add_to_labels() — 레이블을 관리합니다.
- 에이전트 댓글은 사람이 작성한 활동과 구분할 수 있도록 항상 명확하게 표시합니다.
- 다시 처리하지 않도록
'agent-triaged'레이블을 사용합니다.
자주 묻는 질문
“이슈 조회 및 관리” 강의는 무료인가요?
네 — “이슈 조회 및 관리” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Agents 강의 전체를 잠금 해제할 수 있습니다. AI Agents 강의에는 총 4개의 강의가 포함되어 있습니다.
“이슈 조회 및 관리”에서 뭘 배우나요?
프로그래밍으로 이슈를 가져오고 생성하며 라벨을 지정하고 닫습니다. 브라우저에서 직접 실행하는 실습 코드로 AI Agents을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
AI Agents을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 AI Agents은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“이슈 조회 및 관리” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 AI Agents 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 AI Agents 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.