iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🤖

Claude Code Quick Start

に公開4件

Compiled for a workshop. It is recommended to refer to the official documentation if possible, but this material focuses on the essentials to get started quickly.

https://docs.anthropic.com/en/docs/welcome

Note that Claude Code is developed using Claude Code itself and is updated at a terrifying speed. This material will become outdated quickly.

Account contracts, etc., are omitted.

Installation and Execution

$ npm i -g @anthropic-ai/claude-code
$ claude
# Initial setup such as Token

Session Management

The simplest usage

$ claude
> hello
Hello! How can I help you?
# Exit with Ctrl-C

The next time you start, this conversation is forgotten, but you can return to the most recent session with -c.

$ claude -c

To return to a session other than the most recent one, use -r (--resume).

$ claude -r
    Modified    Created     # Messages Summary
❯ 1. 1m ago      1m ago               2 hello

Security

You can specify default permissions in .claude/settings.json.

https://docs.anthropic.com/en/docs/claude-code/settings

{
  "permissions": {
    "allow": ["Bash(npm run lint)", "Bash(npm run test:*)", "Read(~/.zshrc)"],
    "deny": ["Bash(curl:*)"]
  }
}

In a session, use <Shift+TAB> to switch modes.

  • ⏵⏵ auto-accept edits on: A mode that automatically accepts commands that are explicitly allowed or have been allowed once.
  • ⏸ plan mode on : A mode to design in Readonly without editing files.
  • Bypassing Permissions: A mode that allows everything with --allow-dangerously-permissions. Dangerous

It is recommended to use the default initially, and once you get used to it, control permissions and automate within an acceptable range.

Some people have run rm -rf ~/.

Commonly Used Commands

/model: Specify a model. By default, it switches between Sonnet and Opus, but you can also specify only Opus. Note that the context consumption speed is about 5 times faster.

/clear: Resets the conversation history. Use it when the AI starts going wild after consuming strange logs.

/compact: Summarizes the conversation in that session and compresses the context.
It activates automatically when the history becomes long, so it's a command you'll use frequently, or unfortunately, be forced to use.

  /compact
      Clear conversation history but keep a summary in context. Optional:
       /compact [instructions for summarization]

@/: You can autocomplete file names.

! pwd: With !, the command is executed directly without involving the AI. Use it to confirm before giving instructions when the AI is running wild with cd.

You can also dynamically append to CLAUDE.md by inputting with # inside Claude.

# Follow t-wada's TDD

Also, placing .claude/commands/custom-command.md allows you to create custom commands usable within Claude.

An example of making my own gemini cli perform searches.

## Gemini Search

`gemini` is google gemini cli. **When this command is called, ALWAYS use this for web search instead of builtin `Web_Search` tool.**

When web search is needed, you MUST use `gemini --prompt` via Task Tool.

Run web search via Task Tool with `gemini --prompt 'WebSearch: $ARGUMENTS'`

Run

```bash
gemini --prompt 'WebSearch: $ARGUMENTS'
```

think, think hard, ultrathink. Including these phrases in the prompt activates Reasoning mode, causing the AI to self-iterate on its output and think deeply. It consumes more tokens and execution time, so you don't need to use it all the time. Use it when you absolutely cannot fix a bug.

Memory Management: CLAUDE.md

  • ~/.claude/CLAUDE.md: Always loaded.
    • I only have this: Please respond to the user in Japanese.
  • ./CLAUDE.md: Loaded in the directory where Claude is executed.

Configuration example

This project uses npm, typescript, and vitest

You can check the currently loaded memory by executing /memory.

/memory

Memory Files
 L user: ~/.claude/CLAUDE.md
 L project: ~/mizchi/ai-coding-guide/examples/07-real-world/CLAUDE.md

Learn more: https://docs.anthropic.com/en/docs/claude-code/memory

╭─────────────────────────────────────────────────────────────────────────╮
│                                                                         │
│ Select memory to edit:                                                  │
│                                                                         │
│  ❯ 1. Project memory          Checked in at ./CLAUDE.md                 │
│    2. Project memory (local)  Gitignored in ./CLAUDE.local.md           │
│    3. User memory             Saved in ~/.claude/CLAUDE.md              │
│                                                                         │
│ Memory file does not exist yet. [Enter] to create ./CLAUDE.md.          │
│                                                                         │
╰─────────────────────────────────────────────────────────────────────────╯

MCP Settings

Add tools that the AI can use. Manage with claude mcp command.

$ claude mcp add playwright-mcp npx -- -y @playwright/mcp@latest

Alternatively, .mcp.json exists, but if projects are already managed in ~/claude.json, they may or may not be loaded.

{
  "mcpServers": {
    "readability": {
      "command": "npx",
      "args": ["-y", "@mizchi/readability", "--mcp"]
    }
  }
}

You can check running tools with /mcp.

/mcp
╭─────────────────────────────────────────────────────────────────────────╮
│ Manage MCP servers                                                      │
│                                                                         │
│ ❯ 1. playwright-mcp  ✔ connected · Enter to view details                │
╰─────────────────────────────────────────────────────────────────────────╯
   Esc to exit

Rate Limit Subjective Experience

If you use it heavily, you will hit rate limits.

Probably, Approaching Usage Limit... is displayed at half of the hourly limit, but there is still room. When it shows something like You will reset at 11pm/Asia, it's almost at the limit.

With my $200 plan, using 3 parallel sessions, I'm stopped for about 1 hour out of 5 hours. I spend that time on code reading or breaks.

Conclusion

This material does not explain how to write prompts. Please learn that while using it.

Discussion

あきらきあきらき

$ npm i -g @anthropic/claude-code

公式ドキュメントでは npm install -g @anthropic-ai/claude-code となっているようです
https://docs.anthropic.com/ja/docs/claude-code/overview#基本的な使用方法

3
あきらきあきらき

説明不足ですみません、@anthropic/claude-code と @anthropic-ai/claude-code の違いについてコメントしたつもりでした

8
philoludumphiloludum

なるほど、こちらこそ早とちりすみません! タイポっぽいですね。