claude-code-pilot 3.1.0 → 3.2.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 (110) hide show
  1. package/README.md +11 -11
  2. package/bin/install.js +20 -2
  3. package/manifest.json +5 -1
  4. package/package.json +18 -6
  5. package/src/agents/a11y-architect.md +141 -0
  6. package/src/agents/code-architect.md +71 -0
  7. package/src/agents/code-explorer.md +69 -0
  8. package/src/agents/code-simplifier.md +47 -0
  9. package/src/agents/comment-analyzer.md +45 -0
  10. package/src/agents/csharp-reviewer.md +101 -0
  11. package/src/agents/dart-build-resolver.md +201 -0
  12. package/src/agents/pr-test-analyzer.md +45 -0
  13. package/src/agents/silent-failure-hunter.md +50 -0
  14. package/src/agents/type-design-analyzer.md +41 -0
  15. package/src/available-rules/README.md +3 -1
  16. package/src/available-rules/dart/coding-style.md +159 -0
  17. package/src/available-rules/dart/hooks.md +66 -0
  18. package/src/available-rules/dart/patterns.md +261 -0
  19. package/src/available-rules/dart/security.md +135 -0
  20. package/src/available-rules/dart/testing.md +215 -0
  21. package/src/available-rules/web/coding-style.md +105 -0
  22. package/src/available-rules/web/design-quality.md +72 -0
  23. package/src/available-rules/web/hooks.md +129 -0
  24. package/src/available-rules/web/patterns.md +88 -0
  25. package/src/available-rules/web/performance.md +73 -0
  26. package/src/available-rules/web/security.md +66 -0
  27. package/src/available-rules/web/testing.md +64 -0
  28. package/src/commands/ccp/ai-integration-phase.md +36 -0
  29. package/src/commands/ccp/audit-fix.md +33 -0
  30. package/src/commands/ccp/code-review-fix.md +52 -0
  31. package/src/commands/ccp/eval-review.md +32 -0
  32. package/src/commands/ccp/extract_learnings.md +22 -0
  33. package/src/commands/ccp/import.md +37 -0
  34. package/src/commands/ccp/ingest-docs.md +42 -0
  35. package/src/commands/ccp/intel.md +179 -0
  36. package/src/commands/ccp/plan-review-convergence.md +58 -0
  37. package/src/commands/ccp/scan.md +26 -0
  38. package/src/commands/ccp/sketch-wrap-up.md +31 -0
  39. package/src/commands/ccp/sketch.md +54 -0
  40. package/src/commands/ccp/spec-phase.md +62 -0
  41. package/src/commands/ccp/spike-wrap-up.md +31 -0
  42. package/src/commands/ccp/spike.md +51 -0
  43. package/src/commands/ccp/ultraplan-phase.md +33 -0
  44. package/src/hooks/ccp-read-injection-scanner.js +152 -0
  45. package/src/hooks/kit-check-update.js +59 -7
  46. package/src/hooks/run-with-flags-shell.sh +1 -0
  47. package/src/hooks/run-with-flags.js +48 -1
  48. package/src/hooks/session-end.js +88 -1
  49. package/src/lib/hook-flags.js +14 -0
  50. package/src/pilot/references/agent-contracts.md +79 -0
  51. package/src/pilot/references/ai-evals.md +156 -0
  52. package/src/pilot/references/ai-frameworks.md +186 -0
  53. package/src/pilot/references/doc-conflict-engine.md +91 -0
  54. package/src/pilot/references/gate-prompts.md +100 -0
  55. package/src/pilot/references/gates.md +70 -0
  56. package/src/pilot/references/mandatory-initial-read.md +2 -0
  57. package/src/pilot/references/project-skills-discovery.md +19 -0
  58. package/src/pilot/references/revision-loop.md +97 -0
  59. package/src/pilot/references/sketch-interactivity.md +41 -0
  60. package/src/pilot/references/sketch-theme-system.md +94 -0
  61. package/src/pilot/references/sketch-tooling.md +45 -0
  62. package/src/pilot/references/sketch-variant-patterns.md +81 -0
  63. package/src/pilot/references/thinking-models-debug.md +44 -0
  64. package/src/pilot/references/thinking-models-execution.md +50 -0
  65. package/src/pilot/references/thinking-models-planning.md +62 -0
  66. package/src/pilot/references/thinking-models-research.md +50 -0
  67. package/src/pilot/references/thinking-models-verification.md +55 -0
  68. package/src/pilot/templates/AI-SPEC.md +246 -0
  69. package/src/pilot/templates/spec.md +307 -0
  70. package/src/pilot/workflows/ai-integration-phase.md +284 -0
  71. package/src/pilot/workflows/audit-fix.md +175 -0
  72. package/src/pilot/workflows/code-review-fix.md +497 -0
  73. package/src/pilot/workflows/eval-review.md +155 -0
  74. package/src/pilot/workflows/extract_learnings.md +242 -0
  75. package/src/pilot/workflows/import.md +246 -0
  76. package/src/pilot/workflows/ingest-docs.md +328 -0
  77. package/src/pilot/workflows/plan-review-convergence.md +329 -0
  78. package/src/pilot/workflows/scan.md +102 -0
  79. package/src/pilot/workflows/sketch-wrap-up.md +285 -0
  80. package/src/pilot/workflows/sketch.md +360 -0
  81. package/src/pilot/workflows/spec-phase.md +262 -0
  82. package/src/pilot/workflows/spike-wrap-up.md +306 -0
  83. package/src/pilot/workflows/spike.md +452 -0
  84. package/src/pilot/workflows/ultraplan-phase.md +189 -0
  85. package/src/skills/accessibility/SKILL.md +146 -0
  86. package/src/skills/agent-eval/SKILL.md +145 -0
  87. package/src/skills/agent-introspection-debugging/SKILL.md +153 -0
  88. package/src/skills/android-clean-architecture/SKILL.md +339 -0
  89. package/src/skills/api-connector-builder/SKILL.md +120 -0
  90. package/src/skills/code-tour/SKILL.md +236 -0
  91. package/src/skills/compose-multiplatform-patterns/SKILL.md +299 -0
  92. package/src/skills/csharp-testing/SKILL.md +321 -0
  93. package/src/skills/dart-flutter-patterns/SKILL.md +563 -0
  94. package/src/skills/dashboard-builder/SKILL.md +108 -0
  95. package/src/skills/dotnet-patterns/SKILL.md +321 -0
  96. package/src/skills/frontend-design/SKILL.md +145 -0
  97. package/src/skills/frontend-slides/SKILL.md +184 -0
  98. package/src/skills/frontend-slides/STYLE_PRESETS.md +330 -0
  99. package/src/skills/gateguard/SKILL.md +121 -0
  100. package/src/skills/github-ops/SKILL.md +144 -0
  101. package/src/skills/hookify-rules/SKILL.md +128 -0
  102. package/src/skills/knowledge-ops/SKILL.md +154 -0
  103. package/src/skills/liquid-glass-design/SKILL.md +279 -0
  104. package/src/skills/nestjs-patterns/SKILL.md +230 -0
  105. package/src/skills/security-bounty-hunter/SKILL.md +99 -0
  106. package/src/skills/swift-actor-persistence/SKILL.md +143 -0
  107. package/src/skills/swift-protocol-di-testing/SKILL.md +190 -0
  108. package/src/skills/swiftui-patterns/SKILL.md +259 -0
  109. package/src/skills/terminal-ops/SKILL.md +109 -0
  110. package/src/skills/ui-demo/SKILL.md +465 -0
@@ -0,0 +1,339 @@
1
+ ---
2
+ name: android-clean-architecture
3
+ description: Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns.
4
+ origin: ECC
5
+ ---
6
+
7
+ # Android Clean Architecture
8
+
9
+ Clean Architecture patterns for Android and KMP projects. Covers module boundaries, dependency inversion, UseCase/Repository patterns, and data layer design with Room, SQLDelight, and Ktor.
10
+
11
+ ## When to Activate
12
+
13
+ - Structuring Android or KMP project modules
14
+ - Implementing UseCases, Repositories, or DataSources
15
+ - Designing data flow between layers (domain, data, presentation)
16
+ - Setting up dependency injection with Koin or Hilt
17
+ - Working with Room, SQLDelight, or Ktor in a layered architecture
18
+
19
+ ## Module Structure
20
+
21
+ ### Recommended Layout
22
+
23
+ ```
24
+ project/
25
+ ├── app/ # Android entry point, DI wiring, Application class
26
+ ├── core/ # Shared utilities, base classes, error types
27
+ ├── domain/ # UseCases, domain models, repository interfaces (pure Kotlin)
28
+ ├── data/ # Repository implementations, DataSources, DB, network
29
+ ├── presentation/ # Screens, ViewModels, UI models, navigation
30
+ ├── design-system/ # Reusable Compose components, theme, typography
31
+ └── feature/ # Feature modules (optional, for larger projects)
32
+ ├── auth/
33
+ ├── settings/
34
+ └── profile/
35
+ ```
36
+
37
+ ### Dependency Rules
38
+
39
+ ```
40
+ app → presentation, domain, data, core
41
+ presentation → domain, design-system, core
42
+ data → domain, core
43
+ domain → core (or no dependencies)
44
+ core → (nothing)
45
+ ```
46
+
47
+ **Critical**: `domain` must NEVER depend on `data`, `presentation`, or any framework. It contains pure Kotlin only.
48
+
49
+ ## Domain Layer
50
+
51
+ ### UseCase Pattern
52
+
53
+ Each UseCase represents one business operation. Use `operator fun invoke` for clean call sites:
54
+
55
+ ```kotlin
56
+ class GetItemsByCategoryUseCase(
57
+ private val repository: ItemRepository
58
+ ) {
59
+ suspend operator fun invoke(category: String): Result<List<Item>> {
60
+ return repository.getItemsByCategory(category)
61
+ }
62
+ }
63
+
64
+ // Flow-based UseCase for reactive streams
65
+ class ObserveUserProgressUseCase(
66
+ private val repository: UserRepository
67
+ ) {
68
+ operator fun invoke(userId: String): Flow<UserProgress> {
69
+ return repository.observeProgress(userId)
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Domain Models
75
+
76
+ Domain models are plain Kotlin data classes — no framework annotations:
77
+
78
+ ```kotlin
79
+ data class Item(
80
+ val id: String,
81
+ val title: String,
82
+ val description: String,
83
+ val tags: List<String>,
84
+ val status: Status,
85
+ val category: String
86
+ )
87
+
88
+ enum class Status { DRAFT, ACTIVE, ARCHIVED }
89
+ ```
90
+
91
+ ### Repository Interfaces
92
+
93
+ Defined in domain, implemented in data:
94
+
95
+ ```kotlin
96
+ interface ItemRepository {
97
+ suspend fun getItemsByCategory(category: String): Result<List<Item>>
98
+ suspend fun saveItem(item: Item): Result<Unit>
99
+ fun observeItems(): Flow<List<Item>>
100
+ }
101
+ ```
102
+
103
+ ## Data Layer
104
+
105
+ ### Repository Implementation
106
+
107
+ Coordinates between local and remote data sources:
108
+
109
+ ```kotlin
110
+ class ItemRepositoryImpl(
111
+ private val localDataSource: ItemLocalDataSource,
112
+ private val remoteDataSource: ItemRemoteDataSource
113
+ ) : ItemRepository {
114
+
115
+ override suspend fun getItemsByCategory(category: String): Result<List<Item>> {
116
+ return runCatching {
117
+ val remote = remoteDataSource.fetchItems(category)
118
+ localDataSource.insertItems(remote.map { it.toEntity() })
119
+ localDataSource.getItemsByCategory(category).map { it.toDomain() }
120
+ }
121
+ }
122
+
123
+ override suspend fun saveItem(item: Item): Result<Unit> {
124
+ return runCatching {
125
+ localDataSource.insertItems(listOf(item.toEntity()))
126
+ }
127
+ }
128
+
129
+ override fun observeItems(): Flow<List<Item>> {
130
+ return localDataSource.observeAll().map { entities ->
131
+ entities.map { it.toDomain() }
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
137
+ ### Mapper Pattern
138
+
139
+ Keep mappers as extension functions near the data models:
140
+
141
+ ```kotlin
142
+ // In data layer
143
+ fun ItemEntity.toDomain() = Item(
144
+ id = id,
145
+ title = title,
146
+ description = description,
147
+ tags = tags.split("|"),
148
+ status = Status.valueOf(status),
149
+ category = category
150
+ )
151
+
152
+ fun ItemDto.toEntity() = ItemEntity(
153
+ id = id,
154
+ title = title,
155
+ description = description,
156
+ tags = tags.joinToString("|"),
157
+ status = status,
158
+ category = category
159
+ )
160
+ ```
161
+
162
+ ### Room Database (Android)
163
+
164
+ ```kotlin
165
+ @Entity(tableName = "items")
166
+ data class ItemEntity(
167
+ @PrimaryKey val id: String,
168
+ val title: String,
169
+ val description: String,
170
+ val tags: String,
171
+ val status: String,
172
+ val category: String
173
+ )
174
+
175
+ @Dao
176
+ interface ItemDao {
177
+ @Query("SELECT * FROM items WHERE category = :category")
178
+ suspend fun getByCategory(category: String): List<ItemEntity>
179
+
180
+ @Upsert
181
+ suspend fun upsert(items: List<ItemEntity>)
182
+
183
+ @Query("SELECT * FROM items")
184
+ fun observeAll(): Flow<List<ItemEntity>>
185
+ }
186
+ ```
187
+
188
+ ### SQLDelight (KMP)
189
+
190
+ ```sql
191
+ -- Item.sq
192
+ CREATE TABLE ItemEntity (
193
+ id TEXT NOT NULL PRIMARY KEY,
194
+ title TEXT NOT NULL,
195
+ description TEXT NOT NULL,
196
+ tags TEXT NOT NULL,
197
+ status TEXT NOT NULL,
198
+ category TEXT NOT NULL
199
+ );
200
+
201
+ getByCategory:
202
+ SELECT * FROM ItemEntity WHERE category = ?;
203
+
204
+ upsert:
205
+ INSERT OR REPLACE INTO ItemEntity (id, title, description, tags, status, category)
206
+ VALUES (?, ?, ?, ?, ?, ?);
207
+
208
+ observeAll:
209
+ SELECT * FROM ItemEntity;
210
+ ```
211
+
212
+ ### Ktor Network Client (KMP)
213
+
214
+ ```kotlin
215
+ class ItemRemoteDataSource(private val client: HttpClient) {
216
+
217
+ suspend fun fetchItems(category: String): List<ItemDto> {
218
+ return client.get("api/items") {
219
+ parameter("category", category)
220
+ }.body()
221
+ }
222
+ }
223
+
224
+ // HttpClient setup with content negotiation
225
+ val httpClient = HttpClient {
226
+ install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
227
+ install(Logging) { level = LogLevel.HEADERS }
228
+ defaultRequest { url("https://api.example.com/") }
229
+ }
230
+ ```
231
+
232
+ ## Dependency Injection
233
+
234
+ ### Koin (KMP-friendly)
235
+
236
+ ```kotlin
237
+ // Domain module
238
+ val domainModule = module {
239
+ factory { GetItemsByCategoryUseCase(get()) }
240
+ factory { ObserveUserProgressUseCase(get()) }
241
+ }
242
+
243
+ // Data module
244
+ val dataModule = module {
245
+ single<ItemRepository> { ItemRepositoryImpl(get(), get()) }
246
+ single { ItemLocalDataSource(get()) }
247
+ single { ItemRemoteDataSource(get()) }
248
+ }
249
+
250
+ // Presentation module
251
+ val presentationModule = module {
252
+ viewModelOf(::ItemListViewModel)
253
+ viewModelOf(::DashboardViewModel)
254
+ }
255
+ ```
256
+
257
+ ### Hilt (Android-only)
258
+
259
+ ```kotlin
260
+ @Module
261
+ @InstallIn(SingletonComponent::class)
262
+ abstract class RepositoryModule {
263
+ @Binds
264
+ abstract fun bindItemRepository(impl: ItemRepositoryImpl): ItemRepository
265
+ }
266
+
267
+ @HiltViewModel
268
+ class ItemListViewModel @Inject constructor(
269
+ private val getItems: GetItemsByCategoryUseCase
270
+ ) : ViewModel()
271
+ ```
272
+
273
+ ## Error Handling
274
+
275
+ ### Result/Try Pattern
276
+
277
+ Use `Result<T>` or a custom sealed type for error propagation:
278
+
279
+ ```kotlin
280
+ sealed interface Try<out T> {
281
+ data class Success<T>(val value: T) : Try<T>
282
+ data class Failure(val error: AppError) : Try<Nothing>
283
+ }
284
+
285
+ sealed interface AppError {
286
+ data class Network(val message: String) : AppError
287
+ data class Database(val message: String) : AppError
288
+ data object Unauthorized : AppError
289
+ }
290
+
291
+ // In ViewModel — map to UI state
292
+ viewModelScope.launch {
293
+ when (val result = getItems(category)) {
294
+ is Try.Success -> _state.update { it.copy(items = result.value, isLoading = false) }
295
+ is Try.Failure -> _state.update { it.copy(error = result.error.toMessage(), isLoading = false) }
296
+ }
297
+ }
298
+ ```
299
+
300
+ ## Convention Plugins (Gradle)
301
+
302
+ For KMP projects, use convention plugins to reduce build file duplication:
303
+
304
+ ```kotlin
305
+ // build-logic/src/main/kotlin/kmp-library.gradle.kts
306
+ plugins {
307
+ id("org.jetbrains.kotlin.multiplatform")
308
+ }
309
+
310
+ kotlin {
311
+ androidTarget()
312
+ iosX64(); iosArm64(); iosSimulatorArm64()
313
+ sourceSets {
314
+ commonMain.dependencies { /* shared deps */ }
315
+ commonTest.dependencies { implementation(kotlin("test")) }
316
+ }
317
+ }
318
+ ```
319
+
320
+ Apply in modules:
321
+
322
+ ```kotlin
323
+ // domain/build.gradle.kts
324
+ plugins { id("kmp-library") }
325
+ ```
326
+
327
+ ## Anti-Patterns to Avoid
328
+
329
+ - Importing Android framework classes in `domain` — keep it pure Kotlin
330
+ - Exposing database entities or DTOs to the UI layer — always map to domain models
331
+ - Putting business logic in ViewModels — extract to UseCases
332
+ - Using `GlobalScope` or unstructured coroutines — use `viewModelScope` or structured concurrency
333
+ - Fat repository implementations — split into focused DataSources
334
+ - Circular module dependencies — if A depends on B, B must not depend on A
335
+
336
+ ## References
337
+
338
+ See skill: `compose-multiplatform-patterns` for UI patterns.
339
+ See skill: `kotlin-coroutines-flows` for async patterns.
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: api-connector-builder
3
+ description: Build a new API connector or provider by matching the target repo's existing integration pattern exactly. Use when adding one more integration without inventing a second architecture.
4
+ origin: ECC direct-port adaptation
5
+ version: "1.0.0"
6
+ ---
7
+
8
+ # API Connector Builder
9
+
10
+ Use this when the job is to add a repo-native integration surface, not just a generic HTTP client.
11
+
12
+ The point is to match the host repository's pattern:
13
+
14
+ - connector layout
15
+ - config schema
16
+ - auth model
17
+ - error handling
18
+ - test style
19
+ - registration/discovery wiring
20
+
21
+ ## When to Use
22
+
23
+ - "Build a Jira connector for this project"
24
+ - "Add a Slack provider following the existing pattern"
25
+ - "Create a new integration for this API"
26
+ - "Build a plugin that matches the repo's connector style"
27
+
28
+ ## Guardrails
29
+
30
+ - do not invent a new integration architecture when the repo already has one
31
+ - do not start from vendor docs alone; start from existing in-repo connectors first
32
+ - do not stop at transport code if the repo expects registry wiring, tests, and docs
33
+ - do not cargo-cult old connectors if the repo has a newer current pattern
34
+
35
+ ## Workflow
36
+
37
+ ### 1. Learn the house style
38
+
39
+ Inspect at least 2 existing connectors/providers and map:
40
+
41
+ - file layout
42
+ - abstraction boundaries
43
+ - config model
44
+ - retry / pagination conventions
45
+ - registry hooks
46
+ - test fixtures and naming
47
+
48
+ ### 2. Narrow the target integration
49
+
50
+ Define only the surface the repo actually needs:
51
+
52
+ - auth flow
53
+ - key entities
54
+ - core read/write operations
55
+ - pagination and rate limits
56
+ - webhook or polling model
57
+
58
+ ### 3. Build in repo-native layers
59
+
60
+ Typical slices:
61
+
62
+ - config/schema
63
+ - client/transport
64
+ - mapping layer
65
+ - connector/provider entrypoint
66
+ - registration
67
+ - tests
68
+
69
+ ### 4. Validate against the source pattern
70
+
71
+ The new connector should look obvious in the codebase, not imported from a different ecosystem.
72
+
73
+ ## Reference Shapes
74
+
75
+ ### Provider-style
76
+
77
+ ```text
78
+ providers/
79
+ existing_provider/
80
+ __init__.py
81
+ provider.py
82
+ config.py
83
+ ```
84
+
85
+ ### Connector-style
86
+
87
+ ```text
88
+ integrations/
89
+ existing/
90
+ client.py
91
+ models.py
92
+ connector.py
93
+ ```
94
+
95
+ ### TypeScript plugin-style
96
+
97
+ ```text
98
+ src/integrations/
99
+ existing/
100
+ index.ts
101
+ client.ts
102
+ types.ts
103
+ test.ts
104
+ ```
105
+
106
+ ## Quality Checklist
107
+
108
+ - [ ] matches an existing in-repo integration pattern
109
+ - [ ] config validation exists
110
+ - [ ] auth and error handling are explicit
111
+ - [ ] pagination/retry behavior follows repo norms
112
+ - [ ] registry/discovery wiring is complete
113
+ - [ ] tests mirror the host repo's style
114
+ - [ ] docs/examples are updated if expected by the repo
115
+
116
+ ## Related Skills
117
+
118
+ - `backend-patterns`
119
+ - `mcp-server-patterns`
120
+ - `github-ops`
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: code-tour
3
+ description: Create CodeTour `.tour` files — persona-targeted, step-by-step walkthroughs with real file and line anchors. Use for onboarding tours, architecture walkthroughs, PR tours, RCA tours, and structured "explain how this works" requests.
4
+ origin: ECC
5
+ ---
6
+
7
+ # Code Tour
8
+
9
+ Create **CodeTour** `.tour` files for codebase walkthroughs that open directly to real files and line ranges. Tours live in `.tours/` and are meant for the CodeTour format, not ad hoc Markdown notes.
10
+
11
+ A good tour is a narrative for a specific reader:
12
+ - what they are looking at
13
+ - why it matters
14
+ - what path they should follow next
15
+
16
+ Only create `.tour` JSON files. Do not modify source code as part of this skill.
17
+
18
+ ## When to Use
19
+
20
+ Use this skill when:
21
+ - the user asks for a code tour, onboarding tour, architecture walkthrough, or PR tour
22
+ - the user says "explain how X works" and wants a reusable guided artifact
23
+ - the user wants a ramp-up path for a new engineer or reviewer
24
+ - the task is better served by a guided sequence than a flat summary
25
+
26
+ Examples:
27
+ - onboarding a new maintainer
28
+ - architecture tour for one service or package
29
+ - PR-review walk-through anchored to changed files
30
+ - RCA tour showing the failure path
31
+ - security review tour of trust boundaries and key checks
32
+
33
+ ## When NOT to Use
34
+
35
+ | Instead of code-tour | Use |
36
+ | --- | --- |
37
+ | A one-off explanation in chat is enough | answer directly |
38
+ | The user wants prose docs, not a `.tour` artifact | `documentation-lookup` or repo docs editing |
39
+ | The task is implementation or refactoring | do the implementation work |
40
+ | The task is broad codebase onboarding without a tour artifact | `codebase-onboarding` |
41
+
42
+ ## Workflow
43
+
44
+ ### 1. Discover
45
+
46
+ Explore the repo before writing anything:
47
+ - README and package/app entry points
48
+ - folder structure
49
+ - relevant config files
50
+ - the changed files if the tour is PR-focused
51
+
52
+ Do not start writing steps before you understand the shape of the code.
53
+
54
+ ### 2. Infer the reader
55
+
56
+ Decide the persona and depth from the request.
57
+
58
+ | Request shape | Persona | Suggested depth |
59
+ | --- | --- | --- |
60
+ | "onboarding", "new joiner" | `new-joiner` | 9-13 steps |
61
+ | "quick tour", "vibe check" | `vibecoder` | 5-8 steps |
62
+ | "architecture" | `architect` | 14-18 steps |
63
+ | "tour this PR" | `pr-reviewer` | 7-11 steps |
64
+ | "why did this break" | `rca-investigator` | 7-11 steps |
65
+ | "security review" | `security-reviewer` | 7-11 steps |
66
+ | "explain how this feature works" | `feature-explainer` | 7-11 steps |
67
+ | "debug this path" | `bug-fixer` | 7-11 steps |
68
+
69
+ ### 3. Read and verify anchors
70
+
71
+ Every file path and line anchor must be real:
72
+ - confirm the file exists
73
+ - confirm the line numbers are in range
74
+ - if using a selection, verify the exact block
75
+ - if the file is volatile, prefer a pattern-based anchor
76
+
77
+ Never guess line numbers.
78
+
79
+ ### 4. Write the `.tour`
80
+
81
+ Write to:
82
+
83
+ ```text
84
+ .tours/<persona>-<focus>.tour
85
+ ```
86
+
87
+ Keep the path deterministic and readable.
88
+
89
+ ### 5. Validate
90
+
91
+ Before finishing:
92
+ - every referenced path exists
93
+ - every line or selection is valid
94
+ - the first step is anchored to a real file or directory
95
+ - the tour tells a coherent story rather than listing files
96
+
97
+ ## Step Types
98
+
99
+ ### Content
100
+
101
+ Use sparingly, usually only for a closing step:
102
+
103
+ ```json
104
+ { "title": "Next Steps", "description": "You can now trace the request path end to end." }
105
+ ```
106
+
107
+ Do not make the first step content-only.
108
+
109
+ ### Directory
110
+
111
+ Use to orient the reader to a module:
112
+
113
+ ```json
114
+ { "directory": "src/services", "title": "Service Layer", "description": "The core orchestration logic lives here." }
115
+ ```
116
+
117
+ ### File + line
118
+
119
+ This is the default step type:
120
+
121
+ ```json
122
+ { "file": "src/auth/middleware.ts", "line": 42, "title": "Auth Gate", "description": "Every protected request passes here first." }
123
+ ```
124
+
125
+ ### Selection
126
+
127
+ Use when one code block matters more than the whole file:
128
+
129
+ ```json
130
+ {
131
+ "file": "src/core/pipeline.ts",
132
+ "selection": {
133
+ "start": { "line": 15, "character": 0 },
134
+ "end": { "line": 34, "character": 0 }
135
+ },
136
+ "title": "Request Pipeline",
137
+ "description": "This block wires validation, auth, and downstream execution."
138
+ }
139
+ ```
140
+
141
+ ### Pattern
142
+
143
+ Use when exact lines may drift:
144
+
145
+ ```json
146
+ { "file": "src/app.ts", "pattern": "export default class App", "title": "Application Entry" }
147
+ ```
148
+
149
+ ### URI
150
+
151
+ Use for PRs, issues, or docs when helpful:
152
+
153
+ ```json
154
+ { "uri": "https://github.com/org/repo/pull/456", "title": "The PR" }
155
+ ```
156
+
157
+ ## Writing Rule: SMIG
158
+
159
+ Each description should answer:
160
+ - **Situation**: what the reader is looking at
161
+ - **Mechanism**: how it works
162
+ - **Implication**: why it matters for this persona
163
+ - **Gotcha**: what a smart reader might miss
164
+
165
+ Keep descriptions compact, specific, and grounded in the actual code.
166
+
167
+ ## Narrative Shape
168
+
169
+ Use this arc unless the task clearly needs something different:
170
+ 1. orientation
171
+ 2. module map
172
+ 3. core execution path
173
+ 4. edge case or gotcha
174
+ 5. closing / next move
175
+
176
+ The tour should feel like a path, not an inventory.
177
+
178
+ ## Example
179
+
180
+ ```json
181
+ {
182
+ "$schema": "https://aka.ms/codetour-schema",
183
+ "title": "API Service Tour",
184
+ "description": "Walkthrough of the request path for the payments service.",
185
+ "ref": "main",
186
+ "steps": [
187
+ {
188
+ "directory": "src",
189
+ "title": "Source Root",
190
+ "description": "All runtime code for the service starts here."
191
+ },
192
+ {
193
+ "file": "src/server.ts",
194
+ "line": 12,
195
+ "title": "Entry Point",
196
+ "description": "The server boots here and wires middleware before any route is reached."
197
+ },
198
+ {
199
+ "file": "src/routes/payments.ts",
200
+ "line": 8,
201
+ "title": "Payment Routes",
202
+ "description": "Every payments request enters through this router before hitting service logic."
203
+ },
204
+ {
205
+ "title": "Next Steps",
206
+ "description": "You can now follow any payment request end to end with the main anchors in place."
207
+ }
208
+ ]
209
+ }
210
+ ```
211
+
212
+ ## Anti-Patterns
213
+
214
+ | Anti-pattern | Fix |
215
+ | --- | --- |
216
+ | Flat file listing | Tell a story with dependency between steps |
217
+ | Generic descriptions | Name the concrete code path or pattern |
218
+ | Guessed anchors | Verify every file and line first |
219
+ | Too many steps for a quick tour | Cut aggressively |
220
+ | First step is content-only | Anchor the first step to a real file or directory |
221
+ | Persona mismatch | Write for the actual reader, not a generic engineer |
222
+
223
+ ## Best Practices
224
+
225
+ - keep step count proportional to repo size and persona depth
226
+ - use directory steps for orientation, file steps for substance
227
+ - for PR tours, cover changed files first
228
+ - for monorepos, scope to the relevant packages instead of touring everything
229
+ - close with what the reader can now do, not a recap
230
+
231
+ ## Related Skills
232
+
233
+ - `codebase-onboarding`
234
+ - `coding-standards`
235
+ - `council`
236
+ - official upstream format: `microsoft/codetour`