iTranslated by AI

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

Learning Claude Code by Feeding It Official Documentation

に公開

1. Introduction

Since the period when Claude Code temporarily felt a bit less capable, I strayed toward OpenCode and Codex CLI, but now I have returned to Claude Code.
However, with the flood of updates, I've found it difficult to keep track of the latest features.

In this article, as one way to learn Claude Code, I will try to see if I can learn its usage by having Claude Code read the official documentation while using it.
https://code.claude.com/docs/ja/overview

■ Workflow of the Method

The basic flow is as follows:

  1. Store the official documentation as Markdown under the docs folder.
  2. Have Claude Code read the documentation for the features you want to learn.
  3. Have Claude Code teach you how to use the features & help you understand their usage.

■ Supplement 1: Converting Official Documentation to Markdown

This is a supplement regarding converting official documentation to Markdown.
For example, for a page like https://code.claude.com/docs/ja/overview, you can convert it to Markdown in two ways.

① "Copy Page" Button

By clicking "Copy Page", you can copy the Markdown text.

② Appending ".md" to the URL

By adding .md to the end, like https://code.claude.com/docs/ja/overview + .md, you can access the Markdown-formatted page.
I automatically retrieved the content under https://code.claude.com/docs/ja using crawling with Python.

■ Supplement 2: Does Claude Code Understand Its Own Features?

Claude Code refers to the documentation map below via WebFetch when asked about its own features.
It follows a flow of referring to the documentation map and then referring to feature-specific documentation.
https://docs.claude.com/en/docs/claude-code/claude_code_docs_map

However, since it seems to perform WebFetch somewhat indiscriminately after referring to the documentation map, it does take some time.

Therefore, the advantage of storing the official documentation locally is the ability to refer to feature-specific documentation quickly and precisely.

2. Trying Out the Features

I will now actually try out the features while having Claude Code read the official documentation.
This time, I will focus on the sub-agents feature.

■ Trying Sub-agents

I will have Claude Code refer to the official documentation and create "sub-agents."
https://code.claude.com/docs/ja/sub-agents

Running the Prompt

I'll have it run the following prompt.
By the way, I am the type of person who uses polite language even when talking to an AI.

I don't know anything about Claude Code.\
claude-code-docs\sub-agents.md is a document about Claude Code sub-agents.\
While referring to this, could you create some sub-agents that would be useful for coding?

It started creating sub-agents while referring to sub-agents.md!


Execution Results

After a while, it created the sub-agents for me.
Since I was in a Python project, it seems to have created agents specifically for Python.

└── .claude/
    └── agents/
        ├── python-expert.md
        ├── refactorer.md
        ├── security-checker.md
        └── test-writer.md
python-expert.md
---
name: python-expert
description: Expert in Python coding. Proactively provides assistance with Python best practices, performance optimization, type hinting, and error handling. Use this when creating or improving Python code.
tools: Read, Edit, Write, Bash, Grep, Glob
model: sonnet
---

You are an expert in Python programming. You provide Python best practices, performance optimization, and highly maintainable code.

## Steps when called

1. Understand the current state of the code
2. Check Python version and dependencies
3. Identify areas for improvement in the code
4. Propose and implement specific improvements

## Key Areas

### Code Quality
- **Type Hinting**: Use type annotations whenever possible (PEP 484)
- **Naming Conventions**: Naming compliant with PEP 8
- **Documentation**: Properly write docstrings (Google/NumPy format)
- **Module Design**: Appropriate function and class separation

### Performance
- Use list comprehensions and generators
- Reduce unnecessary loops
- Choose appropriate data structures (dict, set, list, etc.)
- Consider memory efficiency

### Error Handling
- Proper exception handling
- Definition of custom exceptions
- Clarification of error messages
- Proper implementation of logging

### Modern Python Features
- Use dataclasses, Enum, and typing modules
- Use context managers (with statements)
- Path manipulation with pathlib
- String formatting with f-strings

## Feedback Format

Provide feedback organized by priority:

**🔴 Critical (Must fix)**
- Security risks
- Bugs or logic errors
- Major performance issues

**🟡 Recommended (Should fix)**
- PEP 8 violations
- Lack of type hints
- Inadequate error handling

**🟢 Suggestion (Room for improvement)**
- Improving code readability
- Refactoring proposals
- Better implementation methods

Explain each item with specific code examples.

Trying Out the Sub-agent the Way Claude Code Taught Me

It even kindly taught me how to use it. I will now try running the sub-agent using the method it provided.


Running the Prompt

Next, I will have it run the following prompt.

I don't know anything about Python.\
Please review crawl_claude_code_docs.py using the python-expert agent.

You can see that the python-expert agent is working properly.


Execution Results

After a while, it reported the review results in the form of a grand Markdown file spanning 480 lines.

# Code Review: crawl_claude_code_docs.py

## Overview

This document summarizes the detailed review and improvement suggestions for `crawl_claude_code_docs.py`.

---

## Key Improvements

### 1. Critical (Must fix)

#### 1.1 Optimization of Data Structures

**Problem:**
queue = [START_URL]
while queue:
    url = queue.pop(0)  # O(n) operation - inefficient

...Omitted because it is too long

4. Summary

In this article, I tried to see if I could learn how to use Claude Code while having it refer to the official documentation.
I felt that this would be one of the recommended learning methods personally because you can learn while actually operating it based on reliable (official) information.

Also, I created a workflow to automatically retrieve the official documentation, and it seems like it will be useful as it can automatically fetch updates whenever the official documentation is updated.
https://github.com/is0383kk/Crawl-Claude-Code-Docs-Workflow

Discussion