Skip to content

docs: AI 사용 구조 1차 개선#306

Merged
clxxrlove merged 5 commits into
developfrom
docs/#305/TWI-87
May 19, 2026
Merged

docs: AI 사용 구조 1차 개선#306
clxxrlove merged 5 commits into
developfrom
docs/#305/TWI-87

Conversation

@clxxrlove
Copy link
Copy Markdown
Member

🔗 관련 이슈

📙 작업 내역

  • 변경 사항:
    • legacy docs를 canonical docs로 정리
    • Pi review/fix/final/handoff skills 추가 및 frontmatter 보강
    • Claude Code implementation runner와 smoke test 추가
    • Pi 작업 승인 gate extension 추가
    • thin-link skills 추가, handoff-twix 호출 동작 명확화, plan-twix 신규 추가
  • 검증 결과:
    • Fastlane 미실행 (twix-gate 확인 단계에서 중단)

💬 추가 설명 or 리뷰 포인트 (선택)

  • 리뷰 포인트:

    • 신규 .pi/extensions/twix-gate.ts
    • Scripts/run-claude-implementation.sh
    • Scripts/smoke-test-claude-handoff.sh
    • .pi/skills/ canonical 유지, handoff-twix Pi-only 유지
  • AI 스킬이나 extension 외에 레거시 문서 정리도 포함되어 있는데, 이건 한번 검토해주면 좋겠어 @jihun32

  • 위 리뷰 포인트로 찍은 부분까진 AI가 만들어준 문서인데, 만든김에 바로 시켜봤음

    • Pi라는 작은 harness에 시도해보고 있고 아직은 실용성이 있는지는 잘 모르겠어. 제대로 안 써봐서
    • plan 짜고 claude에 handoff하는 스킬까지 만들고 테스트는 해봤는데 동작은 잘 함.
    • 성능이 좋은지는 천천히 써보면서 개선해야 할 거 같고, 스킬은 handoff 제외하고 codex/claude code에 전부 옮겨놔서 써보려면 써볼 수 있음

@linear
Copy link
Copy Markdown

linear Bot commented May 16, 2026

TWI-87

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ecc5e515-3018-4e06-babd-f5440cccee47

📥 Commits

Reviewing files that changed from the base of the PR and between 0a44c1a and 3dfbb44.

📒 Files selected for processing (31)
  • .claude/skills/docs-refactor/SKILL.md
  • .claude/skills/final-review/SKILL.md
  • .claude/skills/fix-review/SKILL.md
  • .claude/skills/review-twix/SKILL.md
  • .codex/skills/docs-refactor/SKILL.md
  • .codex/skills/final-review/SKILL.md
  • .codex/skills/fix-review/SKILL.md
  • .codex/skills/review-twix/SKILL.md
  • .gitignore
  • .pi/extensions/twix-gate.ts
  • .pi/skills/docs-refactor/SKILL.md
  • .pi/skills/final-review/SKILL.md
  • .pi/skills/fix-review/SKILL.md
  • .pi/skills/handoff-twix/SKILL.md
  • .pi/skills/plan-twix/SKILL.md
  • .pi/skills/review-twix/SKILL.md
  • AGENTS.md
  • Claude.md
  • Prompt.md
  • Rules.md
  • Scripts/run-claude-implementation.sh
  • Scripts/smoke-test-claude-handoff.sh
  • docs/Architecture/Overview.md
  • docs/Checklists.md
  • docs/Examples/NavigationStackExample.swift
  • docs/Guides/NetworkGuide.md
  • docs/QuickStart.md
  • docs/Reference/Checklists.md
  • docs/Reference/FileOrganization.md
  • docs/Reference/NamingConventions.md
  • docs/Reference/ProjectRules.md

📝 Walkthrough

PR 요약: AI 에이전트 사용 구조 1차 개선

개요

이 PR은 Keepiluv iOS 저장소의 에이전트 워크플로우를 정규화하고, 아키텍처 가이드라인을 재정립하며, Pi/Claude Code 기반 자동화를 도입합니다. 이슈 #305(TWI-87)를 해결합니다.


핵심 변경사항

1. Navigation 패턴 개선 (TCA State 관리)

NavigationStackExample.swift 업데이트:

  • 이전: StackState<Path> 기반 중첩 path 패턴
  • 현재: routes: [HomeRoute] 배열 + 선택적 child state (detail?, settings?)
  • 구현:
    • @ObservableStatesyncChildStatesWithRoutes() 메서드로 라우트와 child state 동기화
    • BindableAction을 통한 binding 기반 상태 동기화
    • child action을 detail(DetailReducer.Action) / settings(SettingsReducer.Action) 형태로 직접 수신
    • navigationDestination(for:) 기반 렌더링

영향도: 상태 추적 명확화, 테스트 용이성 향상, 라우트 배열 중심의 현대적 패턴


2. Canonical Architecture Guidelines (신규 추가)

AGENTS.md (309줄): 교차 에이전트 baseline document

  • 프로젝트 스택: iOS 17+, SwiftUI, TCA 1.23, Clean Architecture + MFA
  • Interface/Implementation 분리 강제
  • Token 접근 중앙화: TokenManager 경유만 허용
  • 아키텍처 guardrail 정의

docs/Reference/ProjectRules.md (205줄): 팀 구현 규칙 canonical reference

  • DocC 문서화 기준
  • Feature 조립 규칙 및 예외 사항
  • Reducer 생성 패턴 (Interface/Implementation 분리)
  • Token 접근 경계 명확화 (직접 Keychain/UserDefaults 금지)
  • SwiftLint, 코드 스타일, 검증 정책

docs/Architecture/Overview.md 강화:

  • Feature 계층의 Interface(public boundary) vs Sources(implementation) 역할 명시
  • Dependency Injection 시 Interface 우선 원칙
  • Token 접근 경계 섹션 신설: TokenManager → AuthInterceptor 경로만 허용

docs/Guides/NetworkGuide.md 업데이트:

  • Client 설계: struct-based TCA Client 중심 (protocol 최소화)
  • 토큰 처리 정책: TokenManager + AuthInterceptor만 사용
  • Feature Client에서 직접 토큰 접근 금지 명시

3. Pi 승인 게이트 및 안전 정책

.pi/extensions/twix-gate.ts (341줄, 新):

  • 도구 실행 권한 제어 (bash, write/edit 명령)
  • 허용: 읽기 전용 명령
  • 차단: git push, git reset --hard, rm -r, sudo, chmod, xcodebuild 등 위험 패턴
  • 확인 필요:
    • .env*, secrets, credentials, provisioning, signing 파일 접근
    • .pi/skills/, .pi/extensions/ 수정
    • git add/commit, fastlane ios ci_pr 실행
  • 세션 캐시: "한 번 승인" 옵션으로 UX 개선
  • UI 검증: 중요 동작 시 사용자 확인 요구 (UI 미제공 시 차단)

4. Pi 에이전트 스킬 (Skill) 정의

Canonical 구현 (.pi/skills/):

  • review-twix (110줄): 아키텍처/TCA/MFA 기준 코드 리뷰 (기본 리포트 전용)
  • fix-review (171줄): 승인된 리뷰 결과 최소 diff 적용
  • final-review (304줄): 커밋 메시지/PR 초안 생성까지의 최종 단계
  • docs-refactor (100줄): 문서 변경 검증 및 보고
  • handoff-twix (447줄): Pi/Claude Code 간 low-token handoff 오케스트레이션
    • PLAN → IMPLEMENTATION_REQUEST → runner 실행 → review/fix/final-review 연계
    • 부분 워크플로우 모드 A~E 지원
  • plan-twix (152줄): 구현 계획 작성/승인 흐름

Thin Link (.claude/skills/, .codex/skills/): canonical .pi/skills/ 지시 참조


5. Claude Code 실행 인터페이스 (Scripts/)

Scripts/run-claude-implementation.sh (68줄):

  • .agent/handoff/IMPLEMENTATION_REQUEST.md → Claude CLI 실행
  • 도구 허용/차단 목록, 예산, 시스템 프롬프트 제약 전달
  • 결과를 IMPLEMENTATION_RESULT.md (STATUS 파싱), claude.out, claude.err로 저장
  • 실패 시 스크립트 즉시 종료

Scripts/smoke-test-claude-handoff.sh (128줄):

  • 핸드오프 워크플로우 end-to-end 검증
  • 파일 생성 → runner 실행 → 결과 검증 (STATUS: DONE 확인)
  • .agent/handoff 제외 범위 외 변경 감지 (무단 수정 방지)

6. 문서 정리 및 레거시 제거

신규/개편:

  • Claude.md: 프로젝트 요약에서 Claude Code 진입점 가이드로 변경
  • docs/Reference/Checklists.md: Feature 구현/코드 리뷰/배포 체크리스트 확대
  • docs/Reference/FileOrganization.md: Interface 모듈 public boundary 명확화
  • docs/Reference/NamingConventions.md: Navigation 액션 예시를 [Route] 배열 패턴으로 업데이트

제거:

  • Prompt.md (216줄 제거)
  • Rules.md (185줄 제거)
  • docs/Checklists.md (34줄 제거)

아키텍처 영향도

항목 변화
State 관리 StackState → [Route] 배열 기반 (추적 명확화)
의존성 흐름 Token 접근 중앙화 (TokenManager only)
검증 Fastlane CI 기반 + twix-gate 승인 절차
워크플로우 Pi/Claude Code 핸드오프 자동화 (구조화된 파일 기반)
테스트 명시 요청 없는 한 새 테스트 미작성 정책

사용자 영향도

  • 개발자: 새 agentic workflow (handoff-twix / plan-twix skill) 활용 가능
  • 코드 안전성: twix-gate로 위험한 도구 실행 방지
  • 문서 접근성: AGENTS.md / ProjectRules.md 통해 아키텍처 규칙 명확화
  • 구현: [Route] 배열 NavigationStack 패턴 권장

검증 상태

  • Fastlane: twix-gate 승인 단계에서 미실행 (예상 동작)
  • smoke-test: 기본 핸드오프 검증 완료

다음 단계

  • 기존 코드베이스의 Navigation 패턴 점진적 마이그레이션
  • StackState 사용 코드 refactor (향후)
  • Pi 하니스를 통한 stale/성능 검증

개요

AI 에이전트 사용 효율성 및 아키텍처 규칙의 일관성을 위한 1차 개선으로, 스킬 정의, 도구 호출 제어 정책, 핸드오프 실행 인프라, 아키텍처 가이드 문서를 통합적으로 정의합니다. 기존 산재된 문서와 부정확한 내용을 정리하고, canonical 규칙 문서를 중심으로 각 에이전트 환경별 진입점을 구성합니다.

변경 사항

에이전트 기본 정책 및 문서 인프라

계층 설명
기본 정책 정의 및 문서 정리
AGENTS.md, Claude.md, Prompt.md, Rules.md, .gitignore
저장소 전체 에이전트 기준(AGENTS.md), Claude Code 진입점(Claude.md), 레거시 문서 정리(Prompt.md, Rules.md 삭제), handoff 디렉토리 추가(.gitignore).

스킬 정책 및 규칙 (canonical)

계층 설명
핵심 스킬 문서
.pi/skills/review-twix/, .pi/skills/plan-twix/, .pi/skills/handoff-twix/, .pi/skills/fix-review/, .pi/skills/final-review/, .pi/skills/docs-refactor/
각 스킬의 목적, 적용 시점, 실행 절차, 금지 사항, 검증 정책, 한국어 출력 형식을 정의하는 canonical 규칙 문서.

스킬 진입점 (Claude/Codex 호환)

계층 설명
환경별 스킬 진입점
.claude/skills/*, .codex/skills/*
각 에이전트 환경에서 canonical .pi/skills/ 규칙을 참조하도록 하는 얇은 진입점 문서.

도구 호출 제어 정책

계층 설명
Pi 확장 (twix-gate)
.pi/extensions/twix-gate.ts
bash 명령, 파일 쓰기/수정 도구를 가로채 위험도 판별 및 세션 캐시 기반 승인 제어를 구현.

핸드오프 실행 인프라

계층 설명
실행 및 검증 스크립트
Scripts/run-claude-implementation.sh, Scripts/smoke-test-claude-handoff.sh
Claude 구현 요청 실행, 세션 ID 생성, 결과 파일 검증, 스모크 테스트 자동화.

아키텍처 규칙 및 기술 가이드

계층 설명
구현 체크리스트 및 기술 문서 업데이트
docs/Architecture/Overview.md, docs/Examples/NavigationStackExample.swift, docs/Guides/NetworkGuide.md, docs/Reference/Checklists.md, docs/Reference/FileOrganization.md, docs/Reference/NamingConventions.md, docs/Reference/ProjectRules.md, docs/QuickStart.md
Interface/Implementation 분리 강화, Token 접근 경계 신설, Navigation 패턴 업데이트(StackState → Route 배열), Network Client struct-based 기본화, 아키텍처 규칙 canonical 문서(ProjectRules.md) 신규 추가.

예상 코드 리뷰 노력

🎯 4 (복잡함) | ⏱️ ~60분

복잡도 분석:

  • 이질성 높음: 스킬 정의, 확장 로직, 셸 스크립트, 문서 업데이트가 혼재
  • 스킬별 상세 규칙 문서: 각 문서의 절차·금지사항·검증 정책을 개별 검토 필요
  • 도구 호출 제어 로직: decision 분류, 세션 캐시, UI 선택 분기 등 복잡도 높음
  • 문서 재구성: 기존 내용 정리 및 새로운 아키텍처 규칙 통합

제안 레이블

📃 docs

제안 검토자

  • jihun32
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/#305/TWI-87

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the D-3 label May 16, 2026
@clxxrlove
Copy link
Copy Markdown
Member Author

@coderabbitai summary

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

✅ Actions performed

Summary regeneration triggered.

Copy link
Copy Markdown
Contributor

@jihun32 jihun32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍👍👍👍
코멘트 몇개 남긴거 확인만 해주고
pi가 뭔지 감이 잘 안오는데 코덱스 클로드 중복 줄이고 싱크 맞추기 위해 있는건가? 참고했던 레퍼런스 있으면 공유해줘~


현재 단계에서는 테스트/Testing 타겟 추가를 필수로 보지 않습니다.

> Unresolved: `TestDependencyKey`를 Interface에 두는 현재 패턴은 Testing 모듈 분리 원칙과 충돌할 가능성이 있습니다. 새 패턴을 도입하거나 기존 패턴을 변경하기 전에는 owner 확인이 필요합니다.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 맞말이고 내가 설계를 잘못해서 Interface Client가 TestDependencyKey를 따르고, mock용 previewValue도 Interface에 구현되어 있는게 잘못된 구조 같음

기존 Interface에 struct dependency 구조들 아래처럼 바꾸고 previewValue를 Testing에서 구현해서 exampleApp에서 주입하는 식으로 바꾸는게 아키텍처상 맞을 거 같음

  public struct GoalClient {
      public var fetchGoals: () async throws -> [Goal]

      public init(
          fetchGoals: @escaping () async throws -> [Goal]
      ) {
          self.fetchGoals = fetchGoals
      }
  }

  public extension GoalClient {
      static let unimplemented = Self(
          fetchGoals: {
              assertionFailure("GoalClient.fetchGoals is unimplemented. Override with
  withDependencies.")
              return []
          }
      )

  }

  private enum GoalClientKey: DependencyKey {
      static let liveValue: GoalClient = .unimplemented
  }

  public extension DependencyValues {
      var goalClient: GoalClient {
          get { self[GoalClientKey.self] }
          set { self[GoalClientKey.self] = newValue }
      }
  }

위 처럼 바꿀 시 기존에 App단에서 자동으로 주입되던 liveValue가 자동 주입이 안돼서 직접 명시해줘야 하는 트레이드오프가 있지만 MFA 구조를 명확히 따른다고 생각함

이렇게 바꾸는거에 대해서 어떻게 생각해? 괜찮다 싶으면 QA 다 반영하고 내가 새로 이슈 파서 리팩터링 할게

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿굿
해야겠다고 생각든게 좀 있긴 하더라고
하네스가 제대로 없는 상태에서 AI로 구현을 많이 하다보니까 안티패턴들이 많이 섞인거 같아서 나중에 구조 쭉 정리해보게

Comment thread AGENTS.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

200줄 이내로 작성하는게 좋다던데 한번 agent한테 피드백 맡겨보고 줄이면 좋을듯?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

흠... 다음 개선때 한번 해볼게

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review Flow가 review-twix -> fix-review(반영할 거 있을 시) -> fianl-review
이렇게 하면 되는거야?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞어 그거 생각하고 하긴 했어

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너가 handoff 스킬 사용해서 프롬프트 작성하면 그거에 맞게
review-twix, fix-review, final-review, docs-refactor 알아서 스킬 동작 하는거야?
구현은 handoff 스킬 사용해서 계획 프롬프트로 제시하면 pi가 클로드한테 구현 위임하는건가?

handoff 스킬 에서만 프롬프트를 작성할건지 궁금쓰

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pi는 일단 plan 모드가 없어서 plan 스킬을 만들어뒀고
plan 스킬로 받아온다음에, handoff로 클로드한테 맞기고, 리뷰까지 끝내는 orchestartion을 한번 해보고싶었어
실제로 해봤을때 /skill:handoff-twix [프롬프트] 이렇게 보내면 스킬 전부 동작하더라고

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 codex까지 스킬 다 만들어줬네 ㅋㅋㅋㅋ
센스 굿

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pi는 테스트로 써보는거라 버릴 수도 있을거 같아서...ㅋㅋ 글고 그냥 문서니까 여기저기서 다 쓸수있는게 좋은듯

@clxxrlove
Copy link
Copy Markdown
Member Author

@jihun32 pi 간단한 설명은 이거 보면 될듯 약간 에이전트계의 vscode?? https://www.youtube.com/watch?v=PzqRRYHHpbw

@clxxrlove clxxrlove merged commit 1b68a0d into develop May 19, 2026
7 checks passed
@clxxrlove clxxrlove deleted the docs/#305/TWI-87 branch May 19, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants