/ucai:ucai-patternsfrom ucai
Best practices for working with Claude Code's native architecture including context management, agent patterns, hooks, and batch operations. Derived from how Anthropic builds their own plugins.
Ships in ucai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Best practices for working with Claude Code's native architecture. These patterns are derived from how Anthropic builds their own plugins.
The context window is a shared resource. Protect it.
Native tools for context:
tasks/todo.md so hooks can inject state and context compaction doesn't lose your placeAnti-patterns:
For detailed patterns, see: references/context-management.md
Red Flags — Context Management
Pathological Honesty applies to every Red Flags table in this skill: the "Reality" column states what's wrong with the thought. When you catch yourself in one of these thoughts, name a concrete failure mode you've already seen or can see — a real session that overflowed, a real agent that hung, a real CLAUDE.md that drifted. Abstract realism doesn't change behavior; concrete failure modes do.
| Thought | Reality |
|---|---|
| "CLAUDE.md is the right place for this framework pattern" | CLAUDE.md is for project facts only. Framework conventions belong in skills. |
| "I'll load all context upfront to be safe" | Upfront loading burns context before it's needed. Load on demand. |
| "The context window is large enough" | Large ≠ infinite. Shared resource. Protect it. |
Agents are focused workers, not personas.
Native agent format: Markdown files with YAML frontmatter declaring name, description, tools, model, and color. Each agent has a specific mission.
Key patterns:
For detailed patterns, see: references/agent-patterns.md
Red Flags — Agent Patterns
| Thought | Reality |
|---|---|
| "I'll spawn agents one at a time for clarity" | Serial spawning wastes 2-3 seconds per round-trip. Batch in one message. |
| "This agent needs all tools available" | Restrict tools to what the agent actually needs. Scope matters. |
| "I'll have one agent do everything" | Focused agents outperform generalist agents on complex tasks. |
The golden rule: 1 message = ALL related operations. Every round-trip to Claude adds latency. Batch everything that can go together.
Good patterns:
tasks/todo.md updates in a single Write call, not one per itemAnti-patterns:
tasks/todo.md once per todo item across separate turnsWhy it matters: In a 5-agent parallel analysis, serial spawning adds 4 unnecessary round-trips. At 2-3 seconds per round-trip, that is 8-12 seconds of pure latency before any work begins. Batching collapses this to a single round-trip.
For detailed patterns, see: references/agent-patterns.md
Red Flags — Batch Operations
| Thought | Reality |
|---|---|
| "I'll read this file, then decide what to read next" | Speculatively read everything potentially useful in one message. |
| "I'll update todos one at a time as I finish each" | Batch all tasks/todo.md updates in a single Write call. |
| "Let me spawn this agent first, then spawn the next" | All parallel agents go in one message. Always. |
| "Sequential is safer" | Sequential adds latency with zero safety benefit for independent tasks. |
Gate — before spawning any agent:
Am I about to launch this agent alone, wait for it, then spawn the next?
→ Yes → STOP. Bundle all agents into one message first.
→ No → Proceed.
Gate — before any file read:
Do I know other files I'll need in this session?
→ Yes → Read all of them now in this same message.
→ No → Proceed with current read.
Hooks are lifecycle event handlers. They are the primary extension point.
Hook events: SessionStart, PreToolUse, PostToolUse, PostToolUseFailure, Stop, UserPromptSubmit, SubagentStop, SubagentStart, PreCompact, SessionEnd, PermissionRequest
Key patterns:
For detailed patterns, see: references/hook-patterns.md
Red Flags — Hook Patterns
| Thought | Reality |
|---|---|
| "The hook will handle this automatically" | Hooks run on lifecycle events. Read the handler to confirm scope. |
| "Exit code 2 might be too aggressive" | Exit code 2 is the designed block mechanism. Use it when blocking is correct. |
| "I'll skip the Stop hook phase check" | The /ship pipeline depends on the Stop hook. Skipping breaks the pipeline. |
Named mistakes to avoid. Each has a symptom and a fix.
For the full catalogue, see: references/anti-patterns.md
Red Flags — Anti-Patterns
| Thought | Reality |
|---|---|
| "This agent needs Write + Edit for safety" | Read-only agents can't accidentally break things. Restrict tools. |
| "I'll use console.log to debug my hook" | console.log corrupts hook JSON output. Use console.error for debug. |
| "The command will implement this directly" | Commands coordinate. Agents execute. Keep the separation. |
| "I'll build the path with string concatenation" | Use path.resolve() or path.join(). String concat breaks on Windows. |
For skill and command authoring principles (persuasion techniques, gate functions, enforcement language), see: references/skill-design-principles.md
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
claude-code, context-management, agent-patterns, hooks, batch-operations
npx claudepluginhub joncik91/ucai --plugin ucai8 skills in this plugin
/architectThis skill should be used when the user asks to "design system architecture", "evaluate microservices vs monolith", "create architecture diagrams", "analyze dependencies", "choose a database", "plan for scalability", "make technical decisions", or "review system design"./backendThis skill should be used when the user asks to "design REST APIs", "optimize database queries", "implement authentication", "build microservices", "review backend code", "set up GraphQL", "handle database migrations", or "load test APIs"./code-reviewerUse when reviewing pull requests, analyzing code quality, identifying issues, or generating review checklists. Covers TypeScript, JavaScript, Python, Go, Swift, and Kotlin./devopsUse when setting up CI/CD pipelines, deploying applications, managing cloud infrastructure (AWS, GCP, Azure), implementing monitoring, containerizing services, or automating deployments with infrastructure as code./frontendUse when building React components, optimizing performance, analyzing bundle sizes, scaffolding projects, implementing accessibility, reviewing frontend code quality, performing visual overhauls, or designing UI/UX systems./qaThis skill should be used when the user asks to "generate tests", "write unit tests", "analyze test coverage", "scaffold E2E tests", "set up Playwright", "configure Jest", "implement testing patterns", or "improve test quality".Other plugins' skills for the same job