iTranslated by AI
How Combining Claude Code Rules, Skills, and Interactive Tools Eliminates Implementation Oversights
Introduction: Breaking the Cycle of "That's Not What I Asked For"
Many of you who have started using Claude Code might have experienced these situations:
- You asked to "add this API," but it was implemented without authentication checks.
- You asked for a
/bugfix, but the frontend naming conventions were broken. - After implementation, you realized, "Oh, I didn't write any error handling."
However, at a certain point, the omissions and oversights in implementation almost completely disappeared. What changed was how I use Claude Code.
Specifically, I started combining three key elements:
-
Rules (CLAUDE.md +
.claude/rules/) — Teaching Claude "the common sense of this project." -
Skills (
.claude/skills/slash commands) — Defining "how this task should proceed." -
AskUserQuestion+TaskCreate(Dialogue and WBS tools) — Eliminating ambiguity early and tracking missing items.
In this article, I will explain how these three elements work, starting from their internal mechanisms.
Overview: The Operational Layers of Claude Code
Let's start by getting a bird's-eye view. From the moment Claude Code receives a prompt until it responds, it passes through the following layers.
User Prompt
│
▼
┌───────────────────────────────────────────────────┐
│ Layer 1: Rules (Injection into System Prompt) │
│ - CLAUDE.md (Project root instructions) │
│ - .claude/rules/*.md (Path-based conditional rules)│
│ - docs/PROMPT_ENTRYPOINT.md (Delivery protocol) │
└───────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────┐
│ Layer 2: Skills (Action templates via /commands) │
│ - .claude/skills/bugfix/SKILL.md │
│ - .claude/skills/frontend/SKILL.md │
│ - .claude/skills/spec/SKILL.md ... │
└───────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────┐
│ Layer 3: Interactive Tools (Interactive QA) │
│ - AskUserQuestion → Resolve ambiguity in advance │
│ - TaskCreate/List/Update → WBS management / tracking│
│ - EnterPlanMode → Planning phase with approval gate│
└───────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────┐
│ Layer 4: Hooks (Automated quality checks) │
│ - PostToolUse: Edit .py → Auto-run ruff │
│ - Stop: Response complete → Lint check │
└───────────────────────────────────────────────────┘
│
▼
Implementation / Answer
The important thing is that these do not function as a mere "set of rules," but as "dynamic injections into the System Prompt."
---## 1. Rules: Injecting "Project Common Sense" into the System Prompt### The Role of CLAUDE.mdCLAUDE.md is a file that is automatically read by Claude Code every time it opens a project, and it is inserted at the beginning of the System Prompt for every conversation.In other words, if you write this:markdown# CLAUDE.md## LanguageAlways interact in Japanese.## Mandatory Rules- Always use fetchWithAuth for API calls.- Add Depends(get_current_user) to endpoints that require authentication.Claude Code will always operate under the assumption that "this project responds in Japanese and uses fetchWithAuth." It becomes a protocol that is upheld without needing to be explicitly stated every time.### .claude/rules/: Path-based Conditional RulesEven more powerful is the .claude/rules/ directory. You can specify paths in the front matter at the beginning of each Markdown file:markdown---paths: - "app/**/*.py" - "alembic/**/*.py"---# Backend Convention (Python / FastAPI)## Endpoint Implementation- Always add `Depends(get_current_user)` to endpoints requiring authentication.- Always specify the Pydantic schema with `response_model=` for responses.## Database Operations- Use SQLAlchemy ORM (Raw SQL is prohibited)- Constructing SQL via string concatenation is strictly prohibited (SQL injection).With this, the backend conventions are added to the System Prompt only when touching Python files. When touching TypeScript files, the frontend conventions are added instead. This prevents context pollution.### PROMPT_ENTRYPOINT.md: The Always-Applied Meta-RuleFurthermore, by referencing a "protocol that must be followed in every task," such as docs/PROMPT_ENTRYPOINT.md, from CLAUDE.md, you can turn the delivery process itself into a rule:markdown# CLAUDE.md (Excerpt)## Development Workflow (Spec Gate Protocol)Detailed protocol: @docs/PROMPT_ENTRYPOINT.md### Pipeline(1) SPEC_AUDIT → (2) SPEC_V1 → (3) PLAN_WBS → (4) IMPLEMENT → (5) SELF_REVIEW### Explicit approval ("yes") required at each phaseYou can reference other files with the @ prefix, allowing you to manage rules in a modular way without bloating CLAUDE.md.
---## 2. Skills: "Action Templates" for Each Task### What are Skills?Skills are action templates that correspond to slash commands like /bugfix, /spec, and /frontend. They are defined as SKILL.md files within subdirectories under .claude/skills/..claude/skills/├── bugfix/SKILL.md├── spec/SKILL.md├── frontend/SKILL.md├── new-endpoint/SKILL.md├── review/SKILL.md└── audit/SKILL.md### The Structure of SKILL.mdLet's look at an actual SKILL.md example:markdown---name: bugfixdescription: Fix bugs. Use when the user says "fix the bug," "it's not working," or "an error occurs."argument-hint: "[Description of the bug]"allowed-tools: - Read - Glob - Grep - Edit - Write - Bash - Task - AskUserQuestion---# Bug Fix Skill## Steps### 1. Investigation- Confirm the reproduction steps for the bug- Identify related code (endpoints, components, models)- Identify the root cause### 2. Present the fix strategy to the user and obtain approval## Bug Fix Strategy- Symptoms:- Root Cause:- Location: [File path:line number]- Fix Approach:- Impact:- ### 3. Implement the fix after user approval...In the front matter, you define the following:| Field | Role ||-----------|------|| name | Slash command name (/bugfix) || description | Description of when to use it (trigger for auto-suggestions) || argument-hint | Guide for /bugfix [what to write here] || allowed-tools | Permitted list of tools that can be used within this skill |allowed-tools is crucial. If it is the bugfix skill, AskUserQuestion is also permitted, so you can confirm specifications before fixing. Conversely, you can narrow the execution scope by excluding unnecessary tools (e.g., WebSearch).### Workflow When Executing / CommandsUser: /bugfix login returns 401 │ ▼Claude Code expands SKILL.md(Inserts SKILL.md content into the prompt) │ ▼Rules (CLAUDE.md + path-specific rules) + Skills (bugfix steps)combined to allow Claude to operate │ ▼Follows the steps: "First confirm reproduction steps with AskUserQuestion, then identify root cause, then present fix strategy before implementation"Without Skills: When you just say "login returns 401," Claude operates based on its own judgment. In my experience, it tends to skip root cause investigation, try to fix it based on guesses, or implement fixes without confirming the impact range.With Skills: Since the steps are defined in SKILL.md, the flow of investigation → strategy presentation → approval → implementation is guaranteed.
3. AskUserQuestion: Resolving Ambiguity "Before Implementation"
Why is ambiguity a problem?
When humans request tasks, something is always left undefined.
- "Add a search feature" -> Full-text search? Title only? How about pagination?
- "Fix the error" -> Frontend error? Backend error? Which error?
- "Improve performance" -> Which screen? Which metric is slow?
Previously, Claude Code often tended to "just judge and implement on its own." Now, you can ask questions before implementation using the AskUserQuestion tool.
How AskUserQuestion Works
AskUserQuestion is one of the tools that Claude Code can invoke, and it displays structured questions with options as a UI:
Actual display example (question when creating this article):
┌─────────────────────────────────────────────────────┐
│ What is the main target audience for this article? │
├─────────────────────────────────────────────────────┤
│ ○ Claude Code Beginner │
│ New users who don't know CLAUDE.md or Skills │
│ │
│ ● Claude Code Intermediate (Recommended) │
│ Regular users who don't know internal mechanics │
│ │
│ ○ Senior Engineer/Architect │
│ Expect content diving into implementation details │
└─────────────────────────────────────────────────────┘
This "structuring and confirming ambiguity before implementation" is the key to improving quality.
Combining Skills + AskUserQuestion
By defining procedures that include AskUserQuestion in a Skill's SKILL.md, you can enforce a workflow that always includes user consultation.
Example for the spec skill:
---
name: spec
allowed-tools:
- AskUserQuestion
- Read
- Glob
- Write
---
# Specification Creation Skill
## Steps
### 1. Clarification of Requirements (Mandatory)
Use AskUserQuestion to confirm the following:
- Who is the target user?
- What are the boundaries within/outside scope?
- Priority (Must/Should/Could)?
### 2. SPEC_AUDIT
(Create the skeleton of the specification using confirmed requirements)...
In the past, the approach was "just try writing it -> fix if wrong," but this has changed to a "confirm before writing" flow.
4. TaskCreate/TaskUpdate/TaskList: Tracking Omissions with WBS
The Role of Task Management Tools
TaskCreate, TaskUpdate, and TaskList are tools that allow Claude Code to manage a task list within a session. These work powerfully when combined with the PLAN_WBS phase of the Spec Gate Protocol.
Actual Operational Flow
For example, if you receive a request like "Add a new API endpoint":
Previously (Skills only):
Implementation -> Completion report
(Common to forget tests or database migrations midway)
Currently (TaskCreate + Spec Gate):
SPEC_AUDIT (Requirement confirmation)
| Approved
SPEC_V1 (Create specification & RTM build)
| Approved
PLAN_WBS (Task decomposition)
|
TaskCreate to register each task:
T-01: Create Pydantic schema [pending]
T-02: Update SQLAlchemy model [pending]
T-03: Implement CRUD function [pending]
T-04: Implement endpoint [pending]
T-05: Alembic migration [pending]
T-06: Create unit tests [pending]
T-07: Verify integration tests [pending]
| Approved
IMPLEMENT (Execute tasks in order)
T-01 -> in_progress -> completed
T-02 -> in_progress -> completed
...
T-06 -> in_progress -> completed <-- Forgetting tests is prevented here
|
SELF_REVIEW (Check RTM coverage)
[ ] Have all REQs been completed?
[ ] Do all ACs have corresponding tests?
[ ] Are there any orphaned tasks?
How RTM (Requirements Traceability Matrix) Visualizes Omissions
In the Spec Gate Protocol, a requirements traceability matrix is mandatory:
| REQ ID | Requirement | AC IDs | Task IDs | Test IDs | Status |
|--------|--------------------------|-------------|-------------|----------|--------|
| REQ-01 | Fetch data with auth | AC-01, AC-02 | T-01, T-02 | UT-01 | Done |
| REQ-02 | Pagination support | AC-03 | T-03 | UT-02 | Done |
| REQ-03 | Unified error response | AC-04 | T-04 | IT-01 | Done |
We verify this matrix during SELF_REVIEW. If there is a blank cell, it represents an implementation omission, preventing situations where you "thought it was finished."
5. Hooks: The "Automatic Check Upon Completion" Mechanism
You can define commands that automatically run after file edits or upon completion of a response in the hooks section of .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [{
"type": "command",
"command": "filepath=$(echo $CLAUDE_TOOL_INPUT | jq -r '.file_path // empty'); case \"$filepath\" in *.py) ruff format --quiet \"$filepath\" && ruff check --fix --quiet \"$filepath\";; esac"
}]
}
],
"Stop": [
{
"hooks": [{
"type": "command",
"command": "has_py=$(git diff --name-only HEAD | grep '\\.py$'); if [ -n \"$has_py\" ]; then ruff check app/ || exit 2; fi"
}]
}
]
}
}
| Hook | Timing | Purpose |
|---|---|---|
PostToolUse (Edit|Write) |
Immediately after editing a .py file | Automatic execution of ruff format + ruff check --fix |
Stop |
Upon Claude's completion of response | Lint check for all changed files (prompts re-correction if failed) |
Linting runs the moment Claude finishes the implementation, and if there are errors, it either fixes them automatically or instructs the AI to re-correct them. This eliminates "implementation finished, but lint errors remained."
6. Overall Synergy: Understanding through "Before vs. After"
Before: Skills only
User: /bugfix Login returns 401
Claude Code:
- Investigates a little
- Guesses the cause and fixes it
- Reports completion
Issues:
✗ Did not verify reproduction steps
✗ Did not check scope of impact
✗ Did not obtain approval for fix approach
✗ Lint errors remained (manual check required)
After: Rules + Skills + AskUserQuestion + TaskCreate + Hooks
User: /bugfix Login returns 401
Claude Code:
1. Verify reproduction steps, environment, and logs via AskUserQuestion
| User response
2. Investigate relevant code (Read, Grep, Glob)
3. Identify root cause and propose fix approach
| User approval
4. Implement fix (following CLAUDE.md conventions)
| Hooks automatically execute ruff
5. Create checklist via TaskCreate and confirm all items
6. Present completion report
Results:
✓ Reproduction steps verified first
✓ Scope of impact confirmed
✓ Fix approach approved
✓ Zero lint errors (automatically fixed)
✓ Omissions caught via checklist
7. How to Apply to Your Project
Step 1: Write CLAUDE.md (You can start today)
You can get results with just this minimal setup:
# CLAUDE.md
## Language/Communication
- Interact in English
## About this project
[Project overview in 1-3 sentences]
## Tech Stack
- Backend: [e.g., FastAPI + Python 3.11]
- Frontend: [e.g., React + TypeScript]
## Mandatory Rules
- [e.g., Always use fetchWithAuth for API calls]
- [e.g., No raw SQL; use ORM]
Step 2: Add path-specific rules in .claude/rules/
<!-- .claude/rules/backend.md -->
---
paths:
- "src/api/**/*.py"
---
# Backend conventions
- Auth: Depends(get_current_user) is mandatory
- Errors: Use HTTPException with clear messages
Step 3: Turn frequently used workflows into Skills
If you have repetitive task patterns, consolidate them into a SKILL.md:
.claude/skills/
├── deploy/SKILL.md <- Deployment steps
├── db-migrate/SKILL.md <- Migration steps
└── review/SKILL.md <- Review criteria
Step 4: Add automatic quality checks with Hooks
// .claude/settings.json
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "your-lint-command" }]
}]
}
}
Summary: From "Delegating to AI" to "Collaborating with AI"
The combination of Rules, Skills, and interactive tools in Claude Code is not just a "convenient collection of shortcuts."
- Rules eliminate the hassle of explaining "common sense" for the project every time.
- Skills enforce procedures on "how to proceed with this task."
- AskUserQuestion prevents "proceeding with ambiguity and having to rebuild later."
- TaskCreate/WBS visualizes "omissions you thought were handled."
- Hooks automate "manual lint checks forgotten after completion."
Each is a small mechanism, but combined, they bring you closer to a state where "quality is maintained without human review."
If you have ever had the experience of "requesting something from Claude Code only for the implementation to differ from expectations," please start with CLAUDE.md. Simply verbalizing the project's "common sense" will dramatically improve implementation quality.
Reference: Overall File Structure
project-root/
├── CLAUDE.md <- Global Rules (always applied)
├── docs/
│ ├── PROMPT_ENTRYPOINT.md <- Delivery Protocol
│ ├── SPEC_PROTOCOL.md <- Spec Gate Details
│ └── DEFINITION_OF_DONE.md <- Definition of Done
├── specs/ <- Storage for generated specifications
└── .claude/
├── settings.json <- Hooks, Permission settings
├── rules/
│ ├── backend.md <- Applied to app/**/*.py
│ ├── frontend.md <- Applied to src/**/*.ts
│ └── security.md <- Common to all files
└── skills/
├── bugfix/SKILL.md
├── spec/SKILL.md
├── frontend/SKILL.md
├── new-endpoint/SKILL.md
└── review/SKILL.md
This article was written based on operational experience with an actual production CMS project (AIOContentStudio).
Discussion