Hook Examples
실제 프로젝트에 곧바로 응용할 수 있는 Agent Hook 예시 모음입니다. 각 예시는 트리거 종류, 대상 파일 패턴, 그리고 Agent에게 전달할 지시문을 함께 보여줍니다.
1. Security pre-commit scanner
커밋 직전 변경 파일을 점검해 민감 정보가 외부로 새어 나가는 사고를 줄여 주는 보안 점검용 훅입니다.
- Trigger Type:
Agent Stop
Agent에게 다음과 같은 지시를 줍니다.
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
2. Centralized user prompt logging
사용자가 입력한 프롬프트를 중앙 로그 시스템에 적재해 분석·감사 용도로 활용할 수 있도록 합니다.
- Trigger Type:
Prompt Submit - 참조 환경 변수:
${USER},${USER_PROMPT}
# 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}\"] ]
}]}"
3. Internationalization helper
기준 언어(영어) 로케일 파일이 갱신되면 다른 언어 파일과 비교해 누락 키를 보완하고 변경 키에 검토 표식을 달아 줍니다.
- Trigger Type:
File Save - Target Pattern:
src/locales/en/*.json - 사용 표식:
NEEDS_TRANSLATION,NEEDS_REVIEW
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
4. Test coverage maintainer
코드가 수정될 때마다 대응되는 테스트가 존재하는지 살피고, 빠진 부분에 대해서는 새 테스트를 생성·실행해 커버리지가 자연스럽게 유지되도록 돕습니다.
- Trigger Type:
File Save - Target Pattern:
src/**/*.{js,ts,jsx,tsx}
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
5. Documentation generator
필요할 때만 수동으로 실행해 현재 파일을 기준으로 문서를 다시 정리하고 README.md의 export 목록을 갱신합니다.
- Trigger Type:
Manual Trigger
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
6. Integration with MCP
Agent Hook는 Model Context Protocol(MCP)과 결합하면 한층 더 강력해집니다. 외부 도구·도메인 지식·풍부한 컨텍스트를 끌어와 단순한 자동화에서 벗어나 실질적인 의사결정까지 자동화할 수 있습니다.
- Access to External Tools — MCP 서버를 통해 전문 도구나 외부 API에 접근합니다.
- Enhanced Context — 추가 컨텍스트를 공급해 훅이 더 똑똑하게 동작하도록 만듭니다.
- Domain-Specific Knowledge — 특정 분야에 특화된 MCP 서버가 전문 지식을 제공합니다.
훅에 MCP를 연결할 때 권장되는 절차는 다음과 같습니다.
- 먼저 MCP 서버를 구성합니다. 자세한 설정은 MCP configuration 문서를 참고합니다.
- 훅 지시문 안에서 MCP 도구를 명시적으로 호출하도록 작성합니다.
- 자주 쓰이는 도구에는 적절한 auto-approval 설정을 적용해 흐름이 끊기지 않게 합니다.
대표적인 활용 예시로는 Figma 디자인 시스템 준수 검증, 작업 완료 시 티켓 상태 업데이트, 프로젝트 폴더의 샘플 파일 기반 데이터베이스 동기화 등을 들 수 있습니다.
예시: Figma 디자인 검증
HTML과 CSS가 저장될 때마다 Figma MCP를 통해 실제 디자인 명세와의 일치 여부를 점검하는 훅입니다.
- Trigger Type:
File Save Hook - Target Patterns:
*.css,*.html
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.