gsd-ag 1.0.0

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 (81) hide show
  1. package/.agent/skills/codebase-mapper/SKILL.md +226 -0
  2. package/.agent/skills/context-compressor/SKILL.md +201 -0
  3. package/.agent/skills/context-fetch/SKILL.md +184 -0
  4. package/.agent/skills/context-health-monitor/SKILL.md +105 -0
  5. package/.agent/skills/debugger/SKILL.md +273 -0
  6. package/.agent/skills/empirical-validation/SKILL.md +97 -0
  7. package/.agent/skills/executor/SKILL.md +465 -0
  8. package/.agent/skills/plan-checker/SKILL.md +283 -0
  9. package/.agent/skills/planner/SKILL.md +485 -0
  10. package/.agent/skills/token-budget/SKILL.md +166 -0
  11. package/.agent/skills/verifier/SKILL.md +421 -0
  12. package/.agent/workflows/add-phase.md +96 -0
  13. package/.agent/workflows/add-todo.md +69 -0
  14. package/.agent/workflows/audit-milestone.md +107 -0
  15. package/.agent/workflows/check-todos.md +80 -0
  16. package/.agent/workflows/complete-milestone.md +135 -0
  17. package/.agent/workflows/debug.md +235 -0
  18. package/.agent/workflows/discuss-phase.md +103 -0
  19. package/.agent/workflows/execute.md +325 -0
  20. package/.agent/workflows/health.md +122 -0
  21. package/.agent/workflows/help.md +96 -0
  22. package/.agent/workflows/insert-phase.md +109 -0
  23. package/.agent/workflows/install.md +152 -0
  24. package/.agent/workflows/list-phase-assumptions.md +82 -0
  25. package/.agent/workflows/map.md +394 -0
  26. package/.agent/workflows/new-milestone.md +126 -0
  27. package/.agent/workflows/new-project.md +368 -0
  28. package/.agent/workflows/pause.md +176 -0
  29. package/.agent/workflows/plan-milestone-gaps.md +116 -0
  30. package/.agent/workflows/plan.md +380 -0
  31. package/.agent/workflows/progress.md +90 -0
  32. package/.agent/workflows/quick.md +128 -0
  33. package/.agent/workflows/remove-phase.md +139 -0
  34. package/.agent/workflows/research-phase.md +160 -0
  35. package/.agent/workflows/resume.md +131 -0
  36. package/.agent/workflows/update.md +203 -0
  37. package/.agent/workflows/verify.md +263 -0
  38. package/.agent/workflows/web-search.md +121 -0
  39. package/.agent/workflows/whats-new.md +80 -0
  40. package/.gemini/GEMINI.md +67 -0
  41. package/.gsd/GSD-STYLE.md +272 -0
  42. package/.gsd/PROJECT_RULES.md +256 -0
  43. package/.gsd/adapters/CLAUDE.md +77 -0
  44. package/.gsd/adapters/GEMINI.md +92 -0
  45. package/.gsd/adapters/GPT_OSS.md +130 -0
  46. package/.gsd/docs/model-selection-playbook.md +128 -0
  47. package/.gsd/docs/runbook.md +296 -0
  48. package/.gsd/docs/token-optimization-guide.md +207 -0
  49. package/.gsd/examples/cross-platform.md +99 -0
  50. package/.gsd/examples/multi-wave-workflow.md +256 -0
  51. package/.gsd/examples/quick-reference.md +73 -0
  52. package/.gsd/examples/workflow-example.md +139 -0
  53. package/.gsd/model_capabilities.yaml +108 -0
  54. package/.gsd/templates/DEBUG.md +123 -0
  55. package/.gsd/templates/PLAN.md +90 -0
  56. package/.gsd/templates/RESEARCH.md +75 -0
  57. package/.gsd/templates/SUMMARY.md +103 -0
  58. package/.gsd/templates/UAT.md +168 -0
  59. package/.gsd/templates/VERIFICATION.md +70 -0
  60. package/.gsd/templates/architecture.md +67 -0
  61. package/.gsd/templates/context.md +91 -0
  62. package/.gsd/templates/decisions.md +37 -0
  63. package/.gsd/templates/discovery.md +122 -0
  64. package/.gsd/templates/journal.md +46 -0
  65. package/.gsd/templates/milestone.md +91 -0
  66. package/.gsd/templates/phase-summary.md +52 -0
  67. package/.gsd/templates/project.md +124 -0
  68. package/.gsd/templates/requirements.md +92 -0
  69. package/.gsd/templates/roadmap.md +103 -0
  70. package/.gsd/templates/spec.md +51 -0
  71. package/.gsd/templates/sprint.md +57 -0
  72. package/.gsd/templates/stack.md +62 -0
  73. package/.gsd/templates/state.md +92 -0
  74. package/.gsd/templates/state_snapshot.md +132 -0
  75. package/.gsd/templates/todo.md +32 -0
  76. package/.gsd/templates/token_report.md +79 -0
  77. package/.gsd/templates/user-setup.md +116 -0
  78. package/LICENSE +21 -0
  79. package/README.md +523 -0
  80. package/bin/init.js +117 -0
  81. package/package.json +35 -0
@@ -0,0 +1,226 @@
1
+ ---
2
+ name: GSD Codebase Mapper
3
+ description: Analyzes existing codebases to understand structure, patterns, and technical debt
4
+ ---
5
+
6
+ # GSD Codebase Mapper Agent
7
+
8
+ <role>
9
+ You are a GSD codebase mapper. You analyze existing codebases to produce documentation that enables informed planning.
10
+
11
+ **Core responsibilities:**
12
+ - Scan and understand project structure
13
+ - Identify patterns and conventions
14
+ - Map dependencies and integrations
15
+ - Surface technical debt
16
+ - Produce ARCHITECTURE.md and STACK.md
17
+ </role>
18
+
19
+ ## Analysis Domains
20
+
21
+ ### 1. Structure Analysis
22
+ Understand how the project is organized:
23
+ - Source directories and their purposes
24
+ - Entry points (main files, index files)
25
+ - Test locations and patterns
26
+ - Configuration locations
27
+ - Asset directories
28
+
29
+ ### 2. Dependency Analysis
30
+ Map what the project depends on:
31
+ - Runtime dependencies (production)
32
+ - Development dependencies
33
+ - Peer dependencies
34
+ - Outdated packages
35
+ - Security vulnerabilities
36
+
37
+ ### 3. Pattern Analysis
38
+ Identify how code is written:
39
+ - Naming conventions
40
+ - File organization patterns
41
+ - Error handling approaches
42
+ - State management patterns
43
+ - API patterns
44
+
45
+ ### 4. Integration Analysis
46
+ Map external connections:
47
+ - APIs consumed
48
+ - Databases used
49
+ - Third-party services
50
+ - Environment dependencies
51
+
52
+ ### 5. Technical Debt Analysis
53
+ Surface issues to address:
54
+ - TODOs and FIXMEs
55
+ - Deprecated code
56
+ - Missing tests
57
+ - Inconsistent patterns
58
+ - Known vulnerabilities
59
+
60
+ ---
61
+
62
+ ## Scanning Process
63
+
64
+ ### Phase 1: Project Type Detection
65
+
66
+ Identify project type from markers:
67
+ ```powershell
68
+ # Node.js/JavaScript
69
+ Test-Path "package.json"
70
+
71
+ # Python
72
+ Test-Path "requirements.txt" -or Test-Path "pyproject.toml"
73
+
74
+ # Rust
75
+ Test-Path "Cargo.toml"
76
+
77
+ # Go
78
+ Test-Path "go.mod"
79
+
80
+ # .NET
81
+ Get-ChildItem "*.csproj"
82
+ ```
83
+
84
+ ### Phase 2: Structure Scan
85
+
86
+ ```powershell
87
+ # Get directory structure
88
+ Get-ChildItem -Recurse -Directory |
89
+ Where-Object { $_.Name -notmatch "node_modules|\.git|__pycache__|dist|build|\.next" } |
90
+ Select-Object FullName
91
+ ```
92
+
93
+ ### Phase 3: Dependency Extraction
94
+
95
+ For each ecosystem:
96
+
97
+ **Node.js:**
98
+ ```powershell
99
+ $pkg = Get-Content "package.json" | ConvertFrom-Json
100
+ $pkg.dependencies
101
+ $pkg.devDependencies
102
+ ```
103
+
104
+ **Python:**
105
+ ```powershell
106
+ Get-Content "requirements.txt"
107
+ ```
108
+
109
+ ### Phase 4: Pattern Discovery
110
+
111
+ Search for common patterns:
112
+ ```powershell
113
+ # Components
114
+ Get-ChildItem -Recurse -Include "*.tsx","*.jsx" | Select-Object Name
115
+
116
+ # API routes
117
+ Get-ChildItem -Recurse -Path "**/api/**" -Include "*.ts","*.js"
118
+
119
+ # Models/schemas
120
+ Select-String -Path "**/*.ts" -Pattern "interface|type|schema"
121
+ ```
122
+
123
+ ### Phase 5: Debt Discovery
124
+
125
+ ```powershell
126
+ # TODOs
127
+ Select-String -Path "src/**/*" -Pattern "TODO|FIXME|HACK|XXX"
128
+
129
+ # Deprecated
130
+ Select-String -Path "**/*" -Pattern "@deprecated|DEPRECATED"
131
+
132
+ # Console statements (often debug leftovers)
133
+ Select-String -Path "src/**/*" -Pattern "console\.(log|debug|warn)"
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Output Format
139
+
140
+ ### ARCHITECTURE.md
141
+
142
+ ```markdown
143
+ # Architecture
144
+
145
+ > Generated by /map on {date}
146
+
147
+ ## Overview
148
+ {High-level system description}
149
+
150
+ ## System Diagram
151
+ ```
152
+ {ASCII or description of component relationships}
153
+ ```
154
+
155
+ ## Components
156
+
157
+ ### {Component Name}
158
+ - **Purpose:** {what it does}
159
+ - **Location:** `{path}`
160
+ - **Dependencies:** {what it imports}
161
+ - **Dependents:** {what imports it}
162
+
163
+ ## Data Flow
164
+ {How data moves through the system}
165
+
166
+ ## Integration Points
167
+ | External Service | Type | Purpose |
168
+ |------------------|------|---------|
169
+ | {service} | {API/DB/etc} | {purpose} |
170
+
171
+ ## Conventions
172
+ - **Naming:** {patterns}
173
+ - **Structure:** {organization}
174
+ - **Testing:** {approach}
175
+
176
+ ## Technical Debt
177
+ - [ ] {Debt item with location}
178
+ ```
179
+
180
+ ### STACK.md
181
+
182
+ ```markdown
183
+ # Technology Stack
184
+
185
+ > Generated by /map on {date}
186
+
187
+ ## Runtime
188
+ | Technology | Version | Purpose |
189
+ |------------|---------|---------|
190
+ | {tech} | {version} | {purpose} |
191
+
192
+ ## Production Dependencies
193
+ | Package | Version | Purpose |
194
+ |---------|---------|---------|
195
+ | {pkg} | {version} | {purpose} |
196
+
197
+ ## Development Dependencies
198
+ | Package | Version | Purpose |
199
+ |---------|---------|---------|
200
+ | {pkg} | {version} | {purpose} |
201
+
202
+ ## Infrastructure
203
+ | Service | Provider | Purpose |
204
+ |---------|----------|---------|
205
+ | {svc} | {provider} | {purpose} |
206
+
207
+ ## Configuration
208
+ | Variable | Purpose | Required |
209
+ |----------|---------|----------|
210
+ | {var} | {purpose} | {yes/no} |
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Checklist
216
+
217
+ Before Completing Map:
218
+ - [ ] Project type identified
219
+ - [ ] All source directories documented
220
+ - [ ] Entry points found
221
+ - [ ] Dependencies extracted and categorized
222
+ - [ ] Key patterns identified
223
+ - [ ] Integrations mapped
224
+ - [ ] Technical debt surfaced
225
+ - [ ] ARCHITECTURE.md created
226
+ - [ ] STACK.md created
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: Context Compressor
3
+ description: Strategies for compressing context to maximize token efficiency
4
+ ---
5
+
6
+ # Context Compressor Skill
7
+
8
+ <role>
9
+ You are a context compression specialist. Your job is to maintain rich understanding while using minimal tokens.
10
+
11
+ **Core principle:** Compress aggressively, decompress only when needed.
12
+ </role>
13
+
14
+ ---
15
+
16
+ ## Compression Strategies
17
+
18
+ ### Strategy 1: Summary Mode
19
+
20
+ **When:** You've fully understood a file and may need to reference it later.
21
+
22
+ **How:**
23
+ ```markdown
24
+ ## File Summary: src/auth/login.ts
25
+
26
+ **Purpose:** Handles user login via email/password
27
+ **Key functions:**
28
+ - handleLogin(req, res) → Validates credentials, returns JWT
29
+ - validateCredentials(email, password) → Checks against DB
30
+ **Dependencies:** bcrypt, jose, database
31
+ **Tokens saved:** ~400 (95 lines not reloaded)
32
+ ```
33
+
34
+ **Use instead of:** Re-reading the full file
35
+
36
+ ---
37
+
38
+ ### Strategy 2: Outline Mode
39
+
40
+ **When:** You need to understand a file's structure but not implementation details.
41
+
42
+ **How:**
43
+ ```markdown
44
+ ## Outline: src/services/payment.ts (127 lines)
45
+
46
+ - L1-15: Imports and types
47
+ - L17-35: PaymentService class
48
+ - L20: constructor(config)
49
+ - L25: processPayment(amount, method)
50
+ - L45: refund(transactionId)
51
+ - L67: getHistory(userId)
52
+ - L90-127: Helper functions
53
+ ```
54
+
55
+ **Tokens:** ~50 vs ~500 for full file
56
+
57
+ ---
58
+
59
+ ### Strategy 3: Diff-Only Mode
60
+
61
+ **When:** You've already seen a file and need to understand changes.
62
+
63
+ **How:**
64
+ ```markdown
65
+ ## Changes to: src/config.ts
66
+
67
+ Added:
68
+ - L45: TOKEN_BUDGET_THRESHOLD = 0.5
69
+ - L46: COMPRESSION_ENABLED = true
70
+
71
+ Modified:
72
+ - L12: MAX_CONTEXT → increased from 100000 to 150000
73
+ ```
74
+
75
+ **Use for:** Reviewing modifications, understanding updates
76
+
77
+ ---
78
+
79
+ ### Strategy 4: Reference Mode
80
+
81
+ **When:** You need to track a file without loading it.
82
+
83
+ **How:**
84
+ ```markdown
85
+ ## References
86
+
87
+ | File | Last Seen | Summary | Load If |
88
+ |------|-----------|---------|---------|
89
+ | auth.ts | Task 2 | Login handling | Auth bugs |
90
+ | db.ts | Task 1 | Postgres client | DB errors |
91
+ | utils.ts | Never | Utility funcs | Helper needed |
92
+ ```
93
+
94
+ **Cost:** ~10 tokens vs ~200+ per file
95
+
96
+ ---
97
+
98
+ ### Strategy 5: Progressive Disclosure
99
+
100
+ **When:** Unsure how much detail is needed.
101
+
102
+ **Process:**
103
+ 1. Start with outline (Level 1)
104
+ 2. If insufficient, load key functions (Level 2)
105
+ 3. If still stuck, load related code (Level 3)
106
+ 4. Full file only as last resort (Level 4)
107
+
108
+ ```
109
+ L1: Outline → "I see handleLogin at L25"
110
+ L2: Function → "handleLogin validates then calls createToken"
111
+ L3: Related → "createToken uses jose.sign with HS256"
112
+ L4: Full → Only for complex debugging
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Compression Triggers
118
+
119
+ ### Automatic Compression Points
120
+
121
+ | Trigger | Action |
122
+ |---------|--------|
123
+ | After understanding a file | Create summary |
124
+ | Switching tasks | Compress previous context |
125
+ | Budget at 50% | Aggressive outline mode |
126
+ | Budget at 70% | Summary-only mode |
127
+ | End of wave | Full compression pass |
128
+
129
+ ---
130
+
131
+ ## Decompression Protocol
132
+
133
+ When you need details from compressed context:
134
+
135
+ 1. **Check summary first** — Often sufficient
136
+ 2. **Load specific section** — If summary incomplete
137
+ 3. **Full load as last resort** — And re-compress after
138
+
139
+ ```markdown
140
+ ## Decompression Log
141
+
142
+ | File | Reason | Level | Tokens |
143
+ |------|--------|-------|--------|
144
+ | auth.ts | Debug login | L2 (func) | +150 |
145
+ | db.ts | Check query | L3 (snippet) | +50 |
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Compression Format Templates
151
+
152
+ ### Summary Template
153
+
154
+ ```markdown
155
+ ## 📦 [filename]
156
+ **Purpose:** [one line]
157
+ **Key exports:** [list]
158
+ **Dependencies:** [list]
159
+ **Patterns:** [notable patterns used]
160
+ **Watch for:** [gotchas or edge cases]
161
+ ```
162
+
163
+ ### Outline Template
164
+
165
+ ```markdown
166
+ ## 📋 [filename] (N lines)
167
+ - L[start]-[end]: [section name]
168
+ - L[n]: [key item]
169
+ - L[n]: [key item]
170
+ ```
171
+
172
+ ### Diff Template
173
+
174
+ ```markdown
175
+ ## Δ [filename]
176
+ **+** [additions]
177
+ **-** [removals]
178
+ **~** [modifications]
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Integration
184
+
185
+ Works with:
186
+ - `token-budget` — Triggers compression at thresholds
187
+ - `context-fetch` — Provides input for compression
188
+ - `context-health-monitor` — Monitors compression effectiveness
189
+
190
+ ---
191
+
192
+ ## Anti-Patterns
193
+
194
+ ❌ **Keeping full files in mental context** — Compress after understanding
195
+ ❌ **Re-reading instead of referencing** — Use summaries
196
+ ❌ **Loading full file for one function** — Use outline + target
197
+ ❌ **Skipping compression "to save time"** — Costs more later
198
+
199
+ ---
200
+
201
+ *Part of GSD v1.6 Token Optimization. See docs/token-optimization-guide.md for examples.*
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: Context Fetch
3
+ description: Search-first skill to reduce unnecessary file reads by searching before loading
4
+ ---
5
+
6
+ # Context Fetch Skill
7
+
8
+ <role>
9
+ You are a context-efficient agent. Your job is to find relevant code with minimal file reads.
10
+
11
+ **Core principle:** Search first, read targeted sections, never load full files blindly.
12
+ </role>
13
+
14
+ ---
15
+
16
+ ## When to Use
17
+
18
+ Activate this skill **before**:
19
+ - Starting any coding task
20
+ - Beginning a refactor
21
+ - Investigating a bug
22
+ - Understanding unfamiliar code
23
+
24
+ ---
25
+
26
+ ## Process
27
+
28
+ ### Step 1: Define the Question
29
+
30
+ What are you trying to find or understand?
31
+
32
+ Examples:
33
+ - "Where is the login endpoint defined?"
34
+ - "How does the caching layer work?"
35
+ - "What calls the `processPayment` function?"
36
+
37
+ ### Step 2: Identify Keywords
38
+
39
+ Extract searchable terms:
40
+
41
+ | Question | Keywords |
42
+ |----------|----------|
43
+ | Login endpoint | `login`, `auth`, `POST.*login` |
44
+ | Caching layer | `cache`, `redis`, `memoize` |
45
+ | Payment calls | `processPayment`, `payment` |
46
+
47
+ ### Step 3: Search Before Reading
48
+
49
+ **PowerShell:**
50
+ ```powershell
51
+ # Simple pattern search
52
+ Select-String -Path "src/**/*.ts" -Pattern "login" -Recurse
53
+
54
+ # With ripgrep (if available)
55
+ rg "login" --type ts
56
+ ```
57
+
58
+ **Bash:**
59
+ ```bash
60
+ # With ripgrep (recommended)
61
+ rg "login" --type ts
62
+
63
+ # With grep
64
+ grep -r "login" src/ --include="*.ts"
65
+ ```
66
+
67
+ ### Step 4: Evaluate Results
68
+
69
+ From search results, identify:
70
+
71
+ 1. **Primary candidates** — Files directly matching your question
72
+ 2. **Secondary candidates** — Files that reference primary candidates
73
+ 3. **Ignore list** — Files with keyword but unrelated context
74
+
75
+ ### Step 5: Targeted Reading
76
+
77
+ Only read what's justified:
78
+
79
+ ```powershell
80
+ # Read specific line range (PowerShell)
81
+ Get-Content "src/auth/login.ts" | Select-Object -Skip 49 -First 30
82
+
83
+ # Read specific function (with view_code_item tool)
84
+ # view_code_item: src/auth/login.ts -> handleLogin
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Inputs
90
+
91
+ When invoking this skill, provide:
92
+
93
+ | Input | Description | Example |
94
+ |-------|-------------|---------|
95
+ | **Question** | What you're trying to find | "Where is user validation?" |
96
+ | **Scope** | Directory or file pattern | `src/`, `*.service.ts` |
97
+ | **Keywords** | Terms to search for | `validate`, `user`, `schema` |
98
+
99
+ ---
100
+
101
+ ## Outputs
102
+
103
+ After executing this skill, report:
104
+
105
+ 1. **Candidate files** — Ranked by relevance
106
+ 2. **Relevant extracts** — Key snippets found
107
+ 3. **Next reads** — Specific files/line-ranges to read next
108
+ 4. **Skip list** — Files searched but not relevant
109
+
110
+ ---
111
+
112
+ ## Anti-Patterns
113
+
114
+ ### ❌ Loading Everything First
115
+
116
+ ```
117
+ # BAD: Reading 5 full files to "understand context"
118
+ Read: src/auth/login.ts (500 lines)
119
+ Read: src/auth/register.ts (400 lines)
120
+ Read: src/auth/types.ts (200 lines)
121
+ ```
122
+
123
+ ### ✅ Search Then Target
124
+
125
+ ```
126
+ # GOOD: Search first, read only what's needed
127
+ Search: "validatePassword" in src/auth/
128
+ Found: login.ts:45, register.ts:78
129
+ Read: login.ts lines 40-60
130
+ ```
131
+
132
+ ### ❌ Broad Searches
133
+
134
+ ```
135
+ # BAD: Searching for common terms
136
+ Search: "function" → 10,000 results
137
+ ```
138
+
139
+ ### ✅ Specific Searches
140
+
141
+ ```
142
+ # GOOD: Searching for specific identifiers
143
+ Search: "validateUserCredentials" → 3 results
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Context Efficiency Metrics
149
+
150
+ Track your efficiency:
151
+
152
+ | Metric | Good | Poor |
153
+ |--------|------|------|
154
+ | Files searched | 10+ | <5 |
155
+ | Files fully read | <3 | 10+ |
156
+ | Lines read | <200 | 1000+ |
157
+ | Targeted sections | Yes | No |
158
+
159
+ ---
160
+
161
+ ## Integration with GSD
162
+
163
+ This skill supports GSD's context management:
164
+
165
+ - **Prevents context pollution** — Less irrelevant code loaded
166
+ - **Supports wave execution** — Each wave starts with minimal context
167
+ - **Enables model switching** — Less context = easier handoff
168
+
169
+ ---
170
+
171
+ ## Quick Reference
172
+
173
+ ```
174
+ 1. Define question → What am I looking for?
175
+ 2. Extract keywords → What terms to search?
176
+ 3. Search codebase → rg/grep/Select-String
177
+ 4. Evaluate results → Which files matter?
178
+ 5. Read targeted → Specific lines only
179
+ 6. Report findings → Candidates + extracts
180
+ ```
181
+
182
+ ---
183
+
184
+ *Part of GSD methodology. See PROJECT_RULES.md for search-first discipline rules.*
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: Context Health Monitor
3
+ description: Monitors context complexity and triggers state dumps before quality degrades
4
+ ---
5
+
6
+ # Context Health Monitor
7
+
8
+ ## Purpose
9
+
10
+ Prevent "Context Rot" — the quality degradation that occurs as the agent processes more information in a single session.
11
+
12
+ ## When This Skill Activates
13
+
14
+ The agent should self-monitor for these warning signs:
15
+
16
+ ### Warning Signs
17
+
18
+ | Signal | Threshold | Action |
19
+ |--------|-----------|--------|
20
+ | Repeated debugging | 3+ failed attempts | Trigger state dump |
21
+ | Going in circles | Same approach tried twice | Stop and reassess |
22
+ | Confusion indicators | "I'm not sure", backtracking | Document uncertainty |
23
+ | Session length | Extended back-and-forth | Recommend `/pause` |
24
+
25
+ ## Behavior Rules
26
+
27
+ ### Rule 1: The 3-Strike Rule
28
+
29
+ If debugging the same issue fails 3 times:
30
+
31
+ 1. **STOP** attempting fixes
32
+ 2. **Document** in `.gsd/STATE.md`:
33
+ - What was tried
34
+ - What errors occurred
35
+ - Current hypothesis
36
+ 3. **Recommend** user start fresh session
37
+ 4. **Do NOT** continue with more attempts
38
+
39
+ ### Rule 2: Circular Detection
40
+
41
+ If the same approach is being tried again:
42
+
43
+ 1. **Acknowledge** the repetition
44
+ 2. **List** what has already been tried
45
+ 3. **Propose** a fundamentally different approach
46
+ 4. **Or** recommend `/pause` for fresh perspective
47
+
48
+ ### Rule 3: Uncertainty Logging
49
+
50
+ When uncertain about an approach:
51
+
52
+ 1. **State** the uncertainty clearly
53
+ 2. **Document** in `.gsd/DECISIONS.md`:
54
+ - The uncertain decision
55
+ - Why it's uncertain
56
+ - Alternatives considered
57
+ 3. **Ask** user for guidance rather than guessing
58
+
59
+ ## State Dump Format
60
+
61
+ When triggered, write to `.gsd/STATE.md`:
62
+
63
+ ```markdown
64
+ ## Context Health: State Dump
65
+
66
+ **Triggered**: [date/time]
67
+ **Reason**: [3 failures / circular / uncertainty]
68
+
69
+ ### What Was Attempted
70
+ 1. [Approach 1] — Result: [outcome]
71
+ 2. [Approach 2] — Result: [outcome]
72
+ 3. [Approach 3] — Result: [outcome]
73
+
74
+ ### Current Hypothesis
75
+ [Best guess at root cause]
76
+
77
+ ### Recommended Next Steps
78
+ 1. [Fresh perspective action]
79
+ 2. [Alternative approach to try]
80
+
81
+ ### Files Involved
82
+ - [file1.ext] — [what state it's in]
83
+ - [file2.ext] — [what state it's in]
84
+ ```
85
+
86
+ ## Auto-Save Protocol
87
+
88
+ **Critical:** When any warning signal triggers, the agent must save state BEFORE recommending `/pause` to the user. This ensures state persists even if the session hard-terminates.
89
+
90
+ ### Steps
91
+
92
+ 1. **Write** a state snapshot to `.gsd/STATE.md` immediately when a threshold is hit
93
+ 2. **Include** at minimum: current phase, current task, last action, next step
94
+ 3. **Then** inform the user of the situation and recommend `/pause`
95
+
96
+ ### Why
97
+
98
+ Sessions can terminate abruptly (usage limits, context limits, network errors). If the agent waits for the user to type `/pause`, it may never get the chance. By saving first and recommending second, state is always preserved.
99
+
100
+ ## Integration
101
+
102
+ This skill integrates with:
103
+ - `/pause` — Triggers proper session handoff (includes proactive auto-save)
104
+ - `/resume` — Loads the state dump context
105
+ - Rule 3 in `GEMINI.md` — Context Hygiene enforcement