跪拜 Guibai
← All articles
Frontend · Claude · AI Programming

Claude Code in Practice: Structuring Projects, Rules, and Agent Workflows

By Lsx_ ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Terminal-native AI coding agents that modify files directly and follow team conventions through plain Markdown configs lower the barrier to consistent, automated development workflows. The CLAUDE.md and .claude/ directory pattern gives teams a version-controlled, shareable way to encode coding standards that every AI session respects, reducing style drift across contributors.

Summary

Claude Code operates inside the terminal, not a browser chat window. It scans the full project tree, understands file relationships, and executes a think-act-verify loop that mirrors how a human programmer works. Built-in tools handle file operations, shell commands, regex search, and LSP integration, while Sonnet and Opus models cover daily coding and complex architecture respectively.

The real leverage comes from project-level configuration. Running /init generates a CLAUDE.md file that acts as persistent context — tech stack, build commands, code style, and architectural conventions. A .claude/ directory then layers on modular rules, custom slash commands, reusable skills that auto-trigger on matching tasks, and sub-agents with scoped permissions for multi-role workflows like frontend review or backend analysis.

MCP servers extend Claude Code beyond the codebase, connecting it to GitHub, databases, Slack, and browsers through HTTP or local stdio transports. Configuration lives in .mcp.json at the project level and ~/.claude.json globally, with three permission modes — normal, plan, and auto-accept — controlling how autonomously the agent edits files.

Takeaways
Claude Code runs in the terminal and reads the entire project tree, not just the open file.
The agent loop follows think → act → verify, using built-in tools for file ops, shell commands, regex search, and LSP integration.
Sonnet handles daily coding with speed; Opus targets complex architecture and deep reasoning.
/init scans the project and generates CLAUDE.md, a persistent Markdown file that defines tech stack, commands, code style, and architecture.
CLAUDE.md is team-shared and version-controlled; CLAUDE.local.md holds personal preferences and should be gitignored.
A .claude/ directory organizes modular rules, custom slash commands, reusable skills, and sub-agents with scoped permissions.
Skills are Markdown-defined workflows that auto-trigger when Claude detects a matching task, such as writing unit tests or refactoring components.
Sub-agents act as specialized roles (frontend reviewer, backend analyst) with independent context windows, avoiding single-session bloat.
MCP servers connect Claude Code to external systems — GitHub, databases, Slack, browsers — via HTTP or local stdio transports.
Three permission modes (normal, plan, auto-accept) control how autonomously Claude edits files, with a deny list for dangerous commands like rm -rf or sudo.
Conclusions

Encoding team conventions in Markdown files rather than prompt templates makes AI behavior reproducible, auditable, and shareable across a Git repository — a lightweight alternative to heavier policy-as-code approaches.

The sub-agent pattern solves a real bottleneck: single-session context windows get overloaded on complex projects. Delegating to specialized agents with scoped permissions mirrors how human teams split work.

CLAUDE.md functions as a form of prompt-engineering-as-infrastructure. The quality of AI output becomes a function of how well the project's conventions are documented, not how clever the individual prompt is.

Running AI coding agents directly in the terminal with file-write access shifts the trust model from suggestion to execution. The permission modes and deny lists are not optional polish — they are the safety boundary.

Concepts & terms
Agent Loop
A think → act → verify cycle where the AI reasons about a task, executes tool calls (file edits, shell commands), checks the result, and iterates until the goal is met — mimicking a human developer's workflow.
CLAUDE.md
A Markdown file in the project root that serves as persistent context for Claude Code, specifying the tech stack, build commands, code style, architecture, and team conventions. Generated by /init and shared via version control.
MCP (Model Context Protocol)
Anthropic's open protocol that lets AI agents connect to external data sources and services — GitHub, databases, Slack, browsers — through standardized HTTP or local stdio transports, analogous to a USB-C interface for AI applications.
Sub-Agent
A specialized AI role defined in .claude/agents/ with its own context window and permission scope. The main Claude instance delegates tasks to sub-agents (e.g., frontend reviewer, backend analyst) to avoid context-window bloat on complex projects.
Skills (Claude Code)
Markdown-defined workflows stored in .claude/skills/ that Claude auto-invokes when it detects a matching task. Each skill specifies a step-by-step procedure — inspect, pattern-match, create, test, summarize — for repeatable development operations.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗