A2 — CLI Workflow Patterns
← A1 — CLI Intro · Track A: CLI Power User — Stop 2
⏱ Time estimate: 1-2 weeks (~8-15 hours)
📋 Chapter structure: Learning goals → Entry conditions → Required reading → Hands-on exercises → Curated Projects → Self-check 🔑 Key terms: see
resources/glossary.en.md5 (CLAUDE.md / slash command / SKILL.md / plugin / portable prompt)
After installing a CLI and running first tasks, the next question: how do I make the CLI consistent, repeatable, shareable? This stop covers workflow patterns — turning "I retype the same prompt every time" into "set it up once, the CLI does the right thing automatically".
📌 Learning Goals
- Write a production-grade
CLAUDE.md/AGENTS.md— the minimum production-grade shape is (1) role + (2) project context + (3) forbidden actions + (4) test commands + (5) delivery format. In practice, 30-50 lines can usually cover those 5 things; beyond 50 lines, split the file - Design repeatable slash commands / custom prompts
- Decompose multi-step tasks into ones the CLI can execute end-to-end
- Design prompts portable across CLIs
📚 Required Reading
- Anthropic — CLAUDE.md best practices ⭐
- Stage 2 — Prompt Engineering — workflow design and prompt design are two sides of the same coin
- Stage 5.1 — Claude Code Basics — slash command details
resources/cli-agents-guide.en.md"Cross-CLI portable prompt patterns" — portable prompt principles
🛠 Hands-on Exercises
Exercise CLI-5: Write production CLAUDE.md
Your CLAUDE.md should at minimum contain:
- Persona: "You're a senior Python engineer / academic writing assistant / etc."
- Repo context: what project, what stack, what conventions
- Don't do: don't touch main, don't move secrets, don't auto-commit
- How to do things: plan first, run tests before commit, use type hints
- Common commands: how to run tests, lint, deploy
Commit it to git. Next time a teammate clones the repo, their Claude Code auto-loads your conventions.
Exercise CLI-6: First slash command
Write .claude/commands/review.md (or your CLI's equivalent):
---
name: review
description: Review staged changes for security + style
---
Run this flow:
1. `git diff --cached` to get staged changes
2. Look for: hard-coded secrets, SQL injection, type errors
3. Check against the style rules in CLAUDE.md
4. Output: PASS / or list of specific changes neededAfter this, every /review runs the same flow.
Exercise CLI-7: Multi-step task decomposition
Give the CLI a complex task ("translate these 50 markdown files to English + add frontmatter + move to en/ subdirectory").
- First time: throw the whole task at it → observe how it does it, where it errs
- Second time: pre-decompose into 5 sub-tasks, give them one by one → observe the difference
- Lesson: the CLI is like you — too-big tasks need decomposition; too-small tasks lead to over-orchestration
⭐ Advanced note: Claude Code native multi-agent mechanisms (read this one sentence for now; no need to expand it in A2): the manual sub-task splitting in CLI-7 can be automated with Claude Code's Subagent / Agent team / Background agent mechanisms. The full explanation, exercises, and when-not-to-use guidance (team permissions, context isolation, and result-review flow all matter) are in Stage 5.5.
Exercise CLI-8: Portable prompt
Write a prompt that works in Claude Code. Run the same prompt in Codex / OpenCode / Gemini CLI — what needs to change? Common discoveries:
- file path conventions differ (cwd vs absolute)
- shell execution permission defaults differ
- "plan-first" prompting needs explicit instructions in some, default in others
Compile these into your own cheat sheet.
🎯 Curated Projects
CLAUDE.md Examples
Anthropic official docs
official — Claude Code memory / CLAUDE.md authoring docs, including best practices.
obra/superpowers ⭐⭐⭐⭐
★ 178k+ — Not just a skill collection but also a production CLAUDE.md template. Read the full .claude/ structure.
mattpocock/skills ⭐⭐⭐⭐
A practitioner's daily skill library. The .claude/ structure is a great reference. More skill examples in Stage 5.3 — Skills.
Slash Commands / Custom Prompts
anthropics/claude-plugins-official ⭐ Official
★ 18k+ — Official plugin marketplace. Each plugin's commands / skills serve as slash command examples.
hesreallyhim/awesome-claude-code
Community-curated Claude Code resources. Browse the slash command examples.
Prompt Design References
f/awesome-chatgpt-prompts ⭐⭐⭐⭐
★ 161k+ — Started for ChatGPT but ~90% of patterns work in CLIs.
Stage 2 — Prompt Engineering full list
Full list — DSPy, Prompt-Engineering-Guide, etc.
Multi-CLI Patterns
resources/cli-agents-guide.en.md "Three common combinations"
Look at Setup A / B / C and try one that fits.
Recommended Tools
- yamadashy/repomix ⭐⭐⭐⭐⭐ ★ 24k+ — Packs your entire codebase into a single AI-friendly file (XML / Markdown / JSON) for Claude Code / Codex code review / refactoring. Includes MCP server mode + tree-sitter compression (compression varies by language and file structure) + secretlint for secret filtering. A must-have, daily-driver-grade tool for Track A.
✅ Self-Check Before A3
Can you:
- [ ] Written at least 1 CLAUDE.md for a production / work repo (not a demo repo)
- [ ] Written at least 2 slash commands you actually use
- [ ] Run the same prompt across 2 different CLIs and know the differences
- [ ] Articulate "what tasks should be decomposed vs not"
If yes → proceed to A3 — Integration & Production.
If no → CLAUDE.md only on demo repos is wasted; go write one for your real repo first.
💡 Common Pitfalls
- CLAUDE.md too long: over 100 lines and the CLI auto-truncates / ignores the back half. Sweet spot: 30-60 lines.
- Slash command written as "do X, Y, Z, A, B" in one sentence: CLIs skip steps. Rewrite as numbered list with a success criterion per step.
- Over-portable: each CLI has its own strengths; don't strip a prompt of specifics just to make it cross-CLI.
- "I already know all this, I don't need to write it": CLAUDE.md is for future you (and new team members), not for current you.
