Advertisement
Guest User

Untitled

a guest
Jul 14th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.85 KB | None | 0 0
  1. # CLAUDE.md
  2.  
  3. This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
  4.  
  5. ## Project Overview
  6.  
  7. This is the **Claude Code Development Kit** - a comprehensive automation framework that transforms Claude Code from a helpful tool into a reliable development partner. The kit includes n8n documentation, command orchestration templates, intelligent hooks, and a 3-tier AI-optimized documentation system.
  8.  
  9. - **Vision:** Provide automated context injection, security scanning, and documentation maintenance for AI-assisted development
  10. - **Current Phase:** Production-ready framework (v4.0.0) with complete n8n API integration and lifecycle automation
  11. - **Key Architecture:** Shell-based automation framework with markdown-based command orchestration
  12. - **Development Strategy:** Token-efficient AI context management with cross-platform compatibility
  13.  
  14. ## Project Structure
  15.  
  16. **⚠️ CRITICAL: AI agents MUST read the [Project Structure documentation](/docs/ai-context/project-structure.md) before attempting any task to understand the complete technology stack, file tree and project organization.**
  17.  
  18. This is a development toolkit, not a traditional codebase. The framework uses shell scripts, markdown templates, and JSON configuration to orchestrate AI workflows. For the complete structure, see [docs/ai-context/project-structure.md](/docs/ai-context/project-structure.md).
  19.  
  20. ## Common Commands
  21.  
  22. ### Framework Operations
  23.  
  24. - **Install framework**: `curl -sSL https://raw.githubusercontent.com/your-repo/install.sh | bash`
  25. - **Setup locally**: `./setup.sh` (interactive configuration)
  26. - **Test hooks**: `.claude/hooks/notify.sh input` and `.claude/hooks/notify.sh complete`
  27. - **View logs**: `tail -f .claude/logs/context-injection.log` and `tail -f .claude/logs/security-scan.log`
  28.  
  29. ### Command Templates (used as Claude Code slash commands)
  30.  
  31. - `/full-context` - Comprehensive context gathering and analysis
  32. - `/code-review` - Multi-perspective code quality analysis
  33. - `/update-docs` - Synchronize documentation with code changes
  34. - `/create-docs` - Generate initial documentation structure
  35. - `/refactor` - Intelligent code restructuring
  36. - `/handoff` - Session continuity and context preservation
  37.  
  38. ### n8n Workflow Development Suite (9 Commands, 4,500+ Lines)
  39.  
  40. #### Core Development Commands
  41.  
  42. - `/n8n-workflow` - Design and build n8n workflows with AI assistance
  43. - `/n8n-debug` - Diagnose and troubleshoot n8n workflow issues
  44. - `/n8n-optimize` - Analyze and optimize n8n workflow performance
  45. - `/n8n-integrate` - Design secure integrations with external services
  46. - `/n8n-deploy` - Plan and execute production deployment strategies
  47.  
  48. #### Quality Assurance & Operations
  49.  
  50. - `/n8n-validate` - Comprehensive workflow validation and compliance checking
  51. - `/n8n-test` - Automated testing framework with CI/CD integration
  52. - `/n8n-monitor` - Real-time monitoring and operational intelligence
  53.  
  54. #### API Integration & Deployment
  55.  
  56. - `/n8n-deploy-api` - Direct workflow deployment to n8n instances via REST API
  57.  
  58. ### Hook Verification
  59.  
  60. - `/hook-setup` - Comprehensive setup verification and testing (multi-agent orchestration)
  61. - `chmod +x hooks/*.sh` - Ensure hook scripts are executable
  62. - `tail -f .claude/logs/n8n-context-injection.log` - Monitor n8n context loading behavior
  63.  
  64. ### n8n Framework Operations
  65.  
  66. - **Topic-specific context**: `@docs/n8n-topics/{topic}.md` for targeted documentation
  67. - **Intelligent context loading**: Automatic detection and loading of relevant n8n topics
  68. - **Enhanced settings**: Use `hooks/setup/settings-n8n.json.template` for n8n-optimized configuration
  69. - **Query optimization**: Use compound keywords for better topic detection (e.g., "workflow deployment", "API integration")
  70.  
  71. ### n8n API Integration & Deployment
  72.  
  73. - **Direct Deployment**: `./scripts/deploy-workflow.py workflow.json` for API-based deployment
  74. - **Interactive Setup**: `./scripts/setup-n8n-api.sh setup` for environment configuration
  75. - **Environment Management**: Support for dev/staging/production environments
  76. - **Automated Testing**: Post-deployment validation and health checks
  77. - **CI/CD Integration**: GitHub Actions workflows for automated deployment pipelines
  78.  
  79. ## Core Architecture
  80.  
  81. ### Hook System (`hooks/`)
  82.  
  83. Lifecycle automation that executes at specific Claude Code events:
  84.  
  85. - **Context Injection**: Automatically includes project docs in sub-agents and Gemini consultations
  86. - **n8n Intelligence**: `n8n-context-injector.sh` with query analysis and smart topic loading
  87. - **Security Scanning**: Prevents accidental exposure of secrets in MCP calls
  88. - **Audio Notifications**: Cross-platform audio feedback for task completion and input needs
  89. - **Session Continuity**: Maintains context between development sessions
  90.  
  91. ### Command System (`commands/`)
  92.  
  93. Markdown-based orchestration templates that coordinate multi-agent workflows:
  94.  
  95. - Auto-load appropriate documentation tiers
  96. - Spawn specialized agents based on complexity
  97. - Integrate MCP servers when external expertise helps
  98. - Scale from simple analysis to sophisticated multi-agent coordination
  99. - **n8n-Specific Commands**: 9 specialized templates for complete n8n development lifecycle with API integration
  100.  
  101. ### Documentation System (`docs/`)
  102.  
  103. 3-tier AI-optimized structure:
  104.  
  105. - **Tier 1 (Foundation)**: System-wide stable documentation (`/docs/ai-context/`)
  106. - **Tier 2 (Component)**: Architectural charters for major components
  107. - **Tier 3 (Feature)**: Granular docs co-located with code
  108.  
  109. ### n8n Framework Integration
  110.  
  111. - **Intelligent Documentation System**: 12 specialized topic chunks with automatic context injection
  112. - **Smart Context Loading**: Query analysis determines optimal documentation context (50-200KB vs 2.5MB+)
  113. - **Topic-Based Organization**: Core concepts, workflows, integrations, API, hosting, and advanced features
  114. - **Automatic Detection**: `n8n-context-injector.sh` hook intelligently loads relevant topics based on queries
  115.  
  116. ## Multi-Agent Workflows & Context Injection
  117.  
  118. ### Automatic Context Injection for Sub-Agents
  119.  
  120. When using the Task tool to spawn sub-agents, core project context (CLAUDE.md, project-structure.md, docs-overview.md) is automatically injected via the subagent-context-injector hook. This ensures consistent knowledge across all AI agents without manual specification.
  121.  
  122. ### Context Efficiency
  123.  
  124. - Uses `@` references for documentation loading instead of content duplication
  125. - Token-efficient design for large codebases
  126. - Maintains context across sessions through handoff documentation
  127.  
  128. ## MCP Server Integrations
  129.  
  130. ### Gemini Consultation Server
  131.  
  132. **Automatic Context Injection:**
  133.  
  134. - `/docs/ai-context/project-structure.md` - Complete project structure and tech stack
  135. - `/MCP-ASSISTANT-RULES.md` - Project-specific coding standards
  136.  
  137. **Usage for complex problems:**
  138.  
  139. ```python
  140. mcp__gemini__consult_gemini(
  141. specific_question="How should I optimize this framework?",
  142. problem_description="Need to reduce token usage in context injection",
  143. code_context="Current injection includes full documentation...",
  144. attached_files=["hooks/subagent-context-injector.sh"],
  145. preferred_approach="optimize"
  146. )
  147. ```
  148.  
  149. ### Context7 Documentation Server
  150.  
  151. **Usage for external library documentation:**
  152.  
  153. ```python
  154. mcp__context7__resolve_library_id(libraryName="n8n")
  155. mcp__context7__get_library_docs(
  156. context7CompatibleLibraryID="/n8n-io/n8n",
  157. topic="workflows",
  158. tokens=8000
  159. )
  160. ```
  161.  
  162. ## Security & Configuration
  163.  
  164. ### Hook Security Model
  165.  
  166. - All MCP calls are scanned for sensitive data before execution
  167. - Pattern-based detection for API keys, passwords, and secrets
  168. - Configurable via `hooks/config/sensitive-patterns.json`
  169. - Comprehensive logging to `.claude/logs/`
  170.  
  171. ### Configuration Management
  172.  
  173. - Template-based configuration in `hooks/setup/settings.json.template`
  174. - Environment variable substitution with `${WORKSPACE}` references
  175. - Cross-platform compatibility (macOS, Linux, Windows)
  176.  
  177. ## Framework-Specific Guidelines
  178.  
  179. ### Working with the Kit
  180.  
  181. - **Documentation Updates**: Use `/update-docs` after modifying templates or hooks
  182. - **Hook Development**: Test hooks individually before integration
  183. - **Command Customization**: Modify markdown templates in `commands/` directory
  184. - **Context Management**: Leverage automatic injection rather than manual context specification
  185.  
  186. ### Installation Patterns
  187.  
  188. 1. **Remote Installation**: curl-based download → extract → setup
  189. 2. **Local Setup**: Interactive configuration → copy files → set permissions
  190. 3. **Conflict Resolution**: User choice for existing files → consistent application
  191. 4. **Component Selection**: Optional MCP servers → notifications → appropriate hooks
  192.  
  193. ### File Organization Standards
  194.  
  195. - Keep shell scripts under 200 lines when possible
  196. - Single responsibility per hook with clear purpose
  197. - Markdown templates should be self-contained and reusable
  198. - JSON configuration should be environment-agnostic with variable substitution
  199.  
  200. ## Development Workflow
  201.  
  202. ### Typical Framework Development
  203.  
  204. ```bash
  205. # Understand current state
  206. /full-context "analyze hook system performance"
  207.  
  208. # Implement changes to hooks or commands
  209. # ... modify files ...
  210.  
  211. # Verify security and functionality
  212. /code-review "review hook modifications"
  213.  
  214. # Update documentation
  215. /update-docs "document hook improvements"
  216.  
  217. # Test installation
  218. ./setup.sh # or use the hooks test commands
  219.  
  220. # Preserve context
  221. /handoff "completed hook optimization"
  222. ```
  223.  
  224. ### n8n Framework Development
  225.  
  226. ```bash
  227. # Design new n8n workflows
  228. /n8n-workflow "create customer onboarding automation"
  229. # Auto-loads: workflows.md + nodes-integrations.md + code-development.md
  230.  
  231. # Debug workflow issues
  232. /n8n-debug "workflow failing at HTTP node with 401 error"
  233. # Auto-loads: advanced.md + workflows.md + nodes-integrations.md
  234.  
  235. # Optimize workflow performance
  236. /n8n-optimize "reduce execution time for large dataset processing"
  237. # Auto-loads: advanced.md + hosting-deployment.md + workflows.md
  238.  
  239. # Build external integrations
  240. /n8n-integrate "connect to Salesforce CRM with OAuth"
  241. # Auto-loads: nodes-integrations.md + data-management.md + api.md
  242.  
  243. # Deploy to production
  244. /n8n-deploy "production deployment on AWS with high availability"
  245. # Auto-loads: hosting-deployment.md + user-management.md + advanced.md
  246.  
  247. # Validate workflow quality
  248. /n8n-validate "check workflow for security and performance compliance"
  249. # Auto-loads: workflows.md + advanced.md + data-management.md
  250.  
  251. # Test workflow thoroughly
  252. /n8n-test "create comprehensive test suite for workflow"
  253. # Auto-loads: workflows.md + code-development.md + api.md
  254.  
  255. # Monitor workflow operations
  256. /n8n-monitor "setup real-time monitoring and alerting"
  257. # Auto-loads: hosting-deployment.md + advanced.md + workflows.md
  258.  
  259. # Deploy via API
  260. /n8n-deploy-api "deploy workflow directly to n8n instance"
  261. # Auto-loads: api.md + hosting-deployment.md + workflows.md
  262.  
  263. # General n8n analysis
  264. /full-context "analyze n8n integration architecture"
  265. # Auto-loads: core.md + workflows.md + hosting-deployment.md
  266.  
  267. # Update documentation after changes
  268. /update-docs "document new n8n workflow capabilities"
  269.  
  270. # Preserve context for future sessions
  271. /handoff "completed n8n workflow development with specialized commands"
  272. ```
  273.  
  274. ### Command Template Development
  275.  
  276. 1. Copy existing template from `commands/`
  277. 2. Modify orchestration logic and agent strategies
  278. 3. Test with `/command-name` in Claude Code
  279. 4. Update documentation tier references as needed
  280. 5. Verify context injection works correctly
  281.  
  282. ## Important Constraints
  283.  
  284. - **Read-only for most operations**: This is a framework, not executable code
  285. - **Shell script execution**: Hooks run with user permissions
  286. - **Cross-platform compatibility**: All scripts must work on macOS, Linux, and Windows
  287. - **Token efficiency**: Prioritize @ references over content duplication
  288. - **Security first**: All external AI calls must pass security scanning
  289.  
  290. ## n8n Framework Integration
  291.  
  292. ### Intelligent Documentation System
  293.  
  294. The framework includes a sophisticated n8n documentation system with automatic context injection:
  295.  
  296. - **12 Topic Chunks**: Comprehensive n8n knowledge split from 84,849-line compiled documentation
  297. - **Smart Context Loading**: Automatic detection and loading of relevant topics (typically 50-200KB vs 2.5MB+)
  298. - **Query Intelligence**: Keyword analysis determines optimal documentation context
  299. - **Efficient Token Usage**: 95%+ reduction in typical context loading for n8n queries
  300.  
  301. ### n8n Documentation Topics
  302.  
  303. - `core.md` - Fundamental concepts and glossary (416 lines)
  304. - `workflows.md` - Workflow creation and management (982 lines)
  305. - `nodes-integrations.md` - All available nodes and integrations (58,090 lines - largest)
  306. - `code-development.md` - Python/JS/AI development patterns (4,096 lines)
  307. - `api.md` - REST API and programmatic access (279 lines)
  308. - `hosting-deployment.md` - Infrastructure and deployment (5,749 lines)
  309. - `data-management.md` - Credentials and data handling (982 lines)
  310. - `user-management.md` - Users, permissions, security (978 lines)
  311. - `cloud-features.md` - n8n Cloud specific features (1,608 lines)
  312. - `learning.md` - Tutorials and educational content (4,041 lines)
  313. - `advanced.md` - Error handling and troubleshooting (12,137 lines)
  314. - `getting-started.md` - Setup and migration (205 lines)
  315.  
  316. ### Automatic Context Loading Examples
  317.  
  318. ```bash
  319. # User query: "How do I create a workflow with API calls?"
  320. # System detects: "workflow" + "api" keywords
  321. # Auto-loads: workflows.md + api.md + nodes-integrations.md
  322.  
  323. # User query: "Deploy n8n with Docker"
  324. # System detects: "deploy" + "docker" keywords
  325. # Auto-loads: hosting-deployment.md + getting-started.md
  326. ```
  327.  
  328. ### Manual Context Loading for Complex Tasks
  329.  
  330. ```markdown
  331. # Load specific topics for comprehensive analysis:
  332. @docs/n8n-topics/index.md # Topic overview first
  333. @docs/n8n-topics/workflows.md # Workflow development
  334. @docs/n8n-topics/code-development.md # Code integration
  335.  
  336. # For deployment-focused tasks:
  337. @docs/n8n-topics/hosting-deployment.md
  338. @docs/n8n-topics/user-management.md
  339. @docs/n8n-topics/advanced.md
  340. ```
  341.  
  342. ### Framework Configuration
  343.  
  344. To enable the enhanced n8n framework:
  345.  
  346. 1. **Enhanced Settings**: Copy `hooks/setup/settings-n8n.json.template` to `.claude/settings.json`
  347. 2. **Topic Verification**: Ensure all 12 topic files exist in `docs/n8n-topics/`
  348. 3. **Hook Integration**: Verify `n8n-context-injector.sh` is executable and properly configured
  349. 4. **Logging Setup**: Monitor `.claude/logs/n8n-context-injection.log` for system behavior
  350. 5. **Topic Mapping**: Reference `docs/n8n-topics/topic-map.json` for keyword-to-topic relationships
  351.  
  352. When working with n8n:
  353.  
  354. - Leverage automatic context injection for most queries
  355. - Use Context7 MCP for up-to-date n8n API documentation beyond the framework
  356. - Follow n8n 1.0+ patterns (depth-first execution, Python Code node support)
  357. - Combine framework intelligence with deployment automation hooks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement