moai-adk 0.5.4__py3-none-any.whl → 0.5.8__py3-none-any.whl

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.

Potentially problematic release.


This version of moai-adk might be problematic. Click here for more details.

Files changed (63) hide show
  1. moai_adk/__init__.py +1 -1
  2. moai_adk/cli/commands/init.py +4 -2
  3. moai_adk/cli/commands/status.py +4 -2
  4. moai_adk/cli/commands/update.py +4 -5
  5. moai_adk/core/project/initializer.py +13 -11
  6. moai_adk/core/project/phase_executor.py +10 -3
  7. moai_adk/core/template/processor.py +60 -1
  8. moai_adk/templates/.claude/agents/alfred/cc-manager.md +8 -0
  9. moai_adk/templates/.claude/agents/alfred/debug-helper.md +18 -0
  10. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +18 -0
  11. moai_adk/templates/.claude/agents/alfred/git-manager.md +38 -2
  12. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +18 -0
  13. moai_adk/templates/.claude/agents/alfred/project-manager.md +6 -0
  14. moai_adk/templates/.claude/agents/alfred/quality-gate.md +6 -0
  15. moai_adk/templates/.claude/agents/alfred/skill-factory.md +8 -0
  16. moai_adk/templates/.claude/agents/alfred/spec-builder.md +17 -0
  17. moai_adk/templates/.claude/agents/alfred/tag-agent.md +7 -1
  18. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +18 -0
  19. moai_adk/templates/.claude/agents/alfred/trust-checker.md +6 -0
  20. moai_adk/templates/.claude/commands/alfred/0-project.md +5 -1
  21. moai_adk/templates/.claude/commands/alfred/1-plan.md +18 -14
  22. moai_adk/templates/.claude/commands/alfred/2-run.md +6 -2
  23. moai_adk/templates/.claude/commands/alfred/3-sync.md +5 -1
  24. moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +5 -1
  25. moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +5 -1
  26. moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +5 -1
  27. moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +5 -1
  28. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +30 -273
  29. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +487 -129
  30. moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +603 -70
  31. moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +22 -2
  32. moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +22 -2
  33. moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +22 -2
  34. moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +22 -2
  35. moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +22 -2
  36. moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +22 -2
  37. moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +22 -2
  38. moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +25 -5
  39. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +152 -547
  40. moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +835 -878
  41. moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +665 -1151
  42. moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +138 -427
  43. moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +61 -53
  44. moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +99 -1181
  45. moai_adk/templates/.claude/skills/moai-spec-authoring/examples.md +541 -0
  46. moai_adk/templates/.claude/skills/moai-spec-authoring/reference.md +622 -0
  47. moai_adk/templates/.github/ISSUE_TEMPLATE/spec.yml +176 -0
  48. moai_adk/templates/.github/workflows/spec-issue-sync.yml +167 -0
  49. moai_adk/templates/.moai/config.json +5 -5
  50. moai_adk/templates/.moai/memory/CLAUDE-AGENTS-GUIDE.md +208 -0
  51. moai_adk/templates/.moai/memory/CLAUDE-PRACTICES.md +369 -0
  52. moai_adk/templates/.moai/memory/CLAUDE-RULES.md +539 -0
  53. moai_adk/templates/.moai/memory/{development-guide.md → DEVELOPMENT-GUIDE.md} +3 -3
  54. moai_adk/templates/.moai/memory/SKILLS-DESCRIPTION-POLICY.md +218 -0
  55. moai_adk/templates/.moai/memory/config-schema.md +444 -0
  56. moai_adk/templates/CLAUDE.md +149 -845
  57. {moai_adk-0.5.4.dist-info → moai_adk-0.5.8.dist-info}/METADATA +407 -336
  58. {moai_adk-0.5.4.dist-info → moai_adk-0.5.8.dist-info}/RECORD +63 -54
  59. /moai_adk/templates/.moai/memory/{gitflow-protection-policy.md → GITFLOW-PROTECTION-POLICY.md} +0 -0
  60. /moai_adk/templates/.moai/memory/{spec-metadata.md → SPEC-METADATA.md} +0 -0
  61. {moai_adk-0.5.4.dist-info → moai_adk-0.5.8.dist-info}/WHEEL +0 -0
  62. {moai_adk-0.5.4.dist-info → moai_adk-0.5.8.dist-info}/entry_points.txt +0 -0
  63. {moai_adk-0.5.4.dist-info → moai_adk-0.5.8.dist-info}/licenses/LICENSE +0 -0
@@ -9,14 +9,14 @@ allowed-tools:
9
9
  - TodoWrite
10
10
  ---
11
11
 
12
- # MoAI Essentials Debug v2.0
12
+ # MoAI Essentials Debug v2.1
13
13
 
14
14
  ## Skill Metadata
15
15
  | Field | Value |
16
16
  | ----- | ----- |
17
- | Version | 2.0.0 |
17
+ | Version | 2.1.0 |
18
18
  | Created | 2025-10-22 |
19
- | Last Updated | 2025-10-22 |
19
+ | Last Updated | 2025-10-27 |
20
20
  | Language Coverage | 23 languages + containers + distributed systems |
21
21
  | Allowed tools | Read, Write, Edit, Bash, TodoWrite |
22
22
  | Auto-load | On demand during Run stage (debug-helper) |
@@ -42,380 +42,86 @@ Comprehensive debugging support across all 23 MoAI-ADK languages with:
42
42
  - Performance bottleneck investigation
43
43
  - Automatically invoked via debug-helper sub-agent
44
44
 
45
- ## Debugger Matrix (23 Languages)
45
+ ---
46
46
 
47
- ### Systems Programming
47
+ ## Quick Reference: Debugger by Language
48
48
 
49
- #### C
50
- - **Primary**: `gdb` (GNU Debugger 14.x)
51
- - **Alternative**: `lldb` (LLVM 17.x)
52
- - **VSCode**: C/C++ Extension (ms-vscode.cpptools)
53
- - **CLI**: `gdb ./program`, `break main`, `run`, `bt`, `print var`
54
-
55
- #### C++
56
- - **Primary**: `gdb` 14.x with C++23 support
57
- - **Alternative**: `lldb` 17.x
58
- - **GUI**: CLion Debugger, VS Code C++ extension
59
- - **CLI**: `gdb --args ./app arg1 arg2`
60
- - **Tools**: AddressSanitizer, Valgrind 3.22
61
-
62
- #### Rust
63
- - **Primary**: `rust-lldb` (shipped with rustup)
64
- - **Alternative**: `rust-gdb`, CodeLLDB (VS Code)
65
- - **CLI**: `rust-gdb target/debug/myapp`
66
- - **Panic traces**: `RUST_BACKTRACE=1 cargo run`
67
- - **Tools**: `rust-analyzer` debugger integration
68
-
69
- #### Go
70
- - **Primary**: Delve 1.22.x (`dlv`)
71
- - **VSCode**: Go Extension (golang.go) with Delve
72
- - **CLI**: `dlv debug`, `dlv test`, `dlv attach <pid>`
73
- - **Remote**: `dlv debug --headless --listen=:2345`
74
- - **Goroutine debugging**: `goroutines`, `goroutine <id>`
49
+ ### Systems Programming
50
+ - **C/C++**: gdb 14.x, lldb 17.x, AddressSanitizer
51
+ - **Rust**: rust-lldb, rust-gdb, RUST_BACKTRACE=1
52
+ - **Go**: Delve 1.22.x, goroutine debugging
75
53
 
76
54
  ### JVM Ecosystem
77
-
78
- #### Java
79
- - **Primary**: `jdb` (built-in with JDK)
80
- - **IDE**: IntelliJ IDEA Debugger, Eclipse Debugger
81
- - **Remote**: `-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005`
82
- - **CLI**: `jdb -attach 5005`
83
- - **Tools**: VisualVM, JProfiler, Java Flight Recorder
84
-
85
- #### Kotlin
86
- - **Primary**: IntelliJ IDEA Kotlin Debugger
87
- - **Coroutines**: Enable "Async stack traces" in IDE
88
- - **CLI**: Same as Java (`jdb` with Kotlin bytecode)
89
- - **Tools**: Kotlin Coroutines Debugger, Android Studio profiler
90
-
91
- #### Scala
92
- - **Primary**: IntelliJ IDEA Scala Plugin debugger
93
- - **sbt**: `sbt -jvm-debug 5005`
94
- - **Remote**: Same JDWP protocol as Java
95
- - **Tools**: Metals language server debugging
96
-
97
- #### Clojure
98
- - **Primary**: CIDER debugger (Emacs), Cursive (IntelliJ)
99
- - **REPL-based**: `(clojure.tools.trace/trace-ns 'my-ns)`
100
- - **CLI**: Leiningen with `jdb` attachment
101
- - **Tools**: `clojure.tools.logging`, `timbre` logging
55
+ - **Java**: jdb, IntelliJ IDEA, Remote JDWP
56
+ - **Kotlin**: IntelliJ Kotlin Debugger, Coroutines debugger
57
+ - **Scala**: IntelliJ Scala Plugin, sbt debug mode
58
+ - **Clojure**: CIDER, Cursive, REPL-based debugging
102
59
 
103
60
  ### Scripting Languages
104
-
105
- #### Python
106
- - **Primary**: `pdb` (built-in), `debugpy` 1.8.0
107
- - **Enhanced**: `pudb` 2024.1 (TUI), `ipdb` (IPython)
108
- - **VSCode**: Python Extension with debugpy
109
- - **CLI**: `python -m pdb script.py`
110
- - **Async**: `await` stepping, asyncio task inspection
111
- - **Remote**: `debugpy.listen(5678)`, `debugpy.wait_for_client()`
112
-
113
- #### Ruby
114
- - **Primary**: `debug` gem (Ruby 3.2+ built-in)
115
- - **Alternative**: `byebug`, `pry-byebug`
116
- - **VSCode**: Ruby LSP + debug gem
117
- - **CLI**: `ruby -r debug script.rb`
118
- - **Rails**: `binding.break` in views/controllers
119
-
120
- #### PHP
121
- - **Primary**: Xdebug 3.3.x
122
- - **Alternative**: `phpdbg` (built-in CLI)
123
- - **VSCode**: PHP Debug Extension (xdebug.php-debug)
124
- - **CLI**: `php -dxdebug.mode=debug -dxdebug.start_with_request=yes script.php`
125
- - **Laravel**: Laravel Debugbar, Telescope
126
-
127
- #### Lua
128
- - **Primary**: ZeroBrane Studio debugger
129
- - **Alternative**: MobDebug, lua-debug (VS Code)
130
- - **CLI**: `luadebug` module
131
- - **Tools**: LuaRocks debug packages
132
-
133
- #### Shell (Bash)
134
- - **Primary**: `bash -x script.sh` (trace mode)
135
- - **Interactive**: `set -x`, `set +x` toggle
136
- - **VSCode**: Bash Debug Extension
137
- - **Tools**: ShellCheck 0.9.x for static analysis
138
- - **Trace**: `PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'`
61
+ - **Python**: pdb, debugpy 1.8.0, pudb (TUI)
62
+ - **Ruby**: debug gem (built-in), byebug, pry-byebug
63
+ - **PHP**: Xdebug 3.3.x, phpdbg
64
+ - **Lua**: ZeroBrane Studio, MobDebug
65
+ - **Shell**: bash -x, set -x toggle
139
66
 
140
67
  ### Web & Mobile
141
-
142
- #### JavaScript
143
- - **Primary**: Chrome DevTools, Node.js `inspect`
144
- - **VSCode**: Built-in JavaScript Debugger
145
- - **CLI**: `node --inspect script.js`, `node --inspect-brk script.js`
146
- - **Browser**: `debugger;` statement, breakpoints in DevTools
147
- - **Async**: Async stack traces in Chrome DevTools
148
-
149
- #### TypeScript
150
- - **Primary**: Chrome DevTools (via source maps), VS Code TS Debugger
151
- - **CLI**: `node --inspect -r ts-node/register script.ts`
152
- - **Source Maps**: Ensure `"sourceMap": true` in `tsconfig.json`
153
- - **VSCode**: Auto-attaches to Node.js processes
154
-
155
- #### Dart/Flutter
156
- - **Primary**: Flutter DevTools, VS Code Dart extension
157
- - **CLI**: `flutter run --observe`, `dart run --observe`
158
- - **Hot reload**: `r` (reload), `R` (hot restart)
159
- - **Observatory**: `http://localhost:port/` for VM profiling
160
-
161
- #### Swift
162
- - **Primary**: LLDB (Xcode integrated)
163
- - **CLI**: `lldb ./MyApp`
164
- - **Xcode**: Breakpoints, memory graph debugger
165
- - **SwiftUI**: View hierarchy debugger
166
- - **Tools**: Instruments for performance profiling
68
+ - **JavaScript**: Chrome DevTools, node --inspect
69
+ - **TypeScript**: Chrome DevTools with source maps, VS Code debugger
70
+ - **Dart/Flutter**: Flutter DevTools, hot reload
71
+ - **Swift**: LLDB (Xcode), Instruments profiling
167
72
 
168
73
  ### Functional & Concurrency
169
-
170
- #### Haskell
171
- - **Primary**: GHCi debugger (`:break`, `:step`, `:trace`)
172
- - **CLI**: `ghci -fbreak-on-exception script.hs`
173
- - **Tools**: `Debug.Trace` module, `eventlog2html`
174
- - **Profiling**: `ghc -prof -fprof-auto`, `hp2ps`
175
-
176
- #### Elixir
177
- - **Primary**: IEx debugger (`:debugger.start()`)
178
- - **Observer**: `:observer.start()` for live system inspection
179
- - **Tools**: `:sys.trace/2`, `:sys.get_status/1`
180
- - **Phoenix**: Phoenix LiveDashboard for web apps
181
-
182
- #### Julia
183
- - **Primary**: Debugger.jl, Infiltrator.jl
184
- - **CLI**: `using Debugger; @enter myfunction(args)`
185
- - **VSCode**: Julia Extension with debug support
186
- - **Profiling**: `@profile`, ProfileView.jl
187
-
188
- #### R
189
- - **Primary**: `browser()`, `debug()`, `debugonce()`
190
- - **RStudio**: Built-in debugger with breakpoints
191
- - **CLI**: `traceback()`, `recover()`
192
- - **Tools**: `profvis` for profiling
74
+ - **Haskell**: GHCi debugger, Debug.Trace
75
+ - **Elixir**: IEx debugger, :observer.start()
76
+ - **Julia**: Debugger.jl, Infiltrator.jl
77
+ - **R**: browser(), debug(), RStudio debugger
193
78
 
194
79
  ### Enterprise & Data
80
+ - **C#**: Visual Studio Debugger, Rider, vsdbg
81
+ - **SQL**: EXPLAIN ANALYZE, pg_stat_statements
195
82
 
196
- #### C#
197
- - **Primary**: Visual Studio Debugger, Rider
198
- - **CLI**: `dotnet run` with VS Code C# extension
199
- - **Remote**: `vsdbg` for Linux/macOS
200
- - **Tools**: PerfView, dotTrace, WinDbg
201
- - **Async**: Async call stack inspection
202
-
203
- #### SQL
204
- - **PostgreSQL**: `\set VERBOSITY verbose`, EXPLAIN ANALYZE
205
- - **MySQL**: `SHOW WARNINGS`, slow query log
206
- - **Tools**: pgAdmin debugger, MySQL Workbench
207
- - **Profiling**: `pg_stat_statements`, Performance Schema
208
-
209
- ## Container & Kubernetes Debugging
83
+ > **Complete debugger matrix with CLI commands**: See [reference.md](reference.md)
210
84
 
211
- ### Docker Debugging
212
- ```bash
213
- # Attach to running container
214
- docker exec -it <container> /bin/sh
215
-
216
- # Debug with debugger ports exposed
217
- docker run -p 5005:5005 -e JAVA_TOOL_OPTIONS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005' myapp
218
-
219
- # Python remote debugging
220
- docker run -p 5678:5678 -e DEBUGPY_ENABLE=true myapp
221
-
222
- # View logs with timestamps
223
- docker logs --timestamps --follow <container>
224
- ```
225
-
226
- ### Kubernetes Debugging
227
- ```bash
228
- # Port-forward debugger port
229
- kubectl port-forward pod/myapp-pod 5005:5005
230
-
231
- # Exec into pod
232
- kubectl exec -it myapp-pod -- /bin/bash
233
-
234
- # Debug with ephemeral container (K8s 1.23+)
235
- kubectl debug -it myapp-pod --image=busybox --target=myapp
236
-
237
- # Stream logs
238
- kubectl logs -f deployment/myapp --all-containers=true
239
- ```
240
-
241
- ### Debug Container Images
242
- - **Distroless debugging**: Use `gcr.io/distroless/base:debug` variants
243
- - **Scratch debugging**: `kubectl debug` with busybox/alpine
244
-
245
- ## Distributed Tracing & Observability
246
-
247
- ### OpenTelemetry 1.24.0+
248
- ```python
249
- # Python instrumentation
250
- from opentelemetry import trace
251
- from opentelemetry.sdk.trace import TracerProvider
252
- from opentelemetry.sdk.trace.export import BatchSpanProcessor
253
- from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
254
-
255
- provider = TracerProvider()
256
- processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="http://localhost:4317"))
257
- provider.add_span_processor(processor)
258
- trace.set_tracer_provider(provider)
259
-
260
- tracer = trace.get_tracer(__name__)
261
- with tracer.start_as_current_span("operation"):
262
- # Your code here
263
- pass
264
- ```
265
-
266
- ```typescript
267
- // TypeScript instrumentation
268
- import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
269
- import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
270
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
271
-
272
- const provider = new NodeTracerProvider();
273
- provider.addSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter()));
274
- provider.register();
275
- ```
276
-
277
- ### Prometheus 2.48.x Integration
278
- ```yaml
279
- # Scrape config
280
- scrape_configs:
281
- - job_name: 'my-app'
282
- static_configs:
283
- - targets: ['localhost:9090']
284
- metrics_path: '/metrics'
285
- scrape_interval: 15s
286
- ```
287
-
288
- ```python
289
- # Python metrics (prometheus-client 0.19.0)
290
- from prometheus_client import Counter, Histogram, start_http_server
291
-
292
- request_count = Counter('app_requests_total', 'Total requests')
293
- request_duration = Histogram('app_request_duration_seconds', 'Request duration')
294
-
295
- @request_duration.time()
296
- def handle_request():
297
- request_count.inc()
298
- # Handle request
299
- ```
300
-
301
- ### Cloud Debuggers
302
-
303
- #### AWS X-Ray
304
- ```python
305
- from aws_xray_sdk.core import xray_recorder
306
- from aws_xray_sdk.core import patch_all
85
+ ---
307
86
 
308
- patch_all() # Auto-instrument AWS SDK calls
87
+ ## Debugging Workflow (6-Step Process)
309
88
 
310
- @xray_recorder.capture('my_function')
311
- def my_function():
312
- pass
313
- ```
89
+ ### 1. Reproduce
90
+ - [ ] Minimal reproducible example (MRE)
91
+ - [ ] Consistent reproduction steps
92
+ - [ ] Document environment (OS, language version, dependencies)
314
93
 
315
- #### GCP Cloud Debugger
316
- ```python
317
- try:
318
- import googleclouddebugger
319
- googleclouddebugger.enable(
320
- module='myapp',
321
- version='v1.0'
322
- )
323
- except ImportError:
324
- pass # Not available in dev environment
325
- ```
94
+ ### 2. Isolate
95
+ - [ ] Binary search the code (comment out sections)
96
+ - [ ] Check recent changes (git diff, git log)
97
+ - [ ] Verify input data and edge cases
326
98
 
327
- ## Stack Trace Analysis Patterns
328
-
329
- ### Python
330
- ```python
331
- # Traceback example
332
- Traceback (most recent call last):
333
- File "app.py", line 42, in process_data
334
- result = data['missing_key']
335
- KeyError: 'missing_key'
336
-
337
- # Analysis
338
- 📍 Location: app.py:42 in process_data()
339
- 🔍 Root Cause: Accessing dictionary key without validation
340
- 💡 Fix Suggestions:
341
- 1. Use data.get('missing_key', default_value)
342
- 2. Add key existence check: if 'missing_key' in data
343
- 3. Use try-except for KeyError handling
344
- ```
99
+ ### 3. Investigate
100
+ - [ ] Read stack trace from bottom (entry point) to top (error site)
101
+ - [ ] Add logging at key decision points
102
+ - [ ] Use debugger breakpoints before error location
103
+ - [ ] Check variable state in debugger
345
104
 
346
- ### TypeScript/JavaScript
347
- ```typescript
348
- // Error example
349
- TypeError: Cannot read properties of undefined (reading 'name')
350
- at getUserName (user.service.ts:15:23)
351
- at processUser (user.controller.ts:42:10)
352
-
353
- // Analysis
354
- 📍 Location: user.service.ts:15 in getUserName()
355
- 🔍 Root Cause: Object is undefined before property access
356
- 💡 Fix Suggestions:
357
- 1. Add null check: user?.name
358
- 2. Type guard: if (user && 'name' in user)
359
- 3. Use optional chaining throughout call chain
360
- ```
105
+ ### 4. Hypothesize
106
+ - [ ] Form theory about root cause
107
+ - [ ] Identify 2-3 most likely culprits
108
+ - [ ] Design experiment to test hypothesis
361
109
 
362
- ### Java
363
- ```java
364
- // Exception example
365
- java.lang.NullPointerException: Cannot invoke "String.length()" because "text" is null
366
- at com.example.TextProcessor.process(TextProcessor.java:23)
367
- at com.example.Main.main(Main.java:15)
368
-
369
- // Analysis
370
- 📍 Location: TextProcessor.java:23 in process()
371
- 🔍 Root Cause: Null reference passed to method
372
- 💡 Fix Suggestions:
373
- 1. Use Optional<String> parameter type
374
- 2. Add Objects.requireNonNull(text) guard
375
- 3. Add @NonNull annotation with null-checking framework
376
- ```
110
+ ### 5. Fix
111
+ - [ ] Implement minimal fix first
112
+ - [ ] Add regression test (RED → GREEN)
113
+ - [ ] Refactor if needed (REFACTOR stage)
114
+ - [ ] Update documentation
377
115
 
378
- ### Go
379
- ```go
380
- // Panic example
381
- panic: runtime error: invalid memory address or nil pointer dereference
382
- [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10a4b20]
383
-
384
- goroutine 1 [running]:
385
- main.processData(0x0)
386
- /app/main.go:42 +0x20
387
- main.main()
388
- /app/main.go:15 +0x40
389
-
390
- // Analysis
391
- 📍 Location: main.go:42 in processData()
392
- 🔍 Root Cause: Nil pointer dereference
393
- 💡 Fix Suggestions:
394
- 1. Add nil check: if data != nil { ... }
395
- 2. Initialize pointer before use
396
- 3. Use defensive programming with early returns
397
- ```
116
+ ### 6. Verify
117
+ - [ ] Run full test suite
118
+ - [ ] Test edge cases explicitly
119
+ - [ ] Verify fix in production-like environment
120
+ - [ ] Monitor for recurrence
398
121
 
399
- ### Rust
400
- ```rust
401
- // Panic example
402
- thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:42:23
403
- stack backtrace:
404
- 0: rust_begin_unwind
405
- 1: core::panicking::panic_fmt
406
- 2: myapp::process_data
407
- at ./src/main.rs:42
408
-
409
- // Analysis
410
- 📍 Location: src/main.rs:42 in process_data()
411
- 🔍 Root Cause: Unwrapping None Option without checking
412
- 💡 Fix Suggestions:
413
- 1. Use match expression: match opt { Some(v) => ..., None => ... }
414
- 2. Use if let: if let Some(v) = opt { ... }
415
- 3. Use .unwrap_or(default) or .unwrap_or_else(|| ...)
416
- ```
122
+ ---
417
123
 
418
- ## Common Error Patterns by Language
124
+ ## Common Error Patterns by Language Category
419
125
 
420
126
  ### Memory Safety
421
127
  - **C/C++**: Buffer overflow, use-after-free, memory leaks
@@ -446,204 +152,100 @@ stack backtrace:
446
152
  - **JavaScript**: Unhandled promise rejections → Always catch async errors
447
153
  - **Rust**: Send/Sync trait violations → Understand thread safety
448
154
 
449
- ## Debugging Workflow
155
+ > **Detailed error pattern analysis**: See [examples.md](examples.md)
450
156
 
451
- ### 1. Reproduce
452
- - [ ] Minimal reproducible example (MRE)
453
- - [ ] Consistent reproduction steps
454
- - [ ] Document environment (OS, language version, dependencies)
157
+ ---
455
158
 
456
- ### 2. Isolate
457
- - [ ] Binary search the code (comment out sections)
458
- - [ ] Check recent changes (git diff, git log)
459
- - [ ] Verify input data and edge cases
159
+ ## Container & Kubernetes Debugging
460
160
 
461
- ### 3. Investigate
462
- - [ ] Read stack trace from bottom (entry point) to top (error site)
463
- - [ ] Add logging at key decision points
464
- - [ ] Use debugger breakpoints before error location
465
- - [ ] Check variable state in debugger
161
+ ### Docker Debugging
162
+ ```bash
163
+ # Attach to running container
164
+ docker exec -it <container> /bin/sh
466
165
 
467
- ### 4. Hypothesize
468
- - [ ] Form theory about root cause
469
- - [ ] Identify 2-3 most likely culprits
470
- - [ ] Design experiment to test hypothesis
166
+ # Debug with debugger ports exposed
167
+ docker run -p 5005:5005 -e JAVA_TOOL_OPTIONS='-agentlib:jdwp=...' myapp
471
168
 
472
- ### 5. Fix
473
- - [ ] Implement minimal fix first
474
- - [ ] Add regression test (RED → GREEN)
475
- - [ ] Refactor if needed (REFACTOR stage)
476
- - [ ] Update documentation
169
+ # Python remote debugging
170
+ docker run -p 5678:5678 -e DEBUGPY_ENABLE=true myapp
171
+ ```
477
172
 
478
- ### 6. Verify
479
- - [ ] Run full test suite
480
- - [ ] Test edge cases explicitly
481
- - [ ] Verify fix in production-like environment
482
- - [ ] Monitor for recurrence
173
+ ### Kubernetes Debugging
174
+ ```bash
175
+ # Port-forward debugger port
176
+ kubectl port-forward pod/myapp-pod 5005:5005
483
177
 
484
- ## VSCode Launch Configuration Examples
485
-
486
- ### Python (debugpy)
487
- ```json
488
- {
489
- "version": "0.2.0",
490
- "configurations": [
491
- {
492
- "name": "Python: Current File",
493
- "type": "debugpy",
494
- "request": "launch",
495
- "program": "${file}",
496
- "console": "integratedTerminal",
497
- "justMyCode": false
498
- },
499
- {
500
- "name": "Python: Remote Attach",
501
- "type": "debugpy",
502
- "request": "attach",
503
- "connect": {
504
- "host": "localhost",
505
- "port": 5678
506
- },
507
- "pathMappings": [
508
- {
509
- "localRoot": "${workspaceFolder}",
510
- "remoteRoot": "/app"
511
- }
512
- ]
513
- }
514
- ]
515
- }
516
- ```
178
+ # Exec into pod
179
+ kubectl exec -it myapp-pod -- /bin/bash
517
180
 
518
- ### Node.js/TypeScript
519
- ```json
520
- {
521
- "version": "0.2.0",
522
- "configurations": [
523
- {
524
- "type": "node",
525
- "request": "launch",
526
- "name": "TypeScript: Current File",
527
- "runtimeArgs": ["-r", "ts-node/register"],
528
- "args": ["${file}"],
529
- "cwd": "${workspaceFolder}",
530
- "protocol": "inspector"
531
- },
532
- {
533
- "type": "node",
534
- "request": "attach",
535
- "name": "Attach to Remote",
536
- "address": "localhost",
537
- "port": 9229,
538
- "localRoot": "${workspaceFolder}",
539
- "remoteRoot": "/app"
540
- }
541
- ]
542
- }
181
+ # Debug with ephemeral container (K8s 1.23+)
182
+ kubectl debug -it myapp-pod --image=busybox --target=myapp
543
183
  ```
544
184
 
545
- ### Go (Delve)
546
- ```json
547
- {
548
- "version": "0.2.0",
549
- "configurations": [
550
- {
551
- "name": "Launch Package",
552
- "type": "go",
553
- "request": "launch",
554
- "mode": "auto",
555
- "program": "${workspaceFolder}"
556
- },
557
- {
558
- "name": "Attach to Process",
559
- "type": "go",
560
- "request": "attach",
561
- "mode": "local",
562
- "processId": "${command:pickProcess}"
563
- }
564
- ]
565
- }
566
- ```
185
+ > **Complete container debugging guide**: See [reference.md](reference.md)
567
186
 
568
- ### Rust (CodeLLDB)
569
- ```json
570
- {
571
- "version": "0.2.0",
572
- "configurations": [
573
- {
574
- "type": "lldb",
575
- "request": "launch",
576
- "name": "Debug executable",
577
- "cargo": {
578
- "args": ["build", "--bin=myapp", "--package=myapp"]
579
- },
580
- "args": [],
581
- "cwd": "${workspaceFolder}"
582
- }
583
- ]
584
- }
585
- ```
187
+ ---
586
188
 
587
- ### Java
588
- ```json
589
- {
590
- "version": "0.2.0",
591
- "configurations": [
592
- {
593
- "type": "java",
594
- "name": "Debug (Launch)",
595
- "request": "launch",
596
- "mainClass": "com.example.Main"
597
- },
598
- {
599
- "type": "java",
600
- "name": "Debug (Attach)",
601
- "request": "attach",
602
- "hostName": "localhost",
603
- "port": 5005
604
- }
605
- ]
606
- }
607
- ```
189
+ ## Distributed Tracing
608
190
 
609
- ## Performance Profiling Integration
191
+ ### OpenTelemetry 1.24.0+
192
+ - Python: opentelemetry-api, opentelemetry-sdk
193
+ - TypeScript: @opentelemetry/sdk-trace-node
194
+ - Exporters: Jaeger, Zipkin, OTLP
610
195
 
611
- ### Python (cProfile + py-spy)
612
- ```bash
613
- # CPU profiling
614
- python -m cProfile -o output.prof script.py
615
- python -m pstats output.prof
196
+ ### Prometheus 2.48.x Integration
197
+ - Metrics: Counter, Gauge, Histogram, Summary
198
+ - Python: prometheus-client 0.19.0
199
+ - Go: prometheus/client_golang
616
200
 
617
- # Sampling profiler (production-safe)
618
- py-spy top --pid <pid>
619
- py-spy record -o profile.svg --pid <pid>
620
- ```
201
+ ### Cloud Debuggers
202
+ - **AWS X-Ray**: aws-xray-sdk, auto-instrumentation
203
+ - **GCP Cloud Debugger**: googleclouddebugger Python package
621
204
 
622
- ### Go (pprof)
623
- ```bash
624
- # CPU profiling
625
- go test -cpuprofile cpu.prof -bench .
626
- go tool pprof cpu.prof
205
+ > **Complete distributed tracing setup**: See [reference.md](reference.md)
627
206
 
628
- # Memory profiling
629
- go test -memprofile mem.prof -bench .
630
- go tool pprof mem.prof
631
- ```
207
+ ---
632
208
 
633
- ### Rust (flamegraph)
634
- ```bash
635
- cargo install flamegraph
636
- cargo flamegraph --bin myapp
637
- ```
209
+ ## Stack Trace Analysis Quick Guide
638
210
 
639
- ### Java (JFR)
640
- ```bash
641
- # Start with JFR enabled
642
- java -XX:StartFlightRecording=duration=60s,filename=recording.jfr -jar app.jar
211
+ ### Reading Stack Traces
643
212
 
644
- # Analyze with JMC or jfr CLI
645
- jfr print recording.jfr
646
- ```
213
+ **Direction**: Bottom (entry point) Top (error site)
214
+
215
+ **Key information**:
216
+ - 📍 **Location**: File and line number
217
+ - 🔍 **Context**: Function name and arguments
218
+ - 💡 **Error type**: Exception class or error message
219
+
220
+ ### Analysis Pattern
221
+
222
+ 1. **Identify error type**: What exception/error?
223
+ 2. **Locate error site**: Top of stack trace
224
+ 3. **Trace execution path**: Follow stack from bottom
225
+ 4. **Identify root cause**: Where did bad data/state originate?
226
+ 5. **Suggest fix**: 1-3 actionable options
227
+
228
+ > **Language-specific stack trace examples**: See [examples.md](examples.md)
229
+
230
+ ---
231
+
232
+ ## Performance Profiling Integration
233
+
234
+ ### CPU Profiling
235
+ - **Python**: cProfile, py-spy (production-safe)
236
+ - **Go**: pprof, go test -cpuprofile
237
+ - **Rust**: flamegraph crate
238
+ - **Java**: Java Flight Recorder (JFR)
239
+
240
+ ### Memory Profiling
241
+ - **Python**: memory_profiler, tracemalloc
242
+ - **Go**: pprof memory profiling
243
+ - **C/C++**: Valgrind massif
244
+ - **Rust**: heaptrack
245
+
246
+ > **Complete profiling guide**: See [reference.md](reference.md)
247
+
248
+ ---
647
249
 
648
250
  ## Inputs
649
251
  - Stack traces, error messages, logs
@@ -657,37 +259,31 @@ jfr print recording.jfr
657
259
  - Debugging checklist tailored to error type
658
260
  - Code snippets demonstrating fix
659
261
 
262
+ ---
263
+
660
264
  ## Failure Modes
661
265
  - Insufficient stack trace or log information
662
266
  - Unable to reproduce error locally
663
267
  - Complex distributed system failures requiring multi-service tracing
664
268
  - Race conditions or timing-dependent bugs
665
269
 
270
+ ---
271
+
666
272
  ## Dependencies
667
273
  - Works with: tdd-implementer, debug-helper, quality-gate
668
274
  - Requires: Language-specific debugger tools installed
669
275
  - Optional: OpenTelemetry, Prometheus, cloud debugger SDKs
670
276
 
671
- ## References
672
- - OpenTelemetry Documentation. https://opentelemetry.io/docs/ (accessed 2025-10-22)
673
- - Prometheus Documentation. https://prometheus.io/docs/ (accessed 2025-10-22)
674
- - Microsoft. "Debugging in Visual Studio Code." https://code.visualstudio.com/docs/editor/debugging (accessed 2025-10-22)
675
- - JetBrains. "Debugging Code." https://www.jetbrains.com/help/idea/debugging-code.html (accessed 2025-10-22)
676
- - AWS. "AWS X-Ray Developer Guide." https://docs.aws.amazon.com/xray/ (accessed 2025-10-22)
677
- - Google Cloud. "Cloud Debugger Documentation." https://cloud.google.com/debugger/docs (accessed 2025-10-22)
678
- - Delve Debugger Documentation. https://github.com/go-delve/delve (accessed 2025-10-22)
679
- - Rust Debugging Documentation. https://doc.rust-lang.org/book/ch09-00-error-handling.html (accessed 2025-10-22)
680
-
681
- ## Changelog
682
- - 2025-10-22: v2.0.0 - Complete rewrite with 23-language coverage, container debugging, distributed tracing, cloud debuggers
683
- - 2025-03-29: v1.0.0 - Initial version with Python/TypeScript/Java support
684
-
685
- ## Works well with
277
+ ---
278
+
279
+ ## Related Skills
686
280
  - moai-essentials-refactor (clean up code after debugging)
687
281
  - moai-essentials-perf (performance bottleneck investigation)
688
282
  - moai-alfred-debugger-pro (advanced debugging strategies)
689
283
  - moai-foundation-trust (ensure debugging doesn't skip tests)
690
284
 
285
+ ---
286
+
691
287
  ## Best Practices
692
288
  - Always create regression test after fixing bug (TDD cycle)
693
289
  - Log debugging insights in code comments with @TAG references
@@ -696,3 +292,12 @@ jfr print recording.jfr
696
292
  - Set up distributed tracing early in microservices projects
697
293
  - Use production-safe profilers (py-spy, async-profiler) in live systems
698
294
  - Document reproduction steps in issue tracker or SPEC HISTORY
295
+
296
+ ---
297
+
298
+ **For complete 23-language debugger matrix**: [reference.md](reference.md)
299
+ **For language-specific debugging examples**: [examples.md](examples.md)
300
+
301
+ ---
302
+
303
+ **End of Skill** | Refactored 2025-10-27