Drawing mode (d to exit, x to clear)
class: middle, title-slide # Claude Code Tutorial ## CDS DS 595 ### Siddharth Mishra-Sharma [smsharma.io/teaching/ds595-ai4science](https://smsharma.io/teaching/ds595-ai4science.html) --- # Demo project [github.com/hannorein/rebound](https://github.com/hannorein/rebound) .cmd[ .prompt[>] git clone https://github.com/hannorein/rebound.git ] --- # Install and login Install: .cmd[ .prompt[$] curl -fsSL https://claude.ai/install.sh | bash ] Start Claude Code and log in: .cmd[ .prompt[$] claude ] --- # Model selection and effort Switch models: .cmd[ .prompt[/]model ] Effort levels control how much the model reasons: .cmd[ .prompt[/]effort [low|medium|high|max|auto] ] --- # CLAUDE.md Project instructions that persist across sessions. Generate an initial one with: .cmd[ .prompt[/]init ] --- # Resuming sessions Resume a previous session: .cmd[ .prompt[$] claude .flag[--resume] ] Continue most recent session: .cmd[ .prompt[$] claude .flag[--continue] ] --- # Permission modes Shift + Enter to change permissions. .small[ | Mode | Behavior | |---|---| | **default** | Asks before file writes and shell commands | | **acceptEdits** | Auto-approves file edits, asks for shell | | **dontAsk** | Auto-approves (almost) everything | | **plan** | Read-only — analyzes and comes up with a plan | ] Can ask Claude to set fine-grained permissions, which live in `.claude/settings.json`: --- # Skills A skill is a reusable prompt packaged as a markdown file: ``` ~/.claude/skills/my-skill/SKILL.md ``` ```markdown --- name: simulate description: Set up and run a rebound simulation user_invocable: true --- Create a rebound N-body simulation with the given configuration. Always use SI units. Include visualization with matplotlib. ``` Invoke with: .cmd[ .prompt[/]simulate ] --- # Subagents Claude can spawn **child agents** that work independently: - Each gets its own context window - Can restrict which tools they have access to - Run in parallel for independent tasks - Results flow back to the parent Create a subagent with: .cmd[ .prompt[/]agents ] --- # Model Context Protocol (MCP) - MCP lets Claude call **external tools** — databases, APIs, custom scripts — through a standard interface. - Claude discovers the server's tools automatically and can call them like any built-in tool. - Designing an MCP server: just ask Claude to do it. - For a list of available existing MCP servers: .cmd[ .prompt[/]mcp ] --- # Context management **`/compact`** — Summarize the conversation to free up context. .cmd[ .prompt[/]compact ] **`/rewind`** — Undo to a previous point in the conversation .cmd[ .prompt[/]rewind ] `/usage` — See token usage and context window details. --- # Memories Claude remembers things across sessions: .cmd[ .prompt[>] remember that this project uses CGS units ] .cmd[ .prompt[/]memory ] Can also use a local MEMORY.md or CHANGELOG.md file to persist important info and track progress (my preferred method). --- # Git worktrees Claude can work in an **isolated copy** of your repo: .cmd[ .prompt[$] claude .flag[--worktree] ] (or, just ask Claude to set it up) --- # GitHub integration Claude works natively with `gh`: .cmd[ .prompt[>] create a PR for these changes ] .cmd[ .prompt[>] look at the comments on PR #42 and address them ] .cmd[ .prompt[>] check why CI is failing on this branch ] --- # `/batch` — parallel fan-out Run the same prompt across many files or configurations: .cmd[ .prompt[/]batch ] --- # Cloud sessions Run Claude Code in the browser (good if you don't need much local context): .big.center[ [claude.ai/code](https://claude.ai/code) ] --- # Remote control Start a session locally or on web, continue from your phone: .cmd[ .prompt[>] /remote ] - Push-based: your phone receives updates - Can approve/deny actions remotely - Great for long-running tasks --- # Long-running tasks — Ralph loop Every time the agent claims to have completed a task, ask it to promise that is really done, if not kick it back into context. Install with `/plugin`. .cmd[ /ralph-loop PROMPT [--max-iterations N] [--completion-promise TEXT] ] .center.width-30[]