Files
LazyEnter/CLAUDE.md

1.8 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

LazyEnter("소파에서 엔터나 치자")는 로컬 PC의 Claude Code CLI 세션을 Slack으로 중계하여, 모바일에서 승인(y/n) 및 명령을 원격 수행하는 브릿지 시스템이다. Slack Socket Mode를 사용하므로 공인 IP나 방화벽 설정이 불필요하다.

Architecture

Slack App (모바일/데스크톱)
    ↕  Socket Mode
SlackHandler ← Bridge → PtyManager
                  ↑           ↕
               Config     pexpect (claude 프로세스)
                  ↑
              CLI Hooks (hooks.py)
  • Bridge (bridge.py): 핵심 중계기. SlackHandler와 PtyManager를 연결하고 출력 폴링 스레드를 관리
  • SlackHandler (slack_handler.py): slack_bolt 기반 Socket Mode 이벤트 수신/메시지 전송
  • PtyManager (pty_manager.py): pexpect로 가상 터미널 프로세스 생성·입출력 제어
  • Config (config.py): python-dotenv 기반 환경 변수 관리
  • Hooks (hooks.py): Claude Code /hooks 이벤트를 파싱하여 Slack 알림 전송 (승인 대기, 작업 완료)

Commands

# 의존성 설치
pip install -e .

# 실행
lazy-enter
# 또는
python -m lazy_enter

# 테스트
pytest
pytest tests/test_hooks.py -v          # 단일 파일
pytest tests/test_hooks.py::test_parse_hook_event_valid -v  # 단일 테스트

# 린트
ruff check src/ tests/
ruff format src/ tests/

# 타입 체크
mypy src/

Key Conventions

  • src/ 레이아웃 사용 (src/lazy_enter/)
  • 환경 변수는 .env 파일로 관리 (.env.example 참조)
  • 보안: SLACK_ALLOWED_USER_ID, SLACK_ALLOWED_CHANNEL_ID로 접근 제한 필수