mirror of
https://github.com/harivansh-afk/claude-continual-learning.git
synced 2026-04-15 09:01:14 +00:00
skill updates
This commit is contained in:
parent
df061cab9f
commit
5fe2f8795e
3 changed files with 154 additions and 28 deletions
84
commands/simplify.md
Normal file
84
commands/simplify.md
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
---
|
||||||
|
description: Simplify overly complex code while preserving full functionality
|
||||||
|
allowed-tools: Read, Edit, Bash(git diff:*), Bash(git status:*), Grep, Glob
|
||||||
|
argument-hint: [staged|unstaged|both]
|
||||||
|
---
|
||||||
|
|
||||||
|
# Simplify Implementation
|
||||||
|
|
||||||
|
You are reviewing code you just wrote to simplify it. Claude has a tendency to over-engineer. Your job is to ruthlessly simplify while preserving full functionality.
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
Current git status: !`git status --short`
|
||||||
|
|
||||||
|
### Changes to Review
|
||||||
|
|
||||||
|
Based on the argument provided ($ARGUMENTS), review the appropriate diff:
|
||||||
|
|
||||||
|
- **staged** (or no argument): Review staged changes only
|
||||||
|
- **unstaged**: Review unstaged changes only
|
||||||
|
- **both**: Review all changes (staged and unstaged)
|
||||||
|
|
||||||
|
Staged changes: !`git diff --cached`
|
||||||
|
Unstaged changes: !`git diff`
|
||||||
|
|
||||||
|
## Simplification Principles
|
||||||
|
|
||||||
|
### Remove Over-Engineering
|
||||||
|
|
||||||
|
1. **Delete unnecessary abstractions**: If a function is called once, inline it
|
||||||
|
2. **Remove premature generalization**: Delete parameters, options, or config that aren't used
|
||||||
|
3. **Flatten unnecessary nesting**: Reduce indirection levels
|
||||||
|
4. **Kill dead code paths**: Remove conditionals that can't trigger
|
||||||
|
5. **Simplify error handling**: Don't catch errors you can't meaningfully handle
|
||||||
|
6. **Remove defensive coding against impossible states**: Trust internal code
|
||||||
|
|
||||||
|
### Prefer Direct Solutions
|
||||||
|
|
||||||
|
1. **Three lines > one abstraction**: Repeated simple code beats a premature helper
|
||||||
|
2. **Explicit > clever**: Readable beats compact
|
||||||
|
3. **Flat > nested**: Early returns, guard clauses
|
||||||
|
4. **Concrete > generic**: Solve the actual problem, not hypothetical ones
|
||||||
|
5. **Standard library > custom implementation**: Use built-ins when available
|
||||||
|
|
||||||
|
### Preserve
|
||||||
|
|
||||||
|
1. **All functionality**: The feature must work exactly as before
|
||||||
|
2. **Public interfaces**: Don't change signatures that external code depends on
|
||||||
|
3. **Test coverage**: Existing tests must still pass
|
||||||
|
4. **Actual error handling**: Keep meaningful error cases
|
||||||
|
|
||||||
|
## Your Task
|
||||||
|
|
||||||
|
1. **Analyze the diff**: Identify over-engineered patterns
|
||||||
|
2. **List simplifications**: For each issue, explain what's complex and how to simplify
|
||||||
|
3. **Apply changes**: Edit the files to simplify
|
||||||
|
4. **Verify**: Ensure functionality is preserved
|
||||||
|
|
||||||
|
## Output Format
|
||||||
|
|
||||||
|
For each simplification:
|
||||||
|
```
|
||||||
|
FILE: path/to/file.ts
|
||||||
|
|
||||||
|
ISSUE: [What's over-engineered]
|
||||||
|
BEFORE: [Brief description or code snippet]
|
||||||
|
AFTER: [Brief description or code snippet]
|
||||||
|
WHY: [Why this is simpler without losing functionality]
|
||||||
|
```
|
||||||
|
|
||||||
|
Then apply the edits.
|
||||||
|
|
||||||
|
## Red Flags to Watch For
|
||||||
|
|
||||||
|
- Functions with > 3 parameters (probably doing too much)
|
||||||
|
- Deeply nested callbacks or conditionals (flatten them)
|
||||||
|
- Abstract base classes with one implementation (delete the abstraction)
|
||||||
|
- Config objects for things that could be hardcoded
|
||||||
|
- Wrapper functions that just call another function
|
||||||
|
- Comments explaining what code does (code should be self-explanatory)
|
||||||
|
- Type definitions that duplicate structure (use inference)
|
||||||
|
- Utility functions used once (inline them)
|
||||||
|
- Try/catch that just re-throws or logs (let it bubble)
|
||||||
|
- Feature flags for features that are always on
|
||||||
62
install.sh
62
install.sh
|
|
@ -35,13 +35,7 @@ echo ""
|
||||||
|
|
||||||
# Check if .claude directory exists
|
# Check if .claude directory exists
|
||||||
if [ -d "$TARGET_DIR/.claude" ]; then
|
if [ -d "$TARGET_DIR/.claude" ]; then
|
||||||
echo -e "${YELLOW}Warning: .claude directory already exists${NC}"
|
echo -e "${YELLOW}Note: .claude directory already exists - will add missing files only${NC}"
|
||||||
read -p "Continue and merge files? (y/n) " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
echo "Aborted."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create directory structure
|
# Create directory structure
|
||||||
|
|
@ -54,19 +48,28 @@ mkdir -p "$TARGET_DIR/.claude/hooks"
|
||||||
echo "Copying files..."
|
echo "Copying files..."
|
||||||
|
|
||||||
# Function to copy file from local or download from remote
|
# Function to copy file from local or download from remote
|
||||||
|
# Only copies if destination doesn't exist (no overwrite)
|
||||||
copy_file() {
|
copy_file() {
|
||||||
local src="$1"
|
local src="$1"
|
||||||
local dest="$2"
|
local dest="$2"
|
||||||
|
|
||||||
|
# Skip if destination already exists
|
||||||
|
if [ -f "$dest" ]; then
|
||||||
|
echo " Skipping $(basename "$dest") - already exists"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/$src" ]; then
|
if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/$src" ]; then
|
||||||
# Local install
|
# Local install
|
||||||
cp "$SCRIPT_DIR/$src" "$dest"
|
cp "$SCRIPT_DIR/$src" "$dest"
|
||||||
|
echo " Added $(basename "$dest")"
|
||||||
else
|
else
|
||||||
# Remote install - download from GitHub
|
# Remote install - download from GitHub
|
||||||
if ! curl -fsSL "$REPO_RAW_URL/$src" -o "$dest"; then
|
if ! curl -fsSL "$REPO_RAW_URL/$src" -o "$dest"; then
|
||||||
echo -e "${RED}Error: Failed to download $src${NC}"
|
echo -e "${RED}Error: Failed to download $src${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo " Added $(basename "$dest")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,39 +79,42 @@ copy_file "commands/setup-agent.md" "$TARGET_DIR/.claude/commands/setup-agent.md
|
||||||
copy_file "commands/retrospective.md" "$TARGET_DIR/.claude/commands/retrospective.md"
|
copy_file "commands/retrospective.md" "$TARGET_DIR/.claude/commands/retrospective.md"
|
||||||
copy_file "hooks/session-end.sh" "$TARGET_DIR/.claude/hooks/session-end.sh"
|
copy_file "hooks/session-end.sh" "$TARGET_DIR/.claude/hooks/session-end.sh"
|
||||||
|
|
||||||
# Make hook executable
|
# Make hook executable (if it exists and was just copied)
|
||||||
chmod +x "$TARGET_DIR/.claude/hooks/session-end.sh"
|
if [ -f "$TARGET_DIR/.claude/hooks/session-end.sh" ]; then
|
||||||
|
chmod +x "$TARGET_DIR/.claude/hooks/session-end.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
# Handle settings.json merge
|
# Handle settings.json
|
||||||
echo "Configuring hooks..."
|
|
||||||
SETTINGS_FILE="$TARGET_DIR/.claude/settings.json"
|
SETTINGS_FILE="$TARGET_DIR/.claude/settings.json"
|
||||||
|
|
||||||
if [ -f "$SETTINGS_FILE" ]; then
|
if [ -f "$SETTINGS_FILE" ]; then
|
||||||
# Merge with existing settings
|
# Check if SessionEnd hook is already configured
|
||||||
echo -e "${YELLOW}Existing settings.json found. Please manually add the hook configuration:${NC}"
|
if grep -q "session-end.sh" "$SETTINGS_FILE" 2>/dev/null; then
|
||||||
echo ""
|
echo " Skipping settings.json - SessionEnd hook already configured"
|
||||||
cat << 'EOF'
|
else
|
||||||
Add to your .claude/settings.json:
|
echo ""
|
||||||
|
echo -e "${YELLOW}Existing settings.json found. Please manually add the hook configuration:${NC}"
|
||||||
|
echo ""
|
||||||
|
cat << 'EOF'
|
||||||
|
Add to your .claude/settings.json hooks section:
|
||||||
|
|
||||||
{
|
"SessionEnd": [
|
||||||
"hooks": {
|
{
|
||||||
"SessionEnd": [
|
"hooks": [
|
||||||
{
|
{
|
||||||
"hooks": [
|
"type": "command",
|
||||||
{
|
"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/session-end.sh\"",
|
||||||
"type": "command",
|
"timeout": 60
|
||||||
"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/session-end.sh\"",
|
|
||||||
"timeout": 60
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
EOF
|
EOF
|
||||||
echo ""
|
echo ""
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Create new settings.json
|
# Create new settings.json
|
||||||
|
echo " Creating settings.json with SessionEnd hook"
|
||||||
cat > "$SETTINGS_FILE" << 'EOF'
|
cat > "$SETTINGS_FILE" << 'EOF'
|
||||||
{
|
{
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,42 @@ and leverage proven approaches.
|
||||||
3. **Follow conventions**: Adhere to project conventions discovered in learnings
|
3. **Follow conventions**: Adhere to project conventions discovered in learnings
|
||||||
4. **Note discoveries**: When you find something new (pattern, failure, edge case), mention it
|
4. **Note discoveries**: When you find something new (pattern, failure, edge case), mention it
|
||||||
|
|
||||||
|
## Code Simplicity
|
||||||
|
|
||||||
|
**Default to the simplest solution that works.** Resist the urge to over-engineer.
|
||||||
|
|
||||||
|
### Write Less Code
|
||||||
|
|
||||||
|
- Solve the actual problem, not hypothetical future problems
|
||||||
|
- If a function is called once, consider inlining it
|
||||||
|
- Three similar lines are better than a premature abstraction
|
||||||
|
- Use standard library and built-ins before writing custom code
|
||||||
|
- Delete code paths that can't happen
|
||||||
|
|
||||||
|
### Keep It Flat
|
||||||
|
|
||||||
|
- Use early returns and guard clauses to reduce nesting
|
||||||
|
- Avoid callback pyramids - flatten with async/await or composition
|
||||||
|
- One level of abstraction per function
|
||||||
|
|
||||||
|
### Avoid Premature Abstraction
|
||||||
|
|
||||||
|
- Don't add parameters "in case we need them later"
|
||||||
|
- Don't create base classes until you have 2+ implementations
|
||||||
|
- Don't add config for things that could be hardcoded
|
||||||
|
- Don't create wrapper functions that just call another function
|
||||||
|
|
||||||
|
### Trust Your Code
|
||||||
|
|
||||||
|
- Don't defensively code against impossible internal states
|
||||||
|
- Don't catch errors you can't meaningfully handle
|
||||||
|
- Don't validate data that's already validated upstream
|
||||||
|
- Validate at system boundaries (user input, external APIs), trust internal code
|
||||||
|
|
||||||
|
### When in Doubt
|
||||||
|
|
||||||
|
Ask: "What's the least code that makes this work?" Write that first. Add complexity only when reality demands it.
|
||||||
|
|
||||||
## Codebase Context
|
## Codebase Context
|
||||||
|
|
||||||
<!-- POPULATED BY /setup-agent -->
|
<!-- POPULATED BY /setup-agent -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue