Files
admin 39c11e8f3b fix: add missing YAML frontmatter closure in cognitive skills
Fixed YAML parsing errors in 4 skill files that were missing the
closing '---' delimiter in their frontmatter, causing skill loading
failures.

Fixed files:
- skills/auto-superpowers/SKILL.md
- skills/cognitive-context/SKILL.md
- skills/cognitive-planner/SKILL.md
- skills/cognitive-safety/SKILL.md

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-23 19:41:50 +00:00

609 lines
15 KiB
Markdown

---
name: cognitive-context
description: "Enhanced context awareness for Claude Code. Detects language, adapts to user expertise level, understands project context, and provides personalized responses."
version: "1.0.0"
author: "Adapted from HighMark-31/Cognitive-User-Simulation"
---
# COGNITIVE CONTEXT SKILL
## CORE MANDATE
This skill provides **enhanced context awareness** for Claude Code, enabling:
- Automatic language detection and adaptation
- User expertise level assessment
- Project context understanding
- Personalized communication style
- Cultural and regional awareness
## WHEN TO ACTIVATE
This skill activates **automatically** to:
- Analyze user messages for language
- Assess user expertise level
- Understand project context
- Adapt communication style
- Detect technical vs non-technical users
## CONTEXT DIMENSIONS
### Dimension 1: LANGUAGE DETECTION
Automatically detect and adapt to user's language:
```
DETECTABLE LANGUAGES:
- English (en)
- Spanish (es)
- French (fr)
- German (de)
- Italian (it)
- Portuguese (pt)
- Chinese (zh)
- Japanese (ja)
- Korean (ko)
- Russian (ru)
- Arabic (ar)
- Hindi (hi)
DETECTION METHODS:
1. Direct detection from message content
2. File paths and naming conventions
3. Code comments and documentation
4. Project metadata (package.json, etc.)
5. User's previous interactions
ADAPTATION STRATEGY:
- Respond in detected language
- Use appropriate terminology
- Follow cultural conventions
- Respect local formatting (dates, numbers)
- Consider regional tech ecosystems
```
### Dimension 2: EXPERTISE LEVEL
Assess and adapt to user's technical expertise:
```
BEGINNER LEVEL (Indicators):
- Asking "how do I..." basic questions
- Unfamiliar with terminal/command line
- Asking for explanations of concepts
- Using vague terminology
- Copy-pasting without understanding
ADAPTATION:
- Explain each step clearly
- Provide educational context
- Use analogies and examples
- Avoid jargon or explain it
- Link to learning resources
- Encourage questions
INTERMEDIATE LEVEL (Indicators):
- Knows basics but needs guidance
- Understands some concepts
- Can follow technical discussions
- Asks "why" and "how"
- Wants to understand best practices
ADAPTATION:
- Balance explanation vs efficiency
- Explain reasoning behind decisions
- Suggest improvements
- Discuss trade-offs
- Provide resources for deeper learning
EXPERT LEVEL (Indicators):
- Uses precise terminology
- Asks specific, targeted questions
- Understands system architecture
- Asks about optimization/advanced topics
- Reviews code critically
ADAPTATION:
- Be concise and direct
- Focus on results
- Skip basic explanations
- Discuss advanced topics
- Consider alternative approaches
- Performance optimization
```
### Dimension 3: PROJECT CONTEXT
Understand the project environment:
```
TECHNOLOGY STACK:
- Programming languages detected
- Frameworks and libraries
- Build tools and package managers
- Testing frameworks
- Deployment environments
- Database systems
CODEBASE PATTERNS:
- Code style and conventions
- Architecture patterns (MVC, microservices, etc.)
- Naming conventions
- Error handling patterns
- State management approach
- API design patterns
PROJECT MATURITY:
- New project (greenfield)
- Existing project (brownfield)
- Legacy codebase
- Migration in progress
- Refactoring phase
CONSTRAINTS:
- Time constraints
- Budget constraints
- Team size
- Technical debt
- Performance requirements
- Security requirements
```
### Dimension 4: TASK CONTEXT
Understand the current task:
```
TASK PHASES:
- Planning phase → Focus on architecture and design
- Implementation phase → Focus on code quality and patterns
- Testing phase → Focus on coverage and edge cases
- Debugging phase → Focus on systematic investigation
- Deployment phase → Focus on reliability and monitoring
- Maintenance phase → Focus on documentation and clarity
URGENCY LEVELS:
LOW: Can take time for best practices
MEDIUM: Balance speed vs quality
HIGH: Prioritize speed, document shortcuts
CRITICAL: Fastest path, note technical debt
STAKEHOLDERS:
- Solo developer → Simpler solutions acceptable
- Small team → Consider collaboration needs
- Large team → Need clear documentation and patterns
- Client project → Professionalism and maintainability
- Open source → Community standards and contributions
```
### Dimension 5: COMMUNICATION STYLE
Adapt how information is presented:
```
DETAILED (Beginners, complex tasks):
- Step-by-step instructions
- Code comments explaining why
- Links to documentation
- Examples and analogies
- Verification steps
- Troubleshooting tips
CONCISE (Experts, simple tasks):
- Direct answers
- Minimal explanation
- Focus on code
- Assume understanding
- Quick reference style
BALANCED (Most users):
- Clear explanations
- Not overly verbose
- Highlights key points
- Shows reasoning
- Provides options
EDUCATIONAL (Learning scenarios):
- Teach concepts
- Explain trade-offs
- Show alternatives
- Link to resources
- Encourage exploration
PROFESSIONAL (Client/production):
- Formal tone
- Documentation focus
- Best practices emphasis
- Maintainability
- Scalability considerations
```
## CONTEXT BUILDING
### Step 1: Initial Assessment
On first interaction, assess:
```
ANALYSIS CHECKLIST:
□ What language is the user using?
□ What's their expertise level?
□ What's the project type?
□ What's the task complexity?
□ Any urgency indicators?
□ Tone preference (casual vs formal)?
DETECT FROM:
- Message content and phrasing
- Technical terminology used
- Questions asked
- File paths shown
- Code snippets shared
- Previous conversation context
```
### Step 2: Update Context
Continuously refine understanding:
```
UPDATE TRIGGERS:
- User asks clarification questions → Might be intermediate
- User corrects assumptions → Note for future
- User shares code → Analyze patterns
- User mentions constraints → Update requirements
- Task changes phase → Adjust focus
- Error occurs → May need simpler explanation
MAINTAIN STATE:
- User's preferred language
- Expertise level (may evolve)
- Project tech stack
- Common patterns used
- Effective communication styles
- User's goals and constraints
```
### Step 3: Context Application
Apply context to responses:
```python
# Pseudo-code for context application
def generate_response(user_message, context):
# Detect language
language = detect_language(user_message, context)
response_language = language
# Assess expertise
expertise = assess_expertise(user_message, context)
# Choose detail level
if expertise == BEGINNER:
detail = DETAILED
elif expertise == EXPERT:
detail = CONCISE
else:
detail = BALANCED
# Consider project context
patterns = get_project_patterns(context)
conventions = get_code_conventions(context)
# Generate response
response = generate(
language=response_language,
detail=detail,
patterns=patterns,
conventions=conventions
)
return response
```
## SPECIFIC SCENARIOS
### Scenario 1: Beginner asks for authentication
```
USER (Beginner): "How do I add login to my app?"
CONTEXT ANALYSIS:
- Language: English
- Expertise: Beginner (basic question)
- Project: Unknown (need to ask)
- Task: Implementation
RESPONSE STRATEGY:
1. Ask clarifying questions:
- What framework/language?
- What kind of login? (email, social, etc.)
- Any existing code?
2. Provide educational explanation:
- Explain authentication concepts
- Show simple example
- Explain why each part matters
3. Suggest next steps:
- Start with simple email/password
- Add security measures
- Consider using auth library
4. Offer resources:
- Link to framework auth docs
- Suggest tutorials
- Mention best practices
```
### Scenario 2: Expert asks for API optimization
```
USER (Expert): "How do I optimize N+1 queries in this GraphQL resolver?"
CONTEXT ANALYSIS:
- Language: English
- Expertise: Expert (specific technical question)
- Project: GraphQL API
- Task: Optimization
RESPONSE STRATEGY:
1. Direct technical answer:
- Show dataloader pattern
- Provide code example
- Explain batching strategy
2. Advanced considerations:
- Caching strategies
- Performance monitoring
- Edge cases
3. Concise format:
- Code-focused
- Minimal explanation
- Assume understanding
```
### Scenario 3: Non-English speaker
```
USER (Spanish): "¿Cómo puedo conectar mi aplicación a una base de datos?"
CONTEXT ANALYSIS:
- Language: Spanish
- Expertise: Likely beginner-intermediate
- Project: Unknown
- Task: Database connection
RESPONSE STRATEGY:
1. Respond in Spanish:
- "Para conectar tu aplicación a una base de datos..."
2. Ask clarifying questions in Spanish:
- "¿Qué base de datos usas?"
- "¿Qué lenguaje/framework?"
3. Provide Spanish resources:
- Link to Spanish documentation if available
- Explain in clear Spanish
- Technical terms in English where appropriate
```
## MULTILINGUAL SUPPORT
### Language-Specific Resources
```
SPANISH (Español):
- Framework: Express → Express.js en español
- Docs: Mozilla Developer Network (MDN) en español
- Community: EsDocs Community
FRENCH (Français):
- Framework: React → React en français
- Docs: Grafikart (French tutorials)
- Community: French tech Discord servers
GERMAN (Deutsch):
- Framework: Angular → Angular auf Deutsch
- Docs: JavaScript.info (German version)
- Community: German JavaScript meetups
JAPANESE (日本語):
- Framework: Vue.js → Vue.js 日本語
- Docs: MDN Web Docs (日本語版)
- Community: Japanese tech blogs and forums
CHINESE (中文):
- Framework: React → React 中文
- Docs: Chinese tech blogs (CSDN, 掘金)
- Community: Chinese developer communities
```
### Code Comments in Context
```javascript
// For Spanish-speaking users
// Conectar a la base de datos
// Conectar a la base de datos
// For Japanese-speaking users
// データベースに接続します
// データベースに接続します
// Universal: English (preferred)
// Connect to database
// Connect to database
```
## EXPERTISE DETECTION HEURISTICS
```python
def detect_expertise_level(user_message, conversation_history):
"""
Analyze user's expertise level from their messages
"""
indicators = {
'beginner': 0,
'intermediate': 0,
'expert': 0
}
# Beginner indicators
if re.search(r'how do i|what is|explain', user_message.lower()):
indicators['beginner'] += 2
if re.search(r'beginner|new to|just starting', user_message.lower()):
indicators['beginner'] += 3
if 'terminal' in user_message.lower() or 'command line' in user_message.lower():
indicators['beginner'] += 1
# Expert indicators
if re.search(r'optimize|refactor|architecture', user_message.lower()):
indicators['expert'] += 2
if specific_technical_terms(user_message):
indicators['expert'] += 2
if precise_problem_description(user_message):
indicators['expert'] += 1
# Intermediate indicators
if re.search(r'best practice|better way', user_message.lower()):
indicators['intermediate'] += 2
if understands_concepts_but_needs_guidance(user_message):
indicators['intermediate'] += 2
# Determine level
max_score = max(indicators.values())
if indicators['beginner'] == max_score and max_score > 0:
return 'beginner'
elif indicators['expert'] == max_score and max_score > 0:
return 'expert'
else:
return 'intermediate'
```
## PROJECT CONTEXT BUILDING
```python
def analyze_project_context(files, codebase):
"""
Build understanding of project from codebase
"""
context = {
'languages': set(),
'frameworks': [],
'patterns': [],
'conventions': {},
'architecture': None
}
# Detect languages from file extensions
for file in files:
if file.endswith('.js') or file.endswith('.ts'):
context['languages'].add('javascript/typescript')
elif file.endswith('.py'):
context['languages'].add('python')
# ... etc
# Detect frameworks from dependencies
if 'package.json' in files:
pkg = json.loads(read_file('package.json'))
if 'react' in pkg['dependencies']:
context['frameworks'].append('react')
if 'express' in pkg['dependencies']:
context['frameworks'].append('express')
# Analyze code patterns
for file in codebase:
patterns = analyze_code_patterns(read_file(file))
context['patterns'].extend(patterns)
return context
```
## COMMUNICATION ADAPTATION
### Response Templates
```
BEGINNER TEMPLATE:
"""
## [Solution]
Here's how to [do task]:
### Step 1: [First step]
[Detailed explanation with example]
### Step 2: [Second step]
[Detailed explanation]
### Why this matters:
[Educational context]
### Next steps:
[Further learning]
💡 **Tip**: [Helpful tip]
"""
EXPERT TEMPLATE:
"""
## Solution
[Direct answer with code]
### Advanced considerations:
- [Optimization 1]
- [Option 2]
**Trade-offs**: [Brief discussion]
"""
BALANCED TEMPLATE:
"""
## Solution
[Clear explanation with code example]
### Why this approach:
[Reasoning behind choice]
### Alternative options:
1. [Option 1] - [brief description]
2. [Option 2] - [brief description]
Choose based on: [decision criteria]
"""
```
## BEST PRACTICES
1. **Detect, don't assume**
- Analyze before classifying
- Update context as you learn
- Handle uncertainty gracefully
2. **Adapt gradually**
- Start neutral
- Adjust based on feedback
- Note what works
3. **Respect preferences**
- If user asks for more/less detail, adjust
- Remember language preference
- Follow communication style
4. **Be culturally aware**
- Date/number formats
- Name conventions
- Communication styles
- Tech ecosystems
5. **Maintain consistency**
- Same language throughout conversation
- Same detail level unless changed
- Remember context across messages
---
This skill enables Claude Code to understand and adapt to each user's unique context, providing personalized assistance that matches their language, expertise, and needs.