feat: CRM Clinicas SaaS - MVP completo

- Auth: Login/Register con creacion de clinica
- Dashboard: KPIs reales, graficas recharts
- Pacientes: CRUD completo con busqueda
- Agenda: FullCalendar, drag-and-drop, vista recepcion
- Expediente: Notas SOAP, signos vitales, CIE-10
- Facturacion: Facturas con IVA, campos CFDI SAT
- Inventario: Productos, stock, movimientos, alertas
- Configuracion: Clinica, equipo, catalogo servicios
- Supabase self-hosted: 18 tablas con RLS multi-tenant
- Docker + Nginx para produccion

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
Consultoria AS
2026-03-03 07:04:14 +00:00
commit 79b5d86325
1612 changed files with 109181 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
# Hooks Commands
Commands for hooks operations in Claude Flow.
## Available Commands
- [pre-task](./pre-task.md)
- [post-task](./post-task.md)
- [pre-edit](./pre-edit.md)
- [post-edit](./post-edit.md)
- [session-end](./session-end.md)

View File

@@ -0,0 +1,58 @@
# Claude Code Hooks for claude-flow
## Purpose
Automatically coordinate, format, and learn from Claude Code operations using hooks.
## Available Hooks
### Pre-Operation Hooks
- **pre-edit**: Validate and assign agents before file modifications
- **pre-bash**: Check command safety and resource requirements
- **pre-task**: Auto-spawn agents for complex tasks
### Post-Operation Hooks
- **post-edit**: Auto-format code and train neural patterns
- **post-bash**: Log execution and update metrics
- **post-search**: Cache results and improve search patterns
### MCP Integration Hooks
- **mcp-initialized**: Persist swarm configuration
- **agent-spawned**: Update agent roster
- **task-orchestrated**: Monitor task progress
- **neural-trained**: Save pattern improvements
### Session Hooks
- **notify**: Custom notifications with swarm status
- **session-end**: Generate summary and save state
- **session-restore**: Load previous session state
## Configuration
Hooks are configured in `.claude/settings.json`:
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "^(Write|Edit|MultiEdit)$",
"hooks": [{
"type": "command",
"command": "npx claude-flow hook pre-edit --file '${tool.params.file_path}'"
}]
}
]
}
}
```
## Benefits
- 🤖 Automatic agent assignment based on file type
- 🎨 Consistent code formatting
- 🧠 Continuous neural pattern improvement
- 💾 Cross-session memory persistence
- 📊 Performance metrics tracking
## See Also
- [Pre-Edit Hook](./pre-edit.md)
- [Post-Edit Hook](./post-edit.md)
- [Session End Hook](./session-end.md)

View File

@@ -0,0 +1,117 @@
# hook post-edit
Execute post-edit processing including formatting, validation, and memory updates.
## Usage
```bash
npx claude-flow hook post-edit [options]
```
## Options
- `--file, -f <path>` - File path that was edited
- `--auto-format` - Automatically format code (default: true)
- `--memory-key, -m <key>` - Store edit context in memory
- `--train-patterns` - Train neural patterns from edit
- `--validate-output` - Validate edited file
## Examples
### Basic post-edit hook
```bash
npx claude-flow hook post-edit --file "src/components/Button.jsx"
```
### With memory storage
```bash
npx claude-flow hook post-edit -f "api/auth.js" --memory-key "auth/login-implementation"
```
### Format and validate
```bash
npx claude-flow hook post-edit -f "config/webpack.js" --auto-format --validate-output
```
### Neural training
```bash
npx claude-flow hook post-edit -f "utils/helpers.ts" --train-patterns --memory-key "utils/refactor"
```
## Features
### Auto Formatting
- Language-specific formatters
- Prettier for JS/TS/JSON
- Black for Python
- gofmt for Go
- Maintains consistency
### Memory Storage
- Saves edit context
- Records decisions made
- Tracks implementation details
- Enables knowledge sharing
### Pattern Training
- Learns from successful edits
- Improves future suggestions
- Adapts to coding style
- Enhances coordination
### Output Validation
- Checks syntax correctness
- Runs linting rules
- Validates formatting
- Ensures quality
## Integration
This hook is automatically called by Claude Code when:
- After Edit tool completes
- Following MultiEdit operations
- During file saves
- After code generation
Manual usage in agents:
```bash
# After editing files
npx claude-flow hook post-edit --file "path/to/edited.js" --memory-key "feature/step1"
```
## Output
Returns JSON with:
```json
{
"file": "src/components/Button.jsx",
"formatted": true,
"formatterUsed": "prettier",
"lintPassed": true,
"memorySaved": "component/button-refactor",
"patternsTrained": 3,
"warnings": [],
"stats": {
"linesChanged": 45,
"charactersAdded": 234
}
}
```
## See Also
- `hook pre-edit` - Pre-edit preparation
- `Edit` - File editing tool
- `memory usage` - Memory management
- `neural train` - Pattern training

View File

@@ -0,0 +1,112 @@
# hook post-task
Execute post-task cleanup, performance analysis, and memory storage.
## Usage
```bash
npx claude-flow hook post-task [options]
```
## Options
- `--task-id, -t <id>` - Task identifier for tracking
- `--analyze-performance` - Generate performance metrics (default: true)
- `--store-decisions` - Save task decisions to memory
- `--export-learnings` - Export neural pattern learnings
- `--generate-report` - Create task completion report
## Examples
### Basic post-task hook
```bash
npx claude-flow hook post-task --task-id "auth-implementation"
```
### With full analysis
```bash
npx claude-flow hook post-task -t "api-refactor" --analyze-performance --generate-report
```
### Memory storage
```bash
npx claude-flow hook post-task -t "bug-fix-123" --store-decisions --export-learnings
```
### Quick cleanup
```bash
npx claude-flow hook post-task -t "minor-update" --analyze-performance false
```
## Features
### Performance Analysis
- Measures execution time
- Tracks token usage
- Identifies bottlenecks
- Suggests optimizations
### Decision Storage
- Saves key decisions made
- Records implementation choices
- Stores error resolutions
- Maintains knowledge base
### Neural Learning
- Exports successful patterns
- Updates coordination models
- Improves future performance
- Trains on task outcomes
### Report Generation
- Creates completion summary
- Documents changes made
- Lists files modified
- Tracks metrics achieved
## Integration
This hook is automatically called by Claude Code when:
- Completing a task
- Switching to a new task
- Ending a work session
- After major milestones
Manual usage in agents:
```bash
# In agent coordination
npx claude-flow hook post-task --task-id "your-task-id" --analyze-performance true
```
## Output
Returns JSON with:
```json
{
"taskId": "auth-implementation",
"duration": 1800000,
"tokensUsed": 45000,
"filesModified": 12,
"performanceScore": 0.92,
"learningsExported": true,
"reportPath": "/reports/task-auth-implementation.md"
}
```
## See Also
- `hook pre-task` - Pre-task setup
- `performance report` - Detailed metrics
- `memory usage` - Memory management
- `neural patterns` - Pattern analysis

View File

@@ -0,0 +1,113 @@
# hook pre-edit
Execute pre-edit validations and agent assignment before file modifications.
## Usage
```bash
npx claude-flow hook pre-edit [options]
```
## Options
- `--file, -f <path>` - File path to be edited
- `--auto-assign-agent` - Automatically assign best agent (default: true)
- `--validate-syntax` - Pre-validate syntax before edit
- `--check-conflicts` - Check for merge conflicts
- `--backup-file` - Create backup before editing
## Examples
### Basic pre-edit hook
```bash
npx claude-flow hook pre-edit --file "src/auth/login.js"
```
### With validation
```bash
npx claude-flow hook pre-edit -f "config/database.js" --validate-syntax
```
### Manual agent assignment
```bash
npx claude-flow hook pre-edit -f "api/users.ts" --auto-assign-agent false
```
### Safe editing with backup
```bash
npx claude-flow hook pre-edit -f "production.env" --backup-file --check-conflicts
```
## Features
### Auto Agent Assignment
- Analyzes file type and content
- Assigns specialist agents
- TypeScript → TypeScript expert
- Database → Data specialist
- Tests → QA engineer
### Syntax Validation
- Pre-checks syntax validity
- Identifies potential errors
- Suggests corrections
- Prevents broken code
### Conflict Detection
- Checks for git conflicts
- Identifies concurrent edits
- Warns about stale files
- Suggests merge strategies
### File Backup
- Creates safety backups
- Enables quick rollback
- Tracks edit history
- Preserves originals
## Integration
This hook is automatically called by Claude Code when:
- Using Edit or MultiEdit tools
- Before file modifications
- During refactoring operations
- When updating critical files
Manual usage in agents:
```bash
# Before editing files
npx claude-flow hook pre-edit --file "path/to/file.js" --validate-syntax
```
## Output
Returns JSON with:
```json
{
"continue": true,
"file": "src/auth/login.js",
"assignedAgent": "auth-specialist",
"syntaxValid": true,
"conflicts": false,
"backupPath": ".backups/login.js.bak",
"warnings": []
}
```
## See Also
- `hook post-edit` - Post-edit processing
- `Edit` - File editing tool
- `MultiEdit` - Multiple edits tool
- `agent spawn` - Manual agent creation

View File

@@ -0,0 +1,111 @@
# hook pre-task
Execute pre-task preparations and context loading.
## Usage
```bash
npx claude-flow hook pre-task [options]
```
## Options
- `--description, -d <text>` - Task description for context
- `--auto-spawn-agents` - Automatically spawn required agents (default: true)
- `--load-memory` - Load relevant memory from previous sessions
- `--optimize-topology` - Select optimal swarm topology
- `--estimate-complexity` - Analyze task complexity
## Examples
### Basic pre-task hook
```bash
npx claude-flow hook pre-task --description "Implement user authentication"
```
### With memory loading
```bash
npx claude-flow hook pre-task -d "Continue API development" --load-memory
```
### Manual agent control
```bash
npx claude-flow hook pre-task -d "Debug issue #123" --auto-spawn-agents false
```
### Full optimization
```bash
npx claude-flow hook pre-task -d "Refactor codebase" --optimize-topology --estimate-complexity
```
## Features
### Auto Agent Assignment
- Analyzes task requirements
- Determines needed agent types
- Spawns agents automatically
- Configures agent parameters
### Memory Loading
- Retrieves relevant past decisions
- Loads previous task contexts
- Restores agent configurations
- Maintains continuity
### Topology Optimization
- Analyzes task structure
- Selects best swarm topology
- Configures communication patterns
- Optimizes for performance
### Complexity Estimation
- Evaluates task difficulty
- Estimates time requirements
- Suggests agent count
- Identifies dependencies
## Integration
This hook is automatically called by Claude Code when:
- Starting a new task
- Resuming work after a break
- Switching between projects
- Beginning complex operations
Manual usage in agents:
```bash
# In agent coordination
npx claude-flow hook pre-task --description "Your task here"
```
## Output
Returns JSON with:
```json
{
"continue": true,
"topology": "hierarchical",
"agentsSpawned": 5,
"complexity": "medium",
"estimatedMinutes": 30,
"memoryLoaded": true
}
```
## See Also
- `hook post-task` - Post-task cleanup
- `agent spawn` - Manual agent creation
- `memory usage` - Memory management
- `swarm init` - Swarm initialization

View File

@@ -0,0 +1,118 @@
# hook session-end
Cleanup and persist session state before ending work.
## Usage
```bash
npx claude-flow hook session-end [options]
```
## Options
- `--session-id, -s <id>` - Session identifier to end
- `--save-state` - Save current session state (default: true)
- `--export-metrics` - Export session metrics
- `--generate-summary` - Create session summary
- `--cleanup-temp` - Remove temporary files
## Examples
### Basic session end
```bash
npx claude-flow hook session-end --session-id "dev-session-2024"
```
### With full export
```bash
npx claude-flow hook session-end -s "feature-auth" --export-metrics --generate-summary
```
### Quick close
```bash
npx claude-flow hook session-end -s "quick-fix" --save-state false --cleanup-temp
```
### Complete persistence
```bash
npx claude-flow hook session-end -s "major-refactor" --save-state --export-metrics --generate-summary
```
## Features
### State Persistence
- Saves current context
- Stores open files
- Preserves task progress
- Maintains decisions
### Metric Export
- Session duration
- Commands executed
- Files modified
- Tokens consumed
- Performance data
### Summary Generation
- Work accomplished
- Key decisions made
- Problems solved
- Next steps identified
### Cleanup Operations
- Removes temp files
- Clears caches
- Frees resources
- Optimizes storage
## Integration
This hook is automatically called by Claude Code when:
- Ending a conversation
- Closing work session
- Before shutdown
- Switching contexts
Manual usage in agents:
```bash
# At session end
npx claude-flow hook session-end --session-id "your-session" --generate-summary
```
## Output
Returns JSON with:
```json
{
"sessionId": "dev-session-2024",
"duration": 7200000,
"saved": true,
"metrics": {
"commandsRun": 145,
"filesModified": 23,
"tokensUsed": 85000,
"tasksCompleted": 8
},
"summaryPath": "/sessions/dev-session-2024-summary.md",
"cleanedUp": true,
"nextSession": "dev-session-2025"
}
```
## See Also
- `hook session-start` - Session initialization
- `hook session-restore` - Session restoration
- `performance report` - Detailed metrics
- `memory backup` - State backup

View File

@@ -0,0 +1,103 @@
# Setting Up ruv-swarm Hooks
## Quick Start
### 1. Initialize with Hooks
```bash
npx claude-flow init --hooks
```
This automatically creates:
- `.claude/settings.json` with hook configurations
- Hook command documentation
- Default hook handlers
### 2. Test Hook Functionality
```bash
# Test pre-edit hook
npx claude-flow hook pre-edit --file test.js
# Test session summary
npx claude-flow hook session-end --summary
```
### 3. Customize Hooks
Edit `.claude/settings.json` to customize:
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "^Write$",
"hooks": [{
"type": "command",
"command": "npx claude-flow hook pre-write --file '${tool.params.file_path}'"
}]
}
]
}
}
```
## Hook Response Format
Hooks return JSON with:
- `continue`: Whether to proceed (true/false)
- `reason`: Explanation for decision
- `metadata`: Additional context
Example blocking response:
```json
{
"continue": false,
"reason": "Protected file - manual review required",
"metadata": {
"file": ".env.production",
"protection_level": "high"
}
}
```
## Performance Tips
- Keep hooks lightweight (< 100ms)
- Use caching for repeated operations
- Batch related operations
- Run non-critical hooks asynchronously
## Debugging Hooks
```bash
# Enable debug output
export CLAUDE_FLOW_DEBUG=true
# Test specific hook
npx claude-flow hook pre-edit --file app.js --debug
```
## Common Patterns
### Auto-Format on Save
Already configured by default for common file types.
### Protected File Detection
```json
{
"matcher": "^(Write|Edit)$",
"hooks": [{
"type": "command",
"command": "npx claude-flow hook check-protected --file '${tool.params.file_path}'"
}]
}
```
### Automatic Testing
```json
{
"matcher": "^Write$",
"hooks": [{
"type": "command",
"command": "test -f '${tool.params.file_path%.js}.test.js' && npm test '${tool.params.file_path%.js}.test.js'"
}]
}
```