## Codebase Exploration - **Overview** - `claude` → start interactive session - `> give me an overview of this codebase` - `> explain the main architecture patterns` - `> what are the key data models?` - `> how is authentication handled?` - **Search** - `> find files that handle user authentication` - `> how do these authentication files work together?` - `> trace the login process from front-end to database` ## Bug Fixing - **Report & Diagnose** - `> I'm seeing an error when I run npm test` - Include stack traces or reproduction steps - **Propose & Apply Fixes** - `> suggest a few ways to fix the @ts-ignore in user.ts` - `> update user.ts to add the null check you suggested` ## Refactoring - **Identify Legacy Code** - `> find deprecated API usage` - **Recommend Modernization** - `> suggest how to refactor utils.js to use ES2024 features` - **Apply & Test** - `> refactor utils.js to use ES2024 features while maintaining behavior` - `> run tests for the refactored code` ## Plan Mode (Safe Read-Only Analysis) - **Enable** - Toggle: `Shift + Tab` → cycle to “plan mode” - CLI: `claude --permission-mode plan` - **Use** - `claude --permission-mode plan -p "Analyze authentication system"` - **Default Config** ```json { "permissions": { "defaultMode": "plan" } } ``` ## Subagents - **View & Use** - `/agents` → list or create subagents - `> review my recent code changes for security issues` - **Explicit Use** - `> use the code-reviewer subagent to check the auth module` - **Create Custom** - `.claude/agents/` → define subagent type, tool access, and description ## Testing Workflows - `> find untested functions in NotificationsService.swift` - `> add tests for the notification service` - `> add edge condition test cases` - `> run the new tests and fix failures` ## Pull Requests - `> summarize the changes I made` - `> create a pr` - `> enhance the PR description with security context` - `> add testing details` ## Documentation - `> find functions without proper JSDoc in auth.js` - `> add JSDoc comments` - `> improve docs with context and examples` - `> verify docs follow project standards` ## Images - Add via drag/drop, paste (ctrl+v), or file path - Examples: - `> What does this image show?` - `> Generate CSS to match this mockup` - `> Analyze this screenshot of an error` ## File & Directory References - Single file: `> Explain logic in @src/utils/auth.js` - Directory: `> What's the structure of @src/components?` - MCP resource: `> Show data from @github:repos/owner/repo/issues` ## Extended Thinking - Enable: `Tab` → toggle thinking mode or set `MAX_THINKING_TOKENS` env var - Prompts: - `> think hard about edge cases` - `> think deeply about architecture tradeoffs` ## Resume Sessions - Continue last session: `claude --continue` - Resume interactively: `claude --resume` - Non-interactive resume: `claude --continue --print "Continue my task"` ## Parallel Sessions with Git Worktrees ```bash git worktree add ../feature-a -b feature-a cd ../feature-a && claude ``` - Each worktree = isolated Claude instance - Remove with `git worktree remove ../feature-a` ## Unix Integration - **CI Linting** ```json "lint:claude": "claude -p 'you are a linter. check for typos vs main'" ``` - **Pipe Input/Output** ```bash cat build-error.txt | claude -p 'explain root cause' > output.txt ``` - **Output Formats** - `--output-format text` (default) - `--output-format json` - `--output-format stream-json` ## Custom Slash Commands - **Project Commands** ```bash mkdir -p .claude/commands echo "Analyze performance of this code" > .claude/commands/optimize.md ``` - Use with `/optimize` - **Arguments** ```bash echo "Fix issue #$ARGUMENTS" > .claude/commands/fix-issue.md ``` - Run `/fix-issue 123` - **Personal Commands** ```bash mkdir -p ~/.claude/commands echo "Review for security vulnerabilities" > ~/.claude/commands/security-review.md ``` ## Ask About Capabilities Examples: ```sh > how does Claude Code handle permissions? > what slash commands are available? > can Claude Code create pull requests? ``` --- **Reference:** [Claude Code GitHub Reference Implementation](https://github.com/anthropics/claude-code/tree/main/.devcontainer)