m
Mars AI Operator Module 1 CLAUDE.md
~55 min · hands-on
Mars AI Operator · Module 1 · agentic coding

Contract with an agent. CLAUDE.md as your permanent signature.

CLAUDE.md — sening doimiy imzong

The first module of the Mars mentor course. Not about chatting with AI — it's about agentic coding tool: Claude Code in the terminal, MarsCode (our fork), and why one markdown file in a project changes everything.

Duration
55 min
Format
Text + terminal
Prereq
Terminal basics
Next
Module 4

2024 vs. 2026. A different category of tool.

2024 vs 2026 — boshqacha asbob
2024 · chat

You open ChatGPT. Copy a function. “Fix this bug.” You get code. Paste it into the editor. It doesn't work. Copy the error back. You do this five times. The context lives in your head, not with the model.

2026 · agent

In your project folder, you write claude. The agent itself reads 7 files, finds the bug, fixes it, and runs tests. You look at the diff and say “merge.”

These are different categories. Chat is a conversational partner. An agent is an executor with tools. And an executor must have a contract. This contract is called CLAUDE.md.

In this module, you'll learn what an agentic coding tool is, how it differs from chat, and how to write your first CLAUDE.md (at the user level and in a Mars project) to stop explaining to the agent who you are and who you're writing code for every session.

After this module, you will

Mental model. What an agentic coding tool is.

Agent loop · surfaces · MarsCode

Anthropic defines it in one phrase:

Verbatim · code.claude.com/docs/en/overview «Claude Code is an agentic coding tool that reads your codebase, edits files, runs commands, and integrates with your development tools. Available in your terminal, IDE, desktop app, and browser.»

The main difference from chat is loop of tool calls, not a single reply. You write the task. The model decides: "First, I'll read the file." It calls the Read tool. It gets the content. It thinks further. It decides: "Now I'll edit." It calls Edit. Then Bash for tests. And so on until the task is closed or it hits a question for you.

┌──────────────┐ │ You: task │ └──────┬───────┘ ▼ ┌──────────────┐ ┌──────────────┐ │ Claude │─────▶│ Read file │ │ (model) │ └──────┬───────┘ └──────▲───────┘ │ │ ▼ │ ┌──────────────┐ │◀────────────│ result │ │ └──────────────┘ │ ├──▶ Edit file ──▶ result ──┐ │ │ ├──▶ Bash (test) ──▶ result ──┤ │ │ └──▶ Read again ──▶ result ──┘ ▼ ┌──────────────┐ │ Response │ │ to you │ │ (diff/summary) │ └──────────────┘
↔ scroll if it doesn't fit

Each downward arrow is a new model call. For large tasks, there are dozens. You see this as a translucent stream in the TUI: Reading src/auth.py, Editing tests/test_login.py, Running pytest.

Surfaces — where the agent lives

Claude Code isn't tied to one window. It's the same configuration (CLAUDE.md, settings, MCP) across multiple surfaces. You choose based on the task, not habit.

Surface
When it's convenient
Installation
Terminal
Live coding with kids on a projector, scripts, Mars repos. Default for the course.
curl install
VS Code
Inline diffs, @-mentions, plan review right in the editor
extension
Desktop app
Multiple sessions side-by-side, visual diff, background tasks
.dmg / .exe
Web
claude.ai/code — no installation, for quick checks
browser
JetBrains
PyCharm / IntelliJ — if you're already working there
plugin
Key idea for a mentor One ~/.claude/CLAUDE.md works across all surfaces. One ./CLAUDE.md in the repo — too. You change the surface, the contract remains.

MarsCode — our fork

Mars maintains its own agent — MarsCode, fork of sst/opencode. It's an OpenAI-compatible API that routes through Mars Token Factory — our LLM-proxy with a Mars coins wallet. Why a fork: an Anthropic-only stack is expensive for mass rollout to students, MarsCode routes to cheaper models via Token Factory. We provide mentors with a balance.

In the MVP course, we teach on Claude Code (baseline, Anthropic documentation covers 100%). MarsCode is mentioned now, with a switch in Module 5 (when we build our own Skills and want to save money).

Codex (OpenAI), Antigravity (Google) — parallels of the same category. We don't teach them in the course, but mentors should hear the names. If a student asks "what about Codex" — it's the same tool use loop, different vendor.

Demo. Without CLAUDE.md and with it.

Bir xil so'rov — ikkita natija

Case: mentor Zukhra, Yunusobod location, Python group 7-9 years old, 6 children. She opens Claude Code in a repo with starter projects. She asks for the same thing. First without a contract, then with one.

Predict first Before looking at Scenario B — write down on paper: what exactly will change in the agent's output if it has a project CLAUDE.md? How many questions will it ask? In what style will it write the code? Write down your hypothesis — then we'll compare it with reality.
A · without CLAUDE.md
$ cd ~/mars-lessons/python-7-9 && claude# agent starts from a blank slate

> help me add another game
  about math for my students

Claude: I'm ready to help. A couple
of questions to understand the context:

  1. What is the age of the students?
  2. In what language are the explanations
     in the comments?
  3. Which libraries are allowed?
  4. How detailed should the comments be?
  5. Is OOP or procedural style allowed?

# 3 minutes of ping-pong in each session.
Without a contract — it's a fresh start every time. Zukhra opens Claude 8-10 times a week. That's 30 minutes for one "hello, it's me again".
B · with CLAUDE.md
$ cd ~/mars-lessons/python-7-9 && claude# agent reads ./CLAUDE.md automatically

> help me add another game
  about math for my students

Claude: I'll make a starter
"Guess the Number" in the project style:

  • pygame + random, no f-strings
  • variables in Russian-Latin script
  • a comment for every 2 lines
  • a short header "What this
    program does"

  I read 01-circle.py for style.
  Creating 06-guess-number.py.

Edit: 06-guess-number.py (+38)
Bash: python3 -m py_compile ✓

# 40 seconds until result.
With the contract, the agent immediately gets into the project spirit. No clarifications needed, because they are already written in the file.

Project CLAUDE.md for Python group 7-9 years old

Here's the file that's in Zukhra's repo. Copy it as a starter — it's one of three ready-made pre-build templates:

./CLAUDE.md · mars-lessons/python-7-9# Mars IT School — Python for group 7-9 years old
# Yunusobod branch, mentor Zukhra

## Who reads this code
- Children 7-9 years old, four of them seeing programming for the first time.
- Language of explanation: Russian. Uzbek Latin script is allowed
  in variable names if it helps (`tugma` instead of `button`).
- Terminology: do not use "function", "class", "loop"
  without explanation through an everyday analogy in a comment.

## Code Conventions
- **Every line is commented in Russian.** This is not production code,
  this is code for a lesson.
- Variable names — simple words or transliteration (`schyot`, not `score_counter`).
- Only `pygame` and `random`. Do not use f-strings,
  list comprehensions, dataclasses.
- The file always starts with a short comment
  "What this program does" in 1 line.

## Workflow
- Each file must be run via `python3 file.py` without arguments.
- Before commit — `python3 -m py_compile file.py` (syntax check).
- Do not edit `.solutions/` — it contains ready solutions for subsequent groups.
Principle A file is "everything I would repeat to an agent if they had amnesia". Children's age, language, conventions, prohibitions. Each rule is specific: not "write clearly," but "comment every 2 lines in Russian."

Different mentor — different contract

The same template "who reads / conventions / workflow" — but a different audience. Timur, Chilonzor branch, second year Python, preparing Olympiad participants 12-14. Compare with Zukhra's:

./CLAUDE.md · mars-lessons/python-olymp-12-14# Mars IT School — Python Olympiad for group 12-14
# Chilonzor branch, mentor Timur

## Who reads this code
- Children 12-14, second year Python, preparing for the Republican
  Olympiad in Informatics.
- Language of explanation: Russian. Variable names — English
  (Olympiad is in English, no point in teaching otherwise).
- Know: functions, loops, dictionaries, generators.
  DO NOT know: classes, dataclasses, async.

## Code Conventions
- Full typing: `def solve(n: int) -> list[int]:` — we teach
  how to read signatures.
- Complex algorithms — must have `doctest` or `assert`
   with an example from the problem statement.
- The solution must pass tests in `./tests/` (`pytest`).
- Each file starts with a docstring: problem, constraints,
  time/memory complexity.
- DO NOT use third-party libraries except `math`, `collections`,
  `itertools`, `heapq`, `bisect` — Olympiad set.

## Workflow
- Before commit — `pytest -q` (all green).
- Solutions in `./solutions/`, tests in `./tests/`.

Zukhra's — a ban on typing and list comprehensions, Timur's — mandatory typing. One template, two different contracts. The third template — Shahzod, Sergeli, React/TypeScript 15-17 — is located nearby in the file starters.md. Take one as an example and adapt it to your group.

Hierarchy. Managed, user, project, local.

To'rt qatlam · qaysi qaysisini bosadi

CLAUDE.md lives in several places. Each level has its own scope. They are loaded in order "from broad to narrow" and concatenated into the context. A narrower scope supplements the previous one, and in case of conflict, it usually wins — because it appears last in the context and the model sees it as more current.

Managedorg policy
/Library/Application Support/ClaudeCode/CLAUDE.md (macOS), /etc/claude-code/CLAUDE.md (Linux). Set by IT/DevOps. Applies to everyone. For Mars MVP — empty, nothing here yet.
Userabout you
~/.claude/CLAUDE.md · your personal preferences for all projects. Working language, how you like the agent to talk to you, what you do most often.
Projectabout the project
./CLAUDE.md or ./.claude/CLAUDE.md · team agreement. Stored in git. Children's age, stack conventions, library prohibitions. Most important for the mentor.
Localonly you
./CLAUDE.local.md · personal notes for a specific project. In .gitignore. Sandbox-URL, test data, personal reminders.
Priority example In ~/.claude/CLAUDE.md it says "reply in English." In the ./CLAUDE.md project, it says "reply in Russian, explaining to children." Project is closer → Russian usually wins — it's the last in the context. Anthropic honestly warns: with conflicting instructions, Claude may choose arbitrarily; there's no guarantee of strict compliance. If it's important, write non-conflicting rules.

@-import: pulling in other files

CLAUDE.md can include other files using the @path syntax. The recursion depth is up to 4 levels. This is handy when you need to pull in a README, package.json, conventions from another repo, or personal preferences from home.

./CLAUDE.md · fragment# Project overview
See @README.md for context and @package.json for npm scripts.

# Git workflow
- follow @docs/git-instructions.md
- my personal preferences: @~/.claude/my-mars-preferences.md

AGENTS.md — a common file for different agents

Claude Code reads CLAUDE.md, not AGENTS.md. But AGENTS.md is a format for various AI agents (as of 2026 — Cursor, opencode, MarsCode, etc., needs re-verification): one file can configure multiple tools. If there's already an AGENTS.md in the repo, we create a thin CLAUDE.md on top via import:

./CLAUDE.md · on top of AGENTS.md@AGENTS.md

## Claude-specific
- Use plan mode for changes under `src/billing/`.

Then Claude reads AGENTS.md as part of its contract and adds its own nuances. For Mars: while the MarsCode-fork is in active development — write AGENTS.md and make CLAUDE.md → @AGENTS.md, so both tools look at the same file.

An alternative is a symlink (ln -s AGENTS.md CLAUDE.md). It works, but on Windows, it requires Developer Mode. Import is more reliable.

Auto memory — what Claude writes itself

Additionally, the agent keeps its own notes in ~/.claude/projects/<project>/memory/MEMORY.md. Build commands, debug insights, patterns it noticed while working with you. The first 200 lines (or 25KB) are loaded automatically each session.

This is a supplement, not a replacement for CLAUDE.md. CLAUDE.md is what you want the agent to always know. Auto memory is what it itself learned during its work and decided to remember. The command /memory shows both and allows you to open them for editing.

Exercise. Try it today, 30 minutes.

Bugun o'zing qil — 30 daqiqa

Four parts. Do it manually in the terminal, don't just read it as theory. After this, you'll have a working user+project CLAUDE.md pair and a verified /memory.

01
Installation and verification

On Mac/Linux: curl -fsSL https://claude.ai/install.sh | bash. On Windows PowerShell: irm https://claude.ai/install.ps1 | iex. To check: claude --version. The first launch will ask for a login.

~ 5 min
02
User-level: ~/.claude/CLAUDE.md

Create a file, copy the template below, and customize it. This is what Claude knows about you in any project.

~/.claude/CLAUDE.md# About me
I am a mentor at Mars IT School, point <X>,
I teach <stack> for ages <Y>.
Working language: Russian. English for technical terms.

# Agent interaction style
- Explain the plan to me before editing files
  (use plan mode when appropriate)
- If you're unsure about an API/library — ask, don't invent
- When writing code that will go to children —
  short lines, simple names, comments in Russian
- Always show git diff before committing, don't commit yourself

# What I usually do
- Prepare starter projects for classes
- Check students' code
- Write internal scripts for Mars
~ 10 min
03
Project-level: ./CLAUDE.md in one repo

Choose one educational repo. Take one of the three ready-made templates in starters.md (Zukhra-Python-7-9, Timur-Python-Olympus-12-14, Shakhzod-React-15-17) as an example — copy-paste and adapt it to your group. Minimum three sections: “who reads this code”, “conventions”, “workflow”. Size — up to 200 lines, otherwise adequacy decreases.

Alternatively — the command /init in the repo: Claude Code will go through the code itself and generate an initial CLAUDE.md (and if the repo already has AGENTS.md — it will take its content into account).

~ 15 min
04
Test via /memory

Run claude in the same folder. In the session, type /memory — you should see both files in the list. If the user file didn't appear — check the path (it's exactly ~/.claude/CLAUDE.md, not ~/.claude/Claude.md).

Give a simple request: “add a greeting function”. Make sure the agent writes in the spirit of CLAUDE.md (language, style, prohibitions). If not — do a /memory, open the files, see what got in there.

~ 5 min
Common mistake Creating a 500-line CLAUDE.md “just in case”. Doesn't work. Anthropic documentation explicitly states: the goal is up to 200 lines, otherwise the model follows instructions less effectively. If it grows too large — move specifics to .claude/rules/ (path-scoped) or to Agent Skill (Module 5).

Quiz. Check what went in.

O'zingni tekshir · 3 ta savol
Before checking knowledge · 30 seconds 1) What was the most unexpected thing for you in this module?
2) Where does your habit from ChatGPT (or another chat) contradict this?
Think aloud or write it down — this reinforces learning better than any quiz.
Question 01 · scenario

Your ~/.claude/CLAUDE.md says “write in English.” The ./CLAUDE.md learning repo says “write in Russian, we’re explaining to kids.” You run claude in this folder and ask to add a function. In what language will the agent write comments?

aIn English — the user-level is broader and takes precedence.
bIn Russian — project is closer to the working folder and appears last in the context.
cIt will explicitly ask which language to choose for this repo.
b. Files are loaded from broad to narrow: managed → user → project → local — and concatenated into the context. Project is added after user, so in case of conflict, what’s closer to the launch location usually wins. Anthropic honestly states: this isn't an enforced rule; with contradictory instructions, Claude might choose arbitrarily. So it’s better to keep rules non-conflicting.
Question 02 · scenario

Two weeks ago, you created a ./CLAUDE.md in the learning repo with the rule “do not use f-strings.” You open the repo again, type claude. Which file with your conventions will automatically load at the start of the session?

aNone — you need to manually type “read CLAUDE.md” in the first message.
bOnly ~/.claude/CLAUDE.md — the project file is pulled upon request.
cBoth: ~/.claude/CLAUDE.md and ./CLAUDE.md — they are concatenated into the session’s starting context.
c. This is the whole point of a “contract”: you write the file once, then Claude Code, with each launch, traverses the tree upwards from the root and pulls CLAUDE.md / CLAUDE.local.md. The command /memory in the session shows exactly what loaded — this is the first check if it seems like the agent “forgot” your rules.
Question 03 · scenario

The Mars repo already contains AGENTS.md — it has general conventions for MarsCode and Cursor. You want to add one line specifically for Claude Code: “use plan mode before making edits in src/billing/.” What should you do?

aCopy the entire AGENTS.md into a new CLAUDE.md and add the line — Claude Code cannot read AGENTS.md.
bCreate a thin CLAUDE.md with the first line @AGENTS.md and the Claude-specific rule below — both tools look at the same source.
cRename AGENTS.md to CLAUDE.md and forget about other agents — we have one standard.
b. Claude Code indeed only reads CLAUDE.md, but the @AGENTS.md syntax pulls content via import — without duplication. Option (a) works but creates two copies of the same rules, which quickly diverge. Option (c) breaks MarsCode and Cursor, which specifically look for AGENTS.md. An alternative to import is a symlink ln -s AGENTS.md CLAUDE.md, but on Windows, this requires Developer Mode.
Cheat Sheet All Claude Code slash commands on one page — for printing and quick reference: _lib/claude-code-cheatsheet.md.

What's Next. Module 4 — context engineering.

Keyingisi — kontekstni boshqarish

You now have a permanent signature — the agent in any Mars project knows who you are and for whom you’re writing. The next mandatory module is the fourth one (modules 2-3 come after feedback): about working memory and context engineering. What is /compact, why an agent "gets dumber" by the evening of a long session, and how to use sub-agents as a way to isolate context. This is the module the course exists for.

Modules 2-3 (Delegation × NTP, Description × Knowledge) and Module 5 (Your Own Sub-agents and Agent Skills) — after pilot feedback from the first mentors.

How was the module overall?