실제 작업에서 Codex & Claude Code 사용하기: 실용적인 코딩 예제 (2026)
Source: Dev.to
이전 글을 읽었다면 Codex와 Claude Code가 접근 방식에서 어떻게 다른지 대략 파악했을 것입니다. 이제 같은 문제에 대한 두 가지 해결책을 실제 시나리오에 적용해 볼 차례입니다.
두 모델에게 간단하지만 단계가 있는 작업을 해결하도록 요청했습니다:
JSON 사용자 목록이 주어졌을 때, "active": true인 사용자만 반환하세요.
Codex Output — Fast, Direct, Minimal Structure
import json
def get_active_users(data):
users = json.loads(data)
active = [u for u in users if u.get("active")]
result = ""
for u in active:
result += f"{u['name']} - {u['email']}\n"
return result
# Example usage
data = '[{"name": "Ana","email": "ana@mail.com","active": true},{"name": "Luis","email":"luis@mail.com","active": false}]'
print(get_active_users(data))
✔ 바로 작동하고 즉시 실행됩니다
Codex는 빠른 결과가 필요하고 나중에 다듬을 계획이라면 완벽합니다.
Claude Code Output — Maintainable, Modular
import json
from typing import List, Dict
def parse_users(data: str) -> List[Dict]:
"""Safely parse JSON input into Python objects."""
return json.loads(data)
def filter_active(users: List[Dict]) -> List[Dict]:
"""Return only active users."""
return [u for u in users if u.get("active") is True]
def format_report(users: List[Dict]) -> str:
"""Generate a readable name + email report."""
lines = [f"{u['name']} " for u in users]
return "\n".join(lines)
def build_user_report(data: str) -> str:
users = parse_users(data)
active = filter_active(users)
return format_report(active)
✔ 유지보수가 쉽고, 주석이 달려 있으며, 모듈화되었습니다
Claude는 이 저장소를 미래 팀과 공유하는 사람처럼 생각합니다.
When to Use Each Approach
Codex를 사용해야 할 경우:
- 스크립트나 해커톤용 빠른 함수가 필요할 때
- 논리를 빠르게 테스트하고 넘어가고 싶을 때
- 나중에 최적화할 시작점이 필요할 때
Claude Code를 사용해야 할 경우:
- 파일이 커질 것이라고 예상될 때
- 여러 사람이 저장소를 유지보수할 때
- 검증, 테스트, 역할 추가 등을 계획하고 있을 때
같은 문제, 다른 철학.
🎥 빠른 시각적 버전도 제공됩니다!