콘텐츠로 이동

Hook 예시

이 예시들은 실제 프로젝트에 적용할 수 있는 실제 hook 구현을 보여줍니다. 각 예시에는 트리거 유형, 대상 패턴 및 완전한 hook 지침이 포함되어 있습니다.

보안 사전 커밋 스캐너

이 hook은 커밋 전에 파일을 스캔하여 보안 유출을 방지합니다.

트리거 타입: Agent Stop

Agent Prompt:

Review changed files for potential security issues: 1. Look for API keys, tokens, or credentials in source code 2. Check for private keys or sensitive credentials 3. Scan for encryption keys or certificates 4. Identify authentication tokens or session IDs 5. Flag passwords or secrets in configuration files 6. Detect IP addresses containing sensitive data 7. Find hardcoded internal URLs 8. Spot database connection credentials For each issue found: 1. Highlight the specific security risk 2. Suggest a secure alternative approach 3. Recommend security best practices

중앙 집중식 사용자 프롬프트 로깅

이 hook은 분석 및/또는 감사를 위해 모든 사용자 프롬프트를 중앙 집중식 로깅 시스템에 기록합니다.

트리거 타입: Prompt Submit

셸 명령:

# Log user prompt to Grafana Loki curl -H "Content-Type: application/json" -XPOST \ "http://loghost/loki/api/v1/push" --data-raw \ "{'streams': [{ 'stream': { 'app': 'kiro', 'user': \"${USER}\" }, 'values': [ [\"$(date +%s%N)\", \"${USER_PROMPT}\"] ] }]}"

국제화 도우미

이 hook은 기본 언어 파일의 텍스트를 업데이트할 때 번역이 동기화되도록 합니다.

트리거 타입: File Save 대상: src/locales/en/*.json

Agent Prompt:

When an English locale file is updated: 1. Identify which string keys were added or modified 2. Check all other language files for these keys 3. For missing keys, add them with a "NEEDS_TRANSLATION" marker 4. For modified keys, mark them as "NEEDS_REVIEW" 5. Generate a summary of changes needed across all languages

테스트 커버리지 유지 관리자

이 hook은 코드가 발전함에 따라 테스트 커버리지를 높게 유지합니다.

트리거 타입: File Save 대상: src/**/*.{js,ts,jsx,tsx}

Agent Prompt:

When a source file is modified: 1. Identify new or modified functions and methods 2. Check if corresponding tests exist and cover the changes 3. If coverage is missing, generate test cases for the new code 4. Run the tests to verify they pass 5. Update coverage reports

문서 생성기

이 hook은 필요에 따라 트리거하여 코드 변경 사항에 맞게 문서를 업데이트할 수 있습니다.

트리거 타입: Manual Trigger

Agent Prompt:

Generate comprehensive documentation for the current file: 1. Extract function and class signatures 2. Document parameters and return types 3. Provide usage examples based on existing code 4. Update the README.md with any new exports 5. Ensure documentation follows project standards

MCP와의 통합

Agent Hooks는 Model Context Protocol(MCP) 기능으로 강화하여 기능을 확장할 수 있습니다:

  1. 외부 도구 액세스: Hooks는 MCP 서버를 활용하여 전문화된 도구 및 API에 액세스할 수 있습니다
  2. 향상된 컨텍스트: MCP는 더 지능적인 hook 작업을 위한 추가 컨텍스트를 제공합니다
  3. 도메인별 지식: 전문화된 MCP 서버는 도메인 전문 지식을 제공할 수 있습니다

MCP를 hooks와 함께 사용하려면:

  1. MCP 서버 구성
  2. Hook 지침에서 MCP 도구 참조
  3. 자주 사용하는 도구에 대해 적절한 자동 승인 설정 지정

사용 사례:

  • Figma 디자인 시스템이 준수되는지 확인
  • 작업 완료 후 티켓 상태 업데이트
  • 프로젝트 폴더 내 샘플 파일에서 데이터베이스 동기화

예시: Figma 디자인 검증

이 hook은 HTML 및 CSS 파일을 모니터링하고 Figma MCP를 사용하여 Figma 디자인을 따르는지 검증합니다.

트리거 타입: File Save Hook 대상: *.css *.html

Agent Prompt:

Use the Figma MCP to analyze the updated html or css files and check that they follow established design patterns in the figma design. Verify elements like hero sections, feature highlights, navigation elements, colors, and button placements align.