Open6
Claude Code tutorial

話題になってる Claude Code の Tutorial をやってみる

利用ケース
- プロジェクトに新規でアサインされたとき
- コードベースの概要を聞いてみる
give me an overview of this codebase
- その他の質問
explain the main architecture patterns used here
what are the key data models?
how is authentication handled?
- コードベースの概要を聞いてみる
- 特定の機能や特徴を示すコードの場所が必要な時
find the files that handle user authentication
how do these authentication files work together?
trace the login process from front-end to database
- その他、いろいろパターンがある
- Extended thinking
-
I need to implement a new authentication system using OAuth2 for our API. Think deeply about the best approach for implementing this in our codebase.
- コードベースから情報を集めて、提示してくれるっぽい
- 自分で login.py 的なファイルを探して、既存の実装を見に行ってくれてる
-
⏺ Update Todos
⎿ ☐ 現在の認証システムの分析(JWT実装の確認)
☐ OAuth2プロバイダーの選定と設定(Google、GitHub等)
☐ バックエンドOAuth2エンドポイントの実装
☐ フロントエンドOAuth2フローの実装
☐ テストとセキュリティ検証
☐ 既存JWT認証との互換性維持
現在の認証システムを分析した結果、以下の実装アプローチを提案します:
🏗️ アーキテクチャ設計
ハイブリッド認証システムを構築し、既存のJWT認証とOAuth2を並行して動作させます:
1. 既存のメール/パスワード認証:そのまま維持
2. OAuth2ソーシャル認証:新規追加(Google、GitHub等)
3. 統一されたJWTトークン:両方の認証方式で同じトークン形式を使用
# 具体的な実装例があがる
🔒 セキュリティ考慮事項
1. PKCE (Proof Key for Code Exchange):公開クライアントのセキュリティ強化
2. State パラメータ:CSRF攻撃防止
3. Nonce:リプレイ攻撃防止
4. スコープ制限:必要最小限の権限のみ要求
🔄 移行戦略
1. 段階的リリース:
- Phase 1: Google OAuth2のみ実装
- Phase 2: GitHub、Microsoft追加
- Phase 3: 既存ユーザーのアカウント連携
2. 既存ユーザーへの影響なし:
- 現在のメール/パスワード認証は継続利用可能
- OAuth2は追加オプションとして提供
3. アカウント連携:
- 同じメールアドレスの場合、自動的にアカウントを統合
- ユーザー設定画面で複数の認証方法を管理可能
この実装により、ユーザーエクスペリエンスを向上させながら、セキュアで拡張可能な
認証システムを構築できます。
- extended thinking とは?
- https://docs.anthropic.com/ja/docs/build-with-claude/extended-thinking
- 拡張思考と翻訳されてる
-
拡張思考はClaudeに複雑なタスクのための強化された推論能力を提供し、最終的な回答を提供する前に、段階的な思考プロセスに対してさまざまなレベルの透明性を提供します。
-
- 以下のような複雑なタスクに威力を発揮する
- Planning complex architectural changes
- Debugging intricate issues
- Creating implementation plans for new features
- Understanding complex codebases
- Evaluating tradeoffs between different approaches
- "think" とか "think more" , “think a lot”, “think harder”, or “think longer” をトリガーにして動くっぽい
- Tips: https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/extended-thinking-tips
- Claude Code で次のセッションで続きの内容が欲しい時
-
claude --continue
- 追加のプロンプトなしで続きを表示する
-
- Claude Code 上の会話は local machine に保存される
- 直近の会話にアクセスする:
--continue
- 特定の過去の会話にアクセスする:
--resume
- 直近の会話にアクセスする:
# Continue most recent conversation
claude --continue
# Continue most recent conversation with a specific prompt
claude --continue --print "Show me our progress"
# Show conversation picker
claude --resume
# Continue most recent conversation in non-interactive mode
claude --continue --print "Run the tests again"

-
カスタムコマンドの作成方法
-
.claude/commands/
にコマンド名.md
ファイルを置く - そのファイルにコマンドの内容を書く
-
/project:コマンド名
でコマンドが出現
-
- サフディレクトリ作って、そこに置くと : で階層化できる
-
.claude/commands/frontend/component.md
becomes/project:frontend:component
-
-
$ARGUMENTS
で引数を取れる- ex: fix-issue.md を作成して、
/project:fix-issue 123
みたいな123
を指定できるようになる -
echo "Find and fix issue #$ARGUMENTS. Follow these steps: 1. Understand the issue described in the ticket 2. Locate the relevant code in our codebase 3. Implement a solution that addresses the root cause 4. Add appropriate tests 5. Prepare a concise PR description" > .claude/commands/fix-issue.md
- ex: fix-issue.md を作成して、
-
mkdir -p ~/.claude/commands
にコマンドを置くことで自分のコマンドを作れる- このコマンドはすべてのプロジェクトから使える
-
/user:xxx
で使える - これはよさそう

-
Use Claude as a unix-style utility
- これよさそう
- Run parallel Claude Code sessions with Git worktreeshttps://docs.anthropic.com/en/docs/claude-code/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees
- よさそうな気がするが、いまいち使い方が思いつかない
- 1リポジトリに複数機能持ってるとかで、ディレクトリ単位で分かれてるなら使える?
-
claude -p 'analyze this code for bugs' --output-format json
claude -p 'summarize this data' --output-format text
で出力形式を選択できる- Use --output-format text for simple integrations where you just need Claude’s response
- Use --output-format json when you need the full conversation log
- Use --output-format stream-json for real-time output of each conversation turn

Claude ode Tips
Plan mode: タスク実行前に実行プランを立ててくれる
- Shift + Tab + Tab
/clear: 以前のコンテキストを削除
- コンテキストは上限がある
-
/compact
でまとめることもできる - 新しいタスクにしたいときは
/clear
で綺麗にする

-
「Claude Code」導入をめっちゃスムーズにする「ドキュメントの下地」を作るプロンプト
- ドキュメントを作成するのは良い