Anthropic claude-code-action(公式)
Anthropic公式GitHub ActionリポジトリのCLAUDE.md。Claude Codeチーム自身がどう指示を書くかを示す。「ハマりポイント」セクション付き。
# CLAUDE.md
## Commands
```bash
bun test # Run tests
bun run typecheck # TypeScript type checking
bun run format # Format with prettier
bun run format:check # Check formatting
```
## What This Is
A GitHub Action that lets Claude respond to `@claude` mentions on issues/PRs (tag mode) or run tasks via `prompt` input (agent mode). Mode is auto-detected: if `prompt` is provided, it's agent mode; if triggered by a comment/issue event with `@claude`, it's tag mode. See `src/modes/detector.ts`.
## How It Runs
Single entrypoint: `src/entrypoints/run.ts` orchestrates everything -- prepare (auth, permissions, trigger check, branch/comment creation), install Claude Code CLI, execute Claude via `base-action/` functions (imported directly, not subprocess), then cleanup (update tracking comment, write step summary).
`base-action/` is also published standalone as `@anthropic-ai/claude-code-base-action`. Don't break its public API.
## Key Concepts
**Auth priority**: `github_token` input (user-provided) > GitHub App OIDC token (default). The `claude_code_oauth_token` and `anthropic_api_key` are for the Claude API, not GitHub.
**Mode lifecycle**: `detectMode()` in `src/modes/detector.ts` picks the mode name ("tag" or "agent").
**Prompt construction**: Tag mode builds the prompt by fetching GitHub data, formatting it as markdown, and writing it to a temp file. This is the most important part of the action -- it's what Claude sees.
## Things That Will Bite You
- **Strict TypeScript**: `noUnusedLocals` and `noUnusedParameters` are enabled. Typecheck will fail on unused variables.
- **Discriminated unions for GitHub context**: `GitHubContext` is a union type -- call `isEntityContext(context)` before accessing entity-specific fields.
- **Token lifecycle matters**: The GitHub App token is obtained early and revoked in a separate `always()` step. If you move token revocation into `run.ts`, it won't run if the process crashes.
- **Error phase attribution**: The catch block in `run.ts` uses `prepareCompleted` to distinguish prepare failures from execution failures.
## Code Conventions
- Runtime is Bun, not Node. Use `bun test`, not `jest`.
- `moduleResolution: "bundler"` -- imports don't need `.js` extensions.
- GitHub API calls should use retry logic (`src/utils/retry.ts`). こちらもおすすめ
DevOps カテゴリの他のルール
もっとルールを探す
CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。



