Enhance Claude Kit with new features and optimizations

This commit is contained in:
duthaho
2025-11-29 22:02:48 +07:00
parent 353e55e2fe
commit 96d9217c31
29 changed files with 2752 additions and 11 deletions
@@ -0,0 +1,212 @@
# Sequential Thinking
## Description
Step-by-step reasoning methodology with explicit evidence collection and confidence tracking. Use for complex problems requiring careful analysis and documented decision-making.
## When to Use
- Complex debugging
- Architecture decisions
- Security analysis
- Performance investigation
- Any problem with multiple possible causes
- When decisions need documentation
---
## The Sequential Process
### Step 1: Define the Question
Clearly state what you're trying to determine.
```markdown
## Question
What is causing the authentication timeout for users with special characters in passwords?
```
### Step 2: Gather Evidence
Collect all relevant information systematically.
```markdown
## Evidence Collection
### Evidence 1: Error Logs
- Source: `logs/auth-service.log`
- Finding: Timeout occurs at password encoding step
- Confidence: High (direct observation)
### Evidence 2: Code Review
- Source: `src/auth/password.ts:42`
- Finding: URL encoding applied to password
- Confidence: High (code inspection)
### Evidence 3: Test Results
- Source: Manual testing
- Finding: Works with alphanumeric, fails with `@#$`
- Confidence: High (reproducible)
```
### Step 3: Form Hypotheses
Generate possible explanations.
```markdown
## Hypotheses
### Hypothesis A: URL Encoding Issue
- Evidence supporting: E1, E2, E3
- Evidence against: None
- Probability: 80%
### Hypothesis B: Character Set Mismatch
- Evidence supporting: E3
- Evidence against: E2 (UTF-8 used)
- Probability: 15%
### Hypothesis C: Database Encoding
- Evidence supporting: None directly
- Evidence against: E1 (fails before DB)
- Probability: 5%
```
### Step 4: Test Hypotheses
Verify the most likely explanation.
```markdown
## Testing
### Test for Hypothesis A
Action: Remove URL encoding, use base64 instead
Result: Password `test@123` now works
Conclusion: Hypothesis A confirmed
```
### Step 5: Document Conclusion
State the final answer with confidence.
```markdown
## Conclusion
**Root Cause**: URL encoding in password.ts:42 mangles special characters
**Confidence**: 9/10
**Evidence Chain**:
1. Timeout at encoding step (logs)
2. URL encoding in code (review)
3. Special char passwords fail (testing)
4. Removing encoding fixes issue (verification)
**Fix**: Replace URL encoding with base64 at line 42
```
---
## Output Template
```markdown
# Sequential Analysis: [Problem Description]
## Question
[Clear statement of what we're investigating]
## Evidence
### Evidence 1: [Title]
- Source: [where found]
- Finding: [what it shows]
- Confidence: [High/Medium/Low]
### Evidence 2: [Title]
...
## Hypotheses
### Hypothesis A: [Name]
- Supporting evidence: [list]
- Contradicting evidence: [list]
- Probability: [X%]
### Hypothesis B: [Name]
...
## Testing
### Test 1: [What tested]
- Action: [what was done]
- Expected: [what should happen if hypothesis true]
- Actual: [what happened]
- Result: [confirms/refutes hypothesis]
## Conclusion
**Answer**: [clear statement]
**Confidence**: [X/10]
**Key Evidence**: [most important findings]
**Recommended Action**: [what to do next]
```
---
## Confidence Scoring
| Score | Meaning | Evidence Required |
|-------|---------|-------------------|
| 9-10 | Certain | Multiple independent confirmations |
| 7-8 | High | Strong evidence, tested hypothesis |
| 5-6 | Medium | Good evidence, some uncertainty |
| 3-4 | Low | Limited evidence, multiple possibilities |
| 1-2 | Guess | Insufficient evidence |
---
## Anti-Patterns
### Jumping to Conclusions
```markdown
❌ "The bug is probably in the database"
✅ "Let me gather evidence before hypothesizing"
```
### Confirmation Bias
```markdown
❌ Only looking for evidence supporting first guess
✅ Actively seeking contradicting evidence
```
### Skipping Documentation
```markdown
❌ Fixing without recording reasoning
✅ Document even simple analysis for future reference
```
---
## Activation
### Via Mode
```
Use mode: deep-research
```
### Via Command
```
Apply sequential thinking to analyze [problem]
```
### Via Skill Reference
```
Use skill: sequential-thinking
```
---
## Combines Well With
- Deep research mode
- Systematic debugging skill
- Root cause tracing skill
- Security audits
- Performance investigations
---
@@ -0,0 +1,198 @@
# Token Optimization
## Description
Patterns and techniques for reducing token usage while maintaining response quality. Achieve 30-70% cost savings through strategic output compression.
## When to Use
- High-volume development sessions
- Repetitive tasks
- Simple, clear requests
- Cost-sensitive projects
- Quick iterations
---
## Compression Levels
### Level 1: Concise (30-40% savings)
- Remove conversational filler
- Skip obvious explanations
- Use bullet points
- Shorter variable names in examples
### Level 2: Compact (50-60% savings)
- Code-only responses
- No surrounding prose
- Abbreviated comments
- Reference docs instead of explaining
### Level 3: Ultra (60-70% savings)
- Minimal viable response
- Essential code only
- No comments
- Diff format for changes
---
## Compression Techniques
### Remove Preambles
```markdown
❌ VERBOSE:
"I'll help you with that. Let me analyze the code and provide
a solution. Based on what I see, the issue is..."
✅ CONCISE:
"Issue: null check missing at line 42. Fix:"
```
### Code-Only Responses
```markdown
❌ VERBOSE:
"Here's the implementation. I've added proper error handling
and made sure to follow the existing patterns in your codebase.
The function now validates input and returns early if invalid."
[large code block]
"This should fix the issue. Let me know if you have questions."
✅ CONCISE:
[code block]
```
### Reference Over Explain
```markdown
❌ VERBOSE:
"React's useEffect hook runs after render. The dependency array
controls when it re-runs. Empty array means run once on mount..."
✅ CONCISE:
"Add `userId` to deps array. See: https://react.dev/reference/react/useEffect"
```
### Diff Format for Changes
```markdown
❌ VERBOSE:
"I've updated the file. Here's the complete new version:"
[entire file]
✅ CONCISE:
```diff
- const user = getUser();
+ const user = getUser() ?? defaultUser;
```
Line 42 in user-service.ts
```
---
## Output Templates
### Bug Fix
```
Fix: [brief description]
File: [path:line]
[code or diff]
Verify: [test command]
```
### Feature Addition
```
Added: [feature]
Files: [list]
[code blocks]
Test: [command]
```
### Refactor
```
Refactor: [what]
[diff format changes]
No behavior change.
```
---
## When NOT to Compress
| Situation | Why |
|-----------|-----|
| Complex architecture | Need full context |
| Security issues | Must explain risks |
| Code reviews | Thoroughness required |
| Teaching/explaining | Clarity matters |
| Debugging complex issues | Details help |
| First-time patterns | Context needed |
---
## Activation
### Via Mode
```
Use mode: token-efficient
```
### Via Flag
```
/command --format=concise
/command --format=ultra
```
### Session-Wide
```
For this session, use token-efficient mode.
```
---
## Metrics
### Typical Savings by Task
| Task Type | Verbose Tokens | Concise Tokens | Savings |
|-----------|----------------|----------------|---------|
| Bug fix | ~500 | ~150 | 70% |
| Feature | ~2000 | ~800 | 60% |
| Refactor | ~1000 | ~400 | 60% |
| Explanation | ~800 | ~300 | 62% |
### ROI Calculation
```
Sessions per day: 10
Avg tokens per session: 50,000
With optimization: 25,000
Daily savings: 250,000 tokens
Monthly savings: ~7.5M tokens
```
---
## Best Practices
1. **Match compression to task complexity**
- Simple task → High compression
- Complex task → Lower compression
2. **Preserve essential information**
- File paths always included
- Test commands always included
- Error context when relevant
3. **Use progressive disclosure**
- Start concise
- Expand if asked
4. **Know when to stop compressing**
- User confusion → Add context
- Errors occurring → Add detail
- Review needed → Full output
---