📝 docs: add mandatory skill usage guidelines for reliable proactive invocation

Add critical section to CLAUDE.md covering:
- Skill vs Agent vs Direct Tools decision matrix
- Mandatory skill invocation rules with trigger conditions
- Proactive usage framework with right/wrong examples
- Skill chaining and coordination patterns
- Context management for skills (load → apply → unload)
- Failure handling for skill conflicts
- Decision tree for tool selection
This commit is contained in:
Lorenz Hilpert
2025-11-19 14:06:54 +01:00
parent 0f171d265b
commit ceaf6dbf3c

109
CLAUDE.md
View File

@@ -22,6 +22,115 @@ This file contains meta-instructions for how Claude should work with the ISA-Fro
- Use bullet points and structured formatting for clarity
- Only provide detailed explanations when complexity requires it
## 🔴 CRITICAL: Mandatory Skill Usage
**Skills are project-specific tools that MUST be used proactively for their domains.**
### Skill vs Agent vs Direct Tools
| Tool Type | Purpose | When to Use | Context Management |
|-----------|---------|-------------|-------------------|
| **Skills** | Domain-specific workflows (Angular, testing, architecture) | Writing/reviewing code in skill's domain | Load skill → follow instructions → unload |
| **Agents** | Research & knowledge gathering | Finding docs, searching code, analysis | Use agent → extract findings → discard output |
| **Direct Tools** | Single file operations | Reading specific known files | Use tool → process → done |
### Mandatory Skill Invocation Rules
**ALWAYS invoke skills when:**
| Trigger | Required Skill | Why |
|---------|---------------|-----|
| Writing Angular templates | `angular-template` | Modern syntax (@if, @for, @defer) |
| Writing HTML with interactivity | `html-template` | E2E attributes (data-what, data-which) + ARIA |
| Applying Tailwind classes | `tailwind` | Design system consistency |
| Writing Angular code | `logging` | Mandatory logging via @isa/core/logging |
| Creating new library | `library-scaffolder` | Proper Nx setup + Vitest config |
| Regenerating API clients | `swagger-sync-manager` | All 10 clients + validation |
| Migrating to standalone | `standalone-component-migrator` | Complete migration workflow |
| Migrating tests to Vitest | `test-migration-specialist` | Jest→Vitest conversion |
| Fixing `any` types | `type-safety-engineer` | Add Zod schemas + type guards |
| Checking architecture | `architecture-enforcer` | Import boundaries + circular deps |
| Resolving circular deps | `circular-dependency-resolver` | Graph analysis + fix strategies |
| API changes analysis | `api-change-analyzer` | Breaking change detection |
| Git workflow | `git-workflow` | Branch naming + conventional commits |
### Proactive Skill Usage Framework
**"Proactive" means:**
1. **Detect task domain automatically** - Don't wait for user to say "use skill X"
2. **Invoke before starting work** - Load skill first, then execute
3. **Apply throughout task** - Keep skill active for entire domain work
4. **Validate with skill** - Use skill to review your own output
**Example - WRONG:**
```
User: "Add a new Angular component with a form"
Assistant: [Writes component without skills]
User: "Did you use the Angular template skill?"
Assistant: "Oh sorry, let me reload with the skill"
```
**Example - RIGHT:**
```
User: "Add a new Angular component with a form"
Assistant: [Invokes angular-template skill]
Assistant: [Invokes html-template skill]
Assistant: [Invokes logging skill]
Assistant: [Writes component following all skill guidelines]
```
### Skill Chaining & Coordination
**Multiple skills often apply to same task:**
| Task | Required Skill Chain | Order |
|------|---------------------|-------|
| New Angular component | `angular-template``html-template``logging``tailwind` | Template syntax → HTML attributes → Logging → Styling |
| New library | `library-scaffolder``architecture-enforcer` | Scaffold → Validate structure |
| API sync | `api-change-analyzer``swagger-sync-manager` | Analyze changes → Regenerate clients |
| Component migration | `standalone-component-migrator``test-migration-specialist` | Migrate component → Migrate tests |
**Skill chaining rules:**
- Load ALL applicable skills at task start (via Skill tool)
- Skills don't nest - they provide instructions you follow
- Skills stay active for entire task scope
- Validate final output against ALL loaded skills
### Skill Context Management
**Skills expand instructions into your context:**
-**DO**: Load skill → internalize rules → follow throughout task
-**DON'T**: Re-read skill instructions multiple times
-**DON'T**: Quote skill instructions back to user
-**DON'T**: Keep skill "open" after task completion
**After task completion:**
1. Verify work against skill requirements
2. Summarize what was applied (1 sentence)
3. Move on (skill context auto-clears next task)
### Skill Failure Handling
| Issue | Action |
|-------|--------|
| Skill not found | Verify skill name; ask user to check available skills |
| Skill conflicts with user request | Note conflict; ask user for preference |
| Multiple skills give conflicting rules | Follow most specific skill for current file type |
| Skill instructions unclear | Use best judgment; document assumption in code comment |
### Skills vs Agents - Decision Tree
```
Is this a code writing/reviewing task?
├─ YES → Check if skill exists for domain
│ ├─ Skill exists → Use Skill
│ └─ No skill → Use direct tools
└─ NO → Is this research/finding information?
├─ YES → Use Agent (docs-researcher/Explore)
└─ NO → Use direct tools (Read/Edit/Bash)
```
## Researching and Investigating the Codebase
**🔴 MANDATORY: You MUST use subagents for research. Direct file reading/searching.**