Claude Code: Claude Code First Use

Last updated: 2026-08-31

Your first time using Claude Code is like hiring a powerful assistant — you need to know how to give instructions, confirm operations, and course-correct.

💡 Tip: For your first use, practice on a simple project. Claude Code modifies files; although changes can be reverted, building safe habits matters.

📋 Prerequisites: Chapter 3 - API Configuration and Model Selection

1. What You'll Learn


2. Launching Your First Session

(1) Preparation

BASH
# 1. Create a practice project
mkdir my-first-claude && cd my-first-claude
git init

# 2. Create a simple file
echo 'function hello() { return "Hello"; }' > index.js

# 3. Launch Claude Code
claude

(2) Interactive Interface

TEXT 📖 Display only
╭─────────────────────────────────────────╮
│  Claude Code                             │
│  Model: claude-sonnet-4-20250514         │
│  Project: my-first-claude                │
╰─────────────────────────────────────────╯

> █ (type your instruction)

▶ Example 1: First Conversation

TEXT 📖 Display only
> Hello, please look at this project

Claude: Let me check the project structure and file contents...

  📁 Project structure:
  - index.js

  📄 index.js:
  ```javascript
  function hello() { return "Hello"; }

This is a simple JavaScript project with just one hello function.

Add a goodbye function and unit tests

Claude: I'll add a goodbye function and test file.

→ Reading index.js → Modifying index.js (adding goodbye function) → Creating index.test.js → Running: npm test ✅ 2 tests passed

Done:


---

## 3. Operation Confirmation Mechanism

### (1) Permission Approval Flow

Claude Code requests confirmation for sensitive operations:

| Operation Type | Default Behavior | Example |
|:--------------|:----------------|:--------|
| **Read file** | Auto-execute | Read index.js |
| **Create file** | Request confirmation | Create new file test.js |
| **Modify file** | Request confirmation | Modify existing file |
| **Run command** | Request confirmation | Execute npm test |
| **Delete file** | Request confirmation | Delete old file |

### (2) Confirmation Options

```text
Claude wants to edit index.js:
  - Add goodbye() function after hello()
  - Add module.exports

  Allow? (y/n/a/e)
  y = yes (this time)
  n = no
  a = always allow edits to this file
  e = edit the change before applying

▶ Example 2: Handling Permission Confirmations

TEXT 📖 Display only
> Refactor project to TypeScript

Claude: I'll perform the following:
  1. Create tsconfig.json
  2. Convert index.js to index.ts
  3. Add type definitions
  4. Update package.json

  Allow creating tsconfig.json? [y/n/a/e] y
  ✅ Created tsconfig.json

  Allow editing index.js → index.ts? [y/n/a/e] a
  ✅ Always allowing edits to index.ts

  Allow running: npm install typescript --save-dev? [y/n/a/e] y
  ✅ Installed typescript

  All changes applied successfully!

4. Viewing and Reverting Changes

(1) View Changes

BASH
# View current session file changes
claude /diff

# View git diff
git diff

# View specific file changes
git diff index.js

(2) Revert Operations

BASH
# Revert all changes (git-based)
git checkout .
git clean -fd

# Revert single file
git checkout -- index.js

# View change history
git log --oneline -5

▶ Example 3: Reverting Mistaken Operations

TEXT 📖 Display only
> Rename all functions

Claude: Renaming functions...
  → hello → greet
  → goodbye → farewell
  → Modified 3 files

# Alice finds the rename doesn't match expectations
# Use git to revert

$ git diff --stat
  index.js       | 6 +++---
  index.test.js  | 8 ++++----
  utils.js       | 4 ++--

$ git checkout .
# All changes reverted ✓

5. Best Practices for First Use

(1) Safety Habits Checklist

Habit Reason Practice
git init first Easy revert Manage every project with git
Small commits Reduce revert loss Commit after each feature
Read confirmations Avoid mistakes Don't blindly press y
Use /diff Understand changes Check after major operations
Avoid production Reduce risk Practice on test projects first

(2) Task Description Tips

TEXT 📖 Display only
# Bad description
> Help me change some code

# Good description
> In src/auth/jwt.ts, add token refresh logic,
> set expiry to 7 days, write corresponding unit tests

# Better description (with constraints)
> Refactor UserService query methods:
> 1. Use Repository pattern instead of direct SQL
> 2. Add pagination support (default 20 per page)
> 3. Write integration tests
> 4. Don't modify the interface signatures

6. Comprehensive Example: Complete First Experience

BASH
# Alice's first Claude Code experience

# 1. Prepare project
mkdir todo-app && cd todo-app
git init
npm init -y

# 2. Launch Claude Code
claude "Create a simple Node.js TODO app:
1. Support add, delete, list tasks
2. Store data in JSON file
3. Include complete unit tests
4. Use ES Module syntax"

# Claude Code work process:
# → Reading package.json
# → Creating src/todo.js (core TODO logic)
# → Creating src/storage.js (JSON file storage)
# → Creating src/index.js (CLI entry)
# → Creating tests/todo.test.js (unit tests)
# → Running: npm test → 8/8 passed ✓
# → Creating README.md

# 3. Check results
git add -A && git commit -m "feat: initial todo app by Claude Code"

# 4. Add more requirements
claude "Add task priority feature (high/medium/low), update tests"

# Claude Code continues iterating...

❓ FAQ

Q First launch is slow, what to do?
A First launch loads project context; large projects may take 10-30 seconds. Subsequent interactions are faster.
Q Pressed wrong confirmation, what now?
A Immediately use git checkout . to revert, or tell Claude Code "revert the last change".
Q Claude Code broke my code, what to do?
A That's what git is for. git diff to see changes, git checkout . to revert. Always use under git management.
Q Every confirmation is annoying, can it be automatic?
A Yes. Choose a (always allow) for specific files, or configure permission policies in CLAUDE.md.
Q Can I undo an entire session's changes?
A Yes. If you had a git commit before the session, git reset --soft HEAD~1 reverts to pre-session state.
Q How to make Claude Code more obedient?
A Be specific with instructions. State clearly what to do, what not to do, and constraints. Vague instructions lead to vague results.

📖 Summary


📝 Exercises

  1. Basic (⭐): Create an empty project, use Claude Code to generate a Hello World app, confirm it runs.
  2. Intermediate (⭐⭐): Have Claude Code add a feature, then use /diff to view changes, manually revert one file's modification.
  3. Advanced (⭐⭐⭐): Give Claude Code one vague and one precise instruction, compare result differences, summarize task description best practices.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏