@paulduvall/claude-dev-toolkit 0.0.1-alpha.2 → 0.0.1-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -37
  3. package/bin/claude-commands +307 -65
  4. package/commands/active/xarchitecture.md +393 -0
  5. package/commands/active/xconfig.md +127 -0
  6. package/commands/active/xcontinue.md +92 -0
  7. package/commands/active/xdebug.md +130 -0
  8. package/commands/active/xdocs.md +178 -0
  9. package/commands/active/xexplore.md +94 -0
  10. package/commands/active/xgit.md +149 -0
  11. package/commands/active/xpipeline.md +152 -0
  12. package/commands/active/xquality.md +96 -0
  13. package/commands/active/xrefactor.md +198 -0
  14. package/commands/active/xrelease.md +142 -0
  15. package/commands/active/xsecurity.md +92 -0
  16. package/commands/active/xspec.md +174 -0
  17. package/commands/active/xtdd.md +151 -0
  18. package/commands/active/xtest.md +89 -0
  19. package/commands/active/xverify.md +80 -0
  20. package/commands/experiments/xact.md +742 -0
  21. package/commands/experiments/xanalytics.md +113 -0
  22. package/commands/experiments/xanalyze.md +70 -0
  23. package/commands/experiments/xapi.md +161 -0
  24. package/commands/experiments/xatomic.md +112 -0
  25. package/commands/experiments/xaws.md +85 -0
  26. package/commands/experiments/xcicd.md +337 -0
  27. package/commands/experiments/xcommit.md +122 -0
  28. package/commands/experiments/xcompliance.md +182 -0
  29. package/commands/experiments/xconstraints.md +89 -0
  30. package/commands/experiments/xcoverage.md +90 -0
  31. package/commands/experiments/xdb.md +102 -0
  32. package/commands/experiments/xdesign.md +121 -0
  33. package/commands/experiments/xdevcontainer.md +238 -0
  34. package/commands/experiments/xevaluate.md +111 -0
  35. package/commands/experiments/xfootnote.md +12 -0
  36. package/commands/experiments/xgenerate.md +117 -0
  37. package/commands/experiments/xgovernance.md +149 -0
  38. package/commands/experiments/xgreen.md +66 -0
  39. package/commands/experiments/xiac.md +118 -0
  40. package/commands/experiments/xincident.md +137 -0
  41. package/commands/experiments/xinfra.md +115 -0
  42. package/commands/experiments/xknowledge.md +115 -0
  43. package/commands/experiments/xmaturity.md +120 -0
  44. package/commands/experiments/xmetrics.md +118 -0
  45. package/commands/experiments/xmonitoring.md +128 -0
  46. package/commands/experiments/xnew.md +903 -0
  47. package/commands/experiments/xobservable.md +114 -0
  48. package/commands/experiments/xoidc.md +165 -0
  49. package/commands/experiments/xoptimize.md +115 -0
  50. package/commands/experiments/xperformance.md +112 -0
  51. package/commands/experiments/xplanning.md +131 -0
  52. package/commands/experiments/xpolicy.md +115 -0
  53. package/commands/experiments/xproduct.md +98 -0
  54. package/commands/experiments/xreadiness.md +75 -0
  55. package/commands/experiments/xred.md +55 -0
  56. package/commands/experiments/xrisk.md +128 -0
  57. package/commands/experiments/xrules.md +124 -0
  58. package/commands/experiments/xsandbox.md +120 -0
  59. package/commands/experiments/xscan.md +102 -0
  60. package/commands/experiments/xsetup.md +123 -0
  61. package/commands/experiments/xtemplate.md +116 -0
  62. package/commands/experiments/xtrace.md +212 -0
  63. package/commands/experiments/xux.md +171 -0
  64. package/commands/experiments/xvalidate.md +104 -0
  65. package/commands/experiments/xworkflow.md +113 -0
  66. package/hooks/.smellrc.example.json +19 -0
  67. package/hooks/README.md +263 -0
  68. package/hooks/check-commit-signing.py +127 -0
  69. package/hooks/check-complexity.py +38 -0
  70. package/hooks/check-security.py +37 -0
  71. package/hooks/claude-wrapper.sh +29 -0
  72. package/hooks/config.py +110 -0
  73. package/hooks/file-logger.sh +100 -0
  74. package/hooks/lib/argument-parser.sh +427 -0
  75. package/hooks/lib/config-constants.sh +230 -0
  76. package/hooks/lib/context-manager.sh +560 -0
  77. package/hooks/lib/error-handler.sh +423 -0
  78. package/hooks/lib/execution-engine.sh +444 -0
  79. package/hooks/lib/execution-results.sh +113 -0
  80. package/hooks/lib/execution-simulation.sh +114 -0
  81. package/hooks/lib/field-validators.sh +104 -0
  82. package/hooks/lib/file-utils.sh +398 -0
  83. package/hooks/lib/subagent-discovery.sh +468 -0
  84. package/hooks/lib/subagent-validator.sh +407 -0
  85. package/hooks/lib/validation-reporter.sh +134 -0
  86. package/hooks/on-error-debug.sh +226 -0
  87. package/hooks/pre-commit-quality.sh +204 -0
  88. package/hooks/pre-commit-test-runner.sh +132 -0
  89. package/hooks/pre-write-security.sh +115 -0
  90. package/hooks/prevent-credential-exposure.sh +279 -0
  91. package/hooks/security_bandit.py +177 -0
  92. package/hooks/security_checks.py +97 -0
  93. package/hooks/security_secrets.py +81 -0
  94. package/hooks/security_trojan.py +61 -0
  95. package/hooks/settings.example.json +52 -0
  96. package/hooks/smell_checks.py +238 -0
  97. package/hooks/smell_javascript.py +231 -0
  98. package/hooks/smell_python.py +110 -0
  99. package/hooks/smell_ruff.py +70 -0
  100. package/hooks/smell_types.py +72 -0
  101. package/hooks/subagent-trigger-simple.sh +202 -0
  102. package/hooks/subagent-trigger.sh +253 -0
  103. package/hooks/suppression.py +82 -0
  104. package/hooks/tab-color.sh +70 -0
  105. package/hooks/verify-before-edit.sh +135 -0
  106. package/lib/backup-restore-command.js +140 -0
  107. package/lib/base/base-command.js +252 -0
  108. package/lib/base/command-result.js +184 -0
  109. package/lib/config/constants.js +255 -0
  110. package/lib/config.js +48 -6
  111. package/lib/configure-command.js +428 -0
  112. package/lib/dependency-validator.js +64 -5
  113. package/lib/hook-installer-core.js +2 -2
  114. package/lib/installation-instruction-generator.js +213 -495
  115. package/lib/installer.js +134 -56
  116. package/lib/oidc-command.js +740 -0
  117. package/lib/services/backup-list-service.js +226 -0
  118. package/lib/services/backup-service.js +230 -0
  119. package/lib/services/command-installer-service.js +217 -0
  120. package/lib/services/logger-service.js +201 -0
  121. package/lib/services/package-manager-service.js +319 -0
  122. package/lib/services/platform-instruction-service.js +294 -0
  123. package/lib/services/recovery-instruction-service.js +348 -0
  124. package/lib/services/restore-service.js +221 -0
  125. package/lib/setup-command.js +359 -0
  126. package/lib/setup-wizard.js +155 -262
  127. package/lib/uninstall-command.js +100 -0
  128. package/lib/utils/claude-path-config.js +184 -0
  129. package/lib/utils/file-system-utils.js +152 -0
  130. package/lib/utils.js +8 -4
  131. package/lib/verify-command.js +430 -0
  132. package/package.json +7 -3
  133. package/scripts/postinstall.js +172 -157
  134. package/subagents/debug-specialist.md +7 -0
  135. package/templates/README.md +115 -0
  136. package/templates/basic-settings.json +30 -0
  137. package/templates/comprehensive-settings.json +57 -0
  138. package/templates/global-claude.md +344 -0
  139. package/templates/hybrid-hook-config.yaml +132 -0
  140. package/templates/security-focused-settings.json +62 -0
  141. package/templates/subagent-hooks.yaml +188 -0
  142. package/lib/package-manager-service.js +0 -270
  143. package/subagents/debug-context.md +0 -197
@@ -0,0 +1,188 @@
1
+ # Claude Code Subagent-Hook Event Mapping Configuration
2
+ #
3
+ # This file defines which subagents should be automatically invoked
4
+ # during specific Claude Code events. Place this file at:
5
+ # ~/.claude/subagent-hooks.yaml
6
+ #
7
+ # Format:
8
+ # event_name:
9
+ # - subagent-name
10
+ # - another-subagent
11
+ #
12
+ # Available events:
13
+ # - pre_write: Before any file write/edit operation
14
+ # - post_write: After successful file write/edit
15
+ # - pre_commit: Before git commit operations
16
+ # - post_commit: After successful git commit
17
+ # - pre_test: Before running tests
18
+ # - post_test: After test execution
19
+ # - on_error: When an error occurs
20
+ # - security_check: Security validation events
21
+ # - code_review: Code review triggers
22
+ # - deployment: Deployment-related events
23
+
24
+ # File modification events
25
+ pre_write:
26
+ - security-auditor # Check for security issues before writing
27
+ - style-enforcer # Ensure code style compliance
28
+ - license-compliance-guardian # Verify license headers
29
+
30
+ post_write:
31
+ - documentation-curator # Update docs after code changes
32
+ - test-writer # Generate/update tests for new code
33
+
34
+ # Git workflow events
35
+ pre_commit:
36
+ - trunk-guardian # Ensure branch policies are followed
37
+ - security-auditor # Final security check before commit
38
+ - contract-tester # Verify API contracts maintained
39
+
40
+ post_commit:
41
+ - audit-trail-verifier # Log changes for audit trail
42
+ - change-scoper # Analyze change impact
43
+
44
+ # Testing events
45
+ pre_test:
46
+ - test-writer # Ensure adequate test coverage
47
+ - environment-guardian # Validate test environment
48
+
49
+ post_test:
50
+ - performance-guardian # Analyze performance results
51
+ - observability-engineer # Check monitoring coverage
52
+
53
+ on_test_failure:
54
+ - debug-specialist # Diagnose test failures
55
+ - test-writer # Suggest test fixes
56
+
57
+ # Build and deployment events
58
+ pre_build:
59
+ - dependency-steward # Check dependency versions
60
+ - sbom-provenance # Generate software bill of materials
61
+
62
+ pre_deployment:
63
+ - deployment-strategist # Plan deployment approach
64
+ - environment-guardian # Validate target environment
65
+ - rollback-first-responder # Prepare rollback plan
66
+
67
+ post_deployment:
68
+ - observability-engineer # Verify monitoring active
69
+ - performance-guardian # Check performance metrics
70
+
71
+ # Error handling events
72
+ on_error:
73
+ - debug-specialist # Analyze and diagnose errors
74
+ - rollback-first-responder # Prepare recovery plan
75
+
76
+ on_security_violation:
77
+ - security-auditor # Deep security analysis
78
+ - audit-trail-verifier # Document violation
79
+
80
+ # Code review events
81
+ code_review:
82
+ - code-review-assistant # Automated review suggestions
83
+ - requirements-reviewer # Check requirements alignment
84
+ - api-guardian # Verify API compatibility
85
+
86
+ # Continuous improvement events
87
+ daily_analysis:
88
+ - data-steward # Data quality check
89
+ - performance-guardian # Performance trending
90
+ - dependency-steward # Dependency updates
91
+
92
+ weekly_review:
93
+ - product-owner-proxy # Business alignment check
94
+ - workflow-coordinator # Process optimization
95
+
96
+ # CI/CD pipeline events
97
+ pipeline_failure:
98
+ - ci-pipeline-curator # Diagnose pipeline issues
99
+ - debug-specialist # Investigate failures
100
+
101
+ pipeline_success:
102
+ - continuous-release-orchestrator # Plan next release
103
+ - audit-trail-verifier # Document successful build
104
+
105
+ # Custom event examples (add your own)
106
+ custom_security_scan:
107
+ - security-auditor
108
+ - license-compliance-guardian
109
+ - sbom-provenance
110
+
111
+ custom_performance_check:
112
+ - performance-guardian
113
+ - observability-engineer
114
+ - debug-specialist
115
+
116
+ # Priority configurations (optional)
117
+ # Define execution order and blocking behavior
118
+ priorities:
119
+ security-auditor:
120
+ priority: 1 # Execute first
121
+ blocking: true # Block operation if issues found
122
+
123
+ style-enforcer:
124
+ priority: 2
125
+ blocking: false # Non-blocking, just warnings
126
+
127
+ test-writer:
128
+ priority: 3
129
+ blocking: false
130
+
131
+ documentation-curator:
132
+ priority: 4
133
+ blocking: false
134
+
135
+ # Subagent configuration overrides (optional)
136
+ # Override default subagent settings for specific events
137
+ overrides:
138
+ pre_deployment:
139
+ deployment-strategist:
140
+ timeout: 300 # 5 minutes for deployment planning
141
+ tools: "Read, Grep, Glob, Bash" # Restricted tools
142
+
143
+ environment-guardian:
144
+ timeout: 120
145
+ require_approval: true # Human approval needed
146
+
147
+ on_error:
148
+ debug-specialist:
149
+ timeout: 600 # 10 minutes for debugging
150
+ tools: "all" # Full tool access for debugging
151
+
152
+ # Event conditions (optional)
153
+ # Define conditions for event triggering
154
+ conditions:
155
+ pre_write:
156
+ file_patterns:
157
+ - "*.py" # Only Python files
158
+ - "*.js" # Only JavaScript files
159
+ - "*.ts" # Only TypeScript files
160
+
161
+ exclude_patterns:
162
+ - "*.test.*" # Skip test files
163
+ - "*.spec.*" # Skip spec files
164
+ - "__pycache__/*" # Skip cache directories
165
+
166
+ code_review:
167
+ branch_patterns:
168
+ - "feature/*" # Feature branches
169
+ - "hotfix/*" # Hotfix branches
170
+
171
+ exclude_branches:
172
+ - "main" # Skip main branch
173
+ - "develop" # Skip develop branch
174
+
175
+ # Notification settings (optional)
176
+ notifications:
177
+ on_blocking_event:
178
+ log_level: "error"
179
+ alert_user: true
180
+
181
+ on_security_violation:
182
+ log_level: "critical"
183
+ alert_user: true
184
+ notify_webhook: "${SECURITY_WEBHOOK_URL}"
185
+
186
+ on_success:
187
+ log_level: "info"
188
+ alert_user: false
@@ -1,270 +0,0 @@
1
- /**
2
- * Package Manager Service
3
- *
4
- * Handles cross-platform package manager operations and configurations.
5
- * Extracted from DependencyValidator as part of Phase 1 bloater refactoring.
6
- *
7
- * Features:
8
- * - Multi-platform package manager support
9
- * - Package name mapping across different managers
10
- * - Command generation for install/check operations
11
- * - Platform-specific package manager detection
12
- */
13
-
14
- const { execSync } = require('child_process');
15
- const PlatformUtils = require('./platform-utils');
16
-
17
- class PackageManagerService {
18
- constructor() {
19
- this.platformUtils = new PlatformUtils();
20
- this.config = {
21
- packageManagers: this._createPackageManagersConfig(),
22
- dependencyMappings: this._createDependencyMappings()
23
- };
24
- }
25
-
26
- /**
27
- * Create package managers configuration by platform
28
- * @returns {Object} Package managers by platform
29
- * @private
30
- */
31
- _createPackageManagersConfig() {
32
- return {
33
- linux: [
34
- { name: 'apt', install: 'sudo apt-get install {package}', check: 'dpkg -l {package}' },
35
- { name: 'yum', install: 'sudo yum install {package}', check: 'rpm -q {package}' },
36
- { name: 'dnf', install: 'sudo dnf install {package}', check: 'rpm -q {package}' },
37
- { name: 'pacman', install: 'sudo pacman -S {package}', check: 'pacman -Q {package}' },
38
- { name: 'snap', install: 'sudo snap install {package}', check: 'snap list {package}' }
39
- ],
40
- darwin: [
41
- { name: 'brew', install: 'brew install {package}', check: 'brew list {package}' },
42
- { name: 'port', install: 'sudo port install {package}', check: 'port installed {package}' },
43
- { name: 'npm', install: 'npm install -g {package}', check: 'npm list -g {package}' }
44
- ],
45
- win32: [
46
- { name: 'chocolatey', install: 'choco install {package}', check: 'choco list --local-only {package}' },
47
- { name: 'winget', install: 'winget install {package}', check: 'winget list {package}' },
48
- { name: 'npm', install: 'npm install -g {package}', check: 'npm list -g {package}' },
49
- { name: 'scoop', install: 'scoop install {package}', check: 'scoop list {package}' }
50
- ]
51
- };
52
- }
53
-
54
- /**
55
- * Create dependency mappings for package managers
56
- * @returns {Object} Dependency mappings by tool and platform
57
- * @private
58
- */
59
- _createDependencyMappings() {
60
- return {
61
- git: {
62
- linux: { apt: 'git', yum: 'git', dnf: 'git', pacman: 'git' },
63
- darwin: { brew: 'git' },
64
- win32: { chocolatey: 'git', winget: 'Git.Git' }
65
- },
66
- python: {
67
- linux: { apt: 'python3', yum: 'python3', dnf: 'python3' },
68
- darwin: { brew: 'python@3.11' },
69
- win32: { chocolatey: 'python', winget: 'Python.Python.3' }
70
- },
71
- docker: {
72
- linux: { apt: 'docker.io', snap: 'docker' },
73
- darwin: { brew: 'docker' },
74
- win32: { chocolatey: 'docker-desktop' }
75
- }
76
- };
77
- }
78
-
79
- /**
80
- * Get package managers for a specific platform
81
- * @param {string} platform - Platform identifier (optional, defaults to current)
82
- * @returns {Array<Object>} List of package managers for the platform
83
- */
84
- getPackageManagersForPlatform(platform = this.platformUtils.getCurrentPlatform()) {
85
- return this.config.packageManagers[platform] || [];
86
- }
87
-
88
- /**
89
- * Get package name for a specific dependency and package manager
90
- * @param {string} dependencyName - Name of the dependency
91
- * @param {string} packageManagerName - Name of the package manager
92
- * @param {string} platform - Platform identifier (optional, defaults to current)
93
- * @returns {string} Mapped package name or original dependency name
94
- */
95
- getPackageName(dependencyName, packageManagerName, platform = this.platformUtils.getCurrentPlatform()) {
96
- const dependencyMapping = this.config.dependencyMappings[dependencyName];
97
-
98
- if (dependencyMapping && dependencyMapping[platform] && dependencyMapping[platform][packageManagerName]) {
99
- return dependencyMapping[platform][packageManagerName];
100
- }
101
-
102
- return dependencyName;
103
- }
104
-
105
- /**
106
- * Generate install command for a package
107
- * @param {string} dependencyName - Name of the dependency
108
- * @param {string} packageManagerName - Name of the package manager
109
- * @param {string} platform - Platform identifier (optional, defaults to current)
110
- * @returns {string|null} Install command or null if package manager not found
111
- */
112
- generateInstallCommand(dependencyName, packageManagerName, platform = this.platformUtils.getCurrentPlatform()) {
113
- const packageManagers = this.getPackageManagersForPlatform(platform);
114
- const packageManager = packageManagers.find(pm => pm.name === packageManagerName);
115
-
116
- if (!packageManager) {
117
- return null;
118
- }
119
-
120
- const packageName = this.getPackageName(dependencyName, packageManagerName, platform);
121
- return packageManager.install.replace('{package}', packageName);
122
- }
123
-
124
- /**
125
- * Generate check command for a package
126
- * @param {string} dependencyName - Name of the dependency
127
- * @param {string} packageManagerName - Name of the package manager
128
- * @param {string} platform - Platform identifier (optional, defaults to current)
129
- * @returns {string|null} Check command or null if package manager not found
130
- */
131
- generateCheckCommand(dependencyName, packageManagerName, platform = this.platformUtils.getCurrentPlatform()) {
132
- const packageManagers = this.getPackageManagersForPlatform(platform);
133
- const packageManager = packageManagers.find(pm => pm.name === packageManagerName);
134
-
135
- if (!packageManager) {
136
- return null;
137
- }
138
-
139
- const packageName = this.getPackageName(dependencyName, packageManagerName, platform);
140
- return packageManager.check.replace('{package}', packageName);
141
- }
142
-
143
- /**
144
- * Check if a package manager is available on the system
145
- * @param {string} packageManagerName - Name of the package manager
146
- * @returns {boolean} True if package manager is available
147
- */
148
- isPackageManagerAvailable(packageManagerName) {
149
- try {
150
- const command = this.platformUtils.getPathCommand();
151
- execSync(`${command} ${packageManagerName}`, {
152
- encoding: 'utf8',
153
- timeout: 3000,
154
- stdio: 'pipe'
155
- });
156
- return true;
157
- } catch (error) {
158
- return false;
159
- }
160
- }
161
-
162
- /**
163
- * Get available package managers for the current platform
164
- * @param {string} platform - Platform identifier (optional, defaults to current)
165
- * @returns {Array<Object>} List of available package managers
166
- */
167
- getAvailablePackageManagers(platform = this.platformUtils.getCurrentPlatform()) {
168
- const allManagers = this.getPackageManagersForPlatform(platform);
169
- return allManagers.filter(pm => this.isPackageManagerAvailable(pm.name));
170
- }
171
-
172
- /**
173
- * Get the best available package manager for a platform
174
- * @param {string} platform - Platform identifier (optional, defaults to current)
175
- * @returns {Object|null} Best available package manager or null
176
- */
177
- getBestAvailablePackageManager(platform = this.platformUtils.getCurrentPlatform()) {
178
- const availableManagers = this.getAvailablePackageManagers(platform);
179
-
180
- // Return the first available manager (they're ordered by preference)
181
- return availableManagers.length > 0 ? availableManagers[0] : null;
182
- }
183
-
184
- /**
185
- * Generate package manager options for installation instructions
186
- * @param {string} dependencyName - Name of the dependency
187
- * @param {string} platform - Platform identifier (optional, defaults to current)
188
- * @returns {Array<Object>} List of package manager options
189
- */
190
- generatePackageManagerOptions(dependencyName, platform = this.platformUtils.getCurrentPlatform()) {
191
- const packageManagers = this.getPackageManagersForPlatform(platform);
192
- const options = [];
193
-
194
- for (const pm of packageManagers) {
195
- const packageName = this.getPackageName(dependencyName, pm.name, platform);
196
- const installCommand = pm.install.replace('{package}', packageName);
197
- const checkCommand = pm.check.replace('{package}', packageName);
198
-
199
- options.push({
200
- name: pm.name,
201
- command: installCommand,
202
- check: checkCommand,
203
- packageName: packageName,
204
- available: this.isPackageManagerAvailable(pm.name)
205
- });
206
- }
207
-
208
- return options;
209
- }
210
-
211
- /**
212
- * Check if a specific package is installed
213
- * @param {string} dependencyName - Name of the dependency
214
- * @param {string} packageManagerName - Name of the package manager
215
- * @param {string} platform - Platform identifier (optional, defaults to current)
216
- * @returns {boolean} True if package is installed
217
- */
218
- isPackageInstalled(dependencyName, packageManagerName, platform = this.platformUtils.getCurrentPlatform()) {
219
- const checkCommand = this.generateCheckCommand(dependencyName, packageManagerName, platform);
220
-
221
- if (!checkCommand) {
222
- return false;
223
- }
224
-
225
- try {
226
- execSync(checkCommand, {
227
- encoding: 'utf8',
228
- timeout: 5000,
229
- stdio: 'pipe'
230
- });
231
- return true;
232
- } catch (error) {
233
- return false;
234
- }
235
- }
236
-
237
- /**
238
- * Execute a package manager command safely
239
- * @param {string} command - Command to execute
240
- * @param {Object} options - Execution options
241
- * @returns {Object} Execution result
242
- */
243
- executePackageManagerCommand(command, options = {}) {
244
- const defaultOptions = {
245
- encoding: 'utf8',
246
- timeout: 30000, // 30 seconds for package operations
247
- stdio: 'pipe'
248
- };
249
-
250
- const execOptions = { ...defaultOptions, ...options };
251
-
252
- try {
253
- const output = execSync(command, execOptions);
254
- return {
255
- success: true,
256
- output: output.toString(),
257
- command: command
258
- };
259
- } catch (error) {
260
- return {
261
- success: false,
262
- error: error.message,
263
- command: command,
264
- exitCode: error.status
265
- };
266
- }
267
- }
268
- }
269
-
270
- module.exports = PackageManagerService;
@@ -1,197 +0,0 @@
1
- # Debug Context Management System
2
-
3
- ## Overview
4
- This system enables the Debug Specialist sub-agent to maintain persistent debugging context across multiple interactions, building comprehensive understanding of complex issues.
5
-
6
- ## Context Structure
7
-
8
- ### Debug Session Context
9
- ```json
10
- {
11
- "session_id": "debug_session_[timestamp]",
12
- "issue_summary": "Brief description of the main problem",
13
- "status": "active|investigating|resolved|escalated",
14
- "priority": "low|medium|high|critical",
15
- "created_at": "ISO timestamp",
16
- "updated_at": "ISO timestamp",
17
- "context": {
18
- "error_details": {
19
- "primary_error": "Main error message",
20
- "secondary_errors": ["Related error messages"],
21
- "stack_traces": ["Full stack trace data"],
22
- "error_frequency": "once|intermittent|frequent|constant",
23
- "reproduction_steps": ["Step-by-step reproduction"]
24
- },
25
- "environment": {
26
- "os": "Operating system details",
27
- "language_version": "Programming language version",
28
- "dependencies": ["Package versions and details"],
29
- "configuration": ["Relevant config settings"],
30
- "deployment_context": "local|staging|production"
31
- },
32
- "codebase_state": {
33
- "recent_changes": ["Recent commits or modifications"],
34
- "affected_files": ["Files related to the issue"],
35
- "test_status": "passing|failing|mixed",
36
- "last_working_state": "Known good configuration"
37
- },
38
- "investigation_history": [
39
- {
40
- "timestamp": "ISO timestamp",
41
- "action": "hypothesis_formed|test_executed|solution_attempted",
42
- "details": "What was done or discovered",
43
- "result": "success|failure|partial|inconclusive",
44
- "notes": "Additional observations"
45
- }
46
- ],
47
- "hypotheses": [
48
- {
49
- "theory": "Potential root cause explanation",
50
- "confidence": "low|medium|high",
51
- "status": "untested|testing|confirmed|rejected",
52
- "evidence": ["Supporting or contradicting evidence"],
53
- "test_plan": ["Steps to validate this hypothesis"]
54
- }
55
- ],
56
- "solutions_attempted": [
57
- {
58
- "approach": "Description of solution attempted",
59
- "implementation": "Code changes or actions taken",
60
- "result": "resolved|partial_fix|no_change|made_worse",
61
- "rollback_info": "How to undo if needed",
62
- "learned": "Key insights from this attempt"
63
- }
64
- ]
65
- }
66
- }
67
- ```
68
-
69
- ## Context Operations
70
-
71
- ### Initialize Debug Session
72
- ```markdown
73
- # Debug Session: [Issue Summary]
74
- **Session ID**: debug_session_[timestamp]
75
- **Status**: Active
76
- **Priority**: [Based on impact assessment]
77
-
78
- ## Current Understanding
79
- - **Primary Issue**: [Main problem description]
80
- - **Environment**: [Key environment details]
81
- - **Recent Changes**: [What changed recently]
82
-
83
- ## Investigation Plan
84
- 1. [Initial hypothesis or investigation step]
85
- 2. [Next planned action]
86
- 3. [Validation approach]
87
-
88
- *This is a persistent debugging session. Context will be maintained across interactions.*
89
- ```
90
-
91
- ### Update Context During Investigation
92
- ```markdown
93
- ## Investigation Update - [Timestamp]
94
-
95
- **Action Taken**: [What was investigated or attempted]
96
- **Result**: [Outcome of the action]
97
- **New Evidence**: [What was discovered]
98
-
99
- ### Updated Hypotheses
100
- - **Theory A**: [Status and confidence level]
101
- - **Theory B**: [New theory based on evidence]
102
-
103
- ### Next Steps
104
- 1. [Immediate next action]
105
- 2. [Follow-up investigation]
106
- ```
107
-
108
- ### Context Retrieval Prompts
109
- When the debug sub-agent is invoked, it should check for existing context:
110
-
111
- ```markdown
112
- **Context Check**: Is this related to an existing debug session?
113
- - Check for similar error patterns
114
- - Look for related file paths or components
115
- - Match against recent debugging history
116
-
117
- **If Related**: Load existing context and continue investigation
118
- **If New**: Initialize new debug session with context tracking
119
- ```
120
-
121
- ## Context Persistence Strategies
122
-
123
- ### File-Based Context Storage
124
- - Store context in `/debug-sessions/` directory
125
- - Use session IDs for file naming
126
- - JSON format for structured data
127
- - Markdown summaries for human readability
128
-
129
- ### Cross-Session Learning
130
- - Maintain database of resolved issues
131
- - Pattern recognition for similar problems
132
- - Solution effectiveness tracking
133
- - Environmental correlation analysis
134
-
135
- ### Context Sharing
136
- - Share context with other sub-agents when relevant
137
- - Security Analyst: For security-related debugging
138
- - Code Quality Reviewer: For quality-related issues
139
- - Architecture Consultant: For systemic problems
140
-
141
- ## Usage Patterns
142
-
143
- ### New Debug Session
144
- ```
145
- @debug-specialist I'm getting a "ModuleNotFoundError" in my Flask app
146
- → Creates new debug session
147
- → Initializes context tracking
148
- → Begins systematic investigation
149
- ```
150
-
151
- ### Continuing Existing Session
152
- ```
153
- @debug-specialist Update on the Flask ModuleNotFoundError - tried your suggestion but still failing
154
- → Loads existing session context
155
- → Updates investigation history
156
- → Adjusts hypotheses based on new information
157
- ```
158
-
159
- ### Complex Multi-Day Debugging
160
- ```
161
- Day 1: Initial investigation and hypothesis formation
162
- Day 2: Environment analysis and dependency checking
163
- Day 3: Solution implementation and validation
164
- → All context preserved across days
165
- → Investigation history maintained
166
- → Learning captured for future similar issues
167
- ```
168
-
169
- ## Integration with Slash Commands
170
-
171
- ### From /xdebug
172
- When `/xdebug` delegates to debug-specialist:
173
- - Include current error details in context initialization
174
- - Transfer any preliminary analysis done
175
- - Set appropriate priority based on error severity
176
-
177
- ### Context Handoff
178
- ```markdown
179
- **Debugging Handoff from /xdebug**
180
- - **Error**: [Error details]
181
- - **Preliminary Analysis**: [Any initial findings]
182
- - **User Request**: [What user specifically asked for]
183
- - **Context Priority**: [Suggested session priority]
184
-
185
- *Continuing with Debug Specialist sub-agent for persistent context and deep analysis...*
186
- ```
187
-
188
- ## Benefits of Persistent Context
189
-
190
- 1. **Avoid Repetition**: Don't re-investigate known facts
191
- 2. **Build Understanding**: Accumulate knowledge over time
192
- 3. **Pattern Recognition**: Identify recurring issues
193
- 4. **Solution Tracking**: Remember what works and what doesn't
194
- 5. **Learning**: Improve debugging effectiveness over time
195
- 6. **Collaboration**: Share context with team members and other agents
196
-
197
- This context management system transforms debugging from isolated problem-solving into systematic investigation with memory and learning capabilities.