opkg 0.6.1 → 0.7.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 (487) hide show
  1. package/README.md +109 -186
  2. package/assets/openpackage_ascii_dark.png +0 -0
  3. package/assets/openpackage_ascii_light.png +0 -0
  4. package/dist/commands/add.js +34 -10
  5. package/dist/commands/add.js.map +1 -1
  6. package/dist/commands/apply.js +16 -0
  7. package/dist/commands/apply.js.map +1 -0
  8. package/dist/commands/delete.js +1 -1
  9. package/dist/commands/delete.js.map +1 -1
  10. package/dist/commands/install.js +177 -8
  11. package/dist/commands/install.js.map +1 -1
  12. package/dist/commands/list.js +2 -2
  13. package/dist/commands/list.js.map +1 -1
  14. package/dist/commands/login.js +1 -1
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/logout.js +1 -1
  17. package/dist/commands/logout.js.map +1 -1
  18. package/dist/commands/new.js +125 -0
  19. package/dist/commands/new.js.map +1 -0
  20. package/dist/commands/pack.js +7 -13
  21. package/dist/commands/pack.js.map +1 -1
  22. package/dist/commands/pull.js +1 -1
  23. package/dist/commands/pull.js.map +1 -1
  24. package/dist/commands/push.js +1 -1
  25. package/dist/commands/push.js.map +1 -1
  26. package/dist/commands/remove.js +63 -0
  27. package/dist/commands/remove.js.map +1 -0
  28. package/dist/commands/save.js +11 -17
  29. package/dist/commands/save.js.map +1 -1
  30. package/dist/commands/set.js +33 -0
  31. package/dist/commands/set.js.map +1 -0
  32. package/dist/commands/show.js +16 -94
  33. package/dist/commands/show.js.map +1 -1
  34. package/dist/commands/status.js +26 -701
  35. package/dist/commands/status.js.map +1 -1
  36. package/dist/commands/uninstall.js +14 -427
  37. package/dist/commands/uninstall.js.map +1 -1
  38. package/dist/constants/index.js +72 -16
  39. package/dist/constants/index.js.map +1 -1
  40. package/dist/core/add/add-conflict-handler.js +1 -8
  41. package/dist/core/add/add-conflict-handler.js.map +1 -1
  42. package/dist/core/add/add-pipeline.js +12 -10
  43. package/dist/core/add/add-pipeline.js.map +1 -1
  44. package/dist/core/add/add-to-source-pipeline.js +123 -0
  45. package/dist/core/add/add-to-source-pipeline.js.map +1 -0
  46. package/dist/core/add/package-index-updater.js +77 -78
  47. package/dist/core/add/package-index-updater.js.map +1 -1
  48. package/dist/core/add/platform-path-transformer.js +6 -4
  49. package/dist/core/add/platform-path-transformer.js.map +1 -1
  50. package/dist/core/add/source-collector.js +2 -3
  51. package/dist/core/add/source-collector.js.map +1 -1
  52. package/dist/core/apply/apply-pipeline.js +110 -0
  53. package/dist/core/apply/apply-pipeline.js.map +1 -0
  54. package/dist/core/dependency-resolver.js +263 -21
  55. package/dist/core/dependency-resolver.js.map +1 -1
  56. package/dist/core/discovery/file-discovery.js +1 -2
  57. package/dist/core/discovery/file-discovery.js.map +1 -1
  58. package/dist/core/discovery/platform-files-discovery.js +33 -18
  59. package/dist/core/discovery/platform-files-discovery.js.map +1 -1
  60. package/dist/core/flows/flow-executor.js +974 -0
  61. package/dist/core/flows/flow-executor.js.map +1 -0
  62. package/dist/core/flows/flow-inverter.js +442 -0
  63. package/dist/core/flows/flow-inverter.js.map +1 -0
  64. package/dist/core/flows/flow-key-extractor.js +101 -0
  65. package/dist/core/flows/flow-key-extractor.js.map +1 -0
  66. package/dist/core/flows/flow-key-mapper.js +382 -0
  67. package/dist/core/flows/flow-key-mapper.js.map +1 -0
  68. package/dist/core/flows/flow-transforms.js +632 -0
  69. package/dist/core/flows/flow-transforms.js.map +1 -0
  70. package/dist/core/flows/map-pipeline/context.js +73 -0
  71. package/dist/core/flows/map-pipeline/context.js.map +1 -0
  72. package/dist/core/flows/map-pipeline/index.js +156 -0
  73. package/dist/core/flows/map-pipeline/index.js.map +1 -0
  74. package/dist/core/flows/map-pipeline/operations/copy.js +104 -0
  75. package/dist/core/flows/map-pipeline/operations/copy.js.map +1 -0
  76. package/dist/core/flows/map-pipeline/operations/pipe.js +70 -0
  77. package/dist/core/flows/map-pipeline/operations/pipe.js.map +1 -0
  78. package/dist/core/flows/map-pipeline/operations/rename.js +102 -0
  79. package/dist/core/flows/map-pipeline/operations/rename.js.map +1 -0
  80. package/dist/core/flows/map-pipeline/operations/set.js +50 -0
  81. package/dist/core/flows/map-pipeline/operations/set.js.map +1 -0
  82. package/dist/core/flows/map-pipeline/operations/switch.js +79 -0
  83. package/dist/core/flows/map-pipeline/operations/switch.js.map +1 -0
  84. package/dist/core/flows/map-pipeline/operations/transform.js +543 -0
  85. package/dist/core/flows/map-pipeline/operations/transform.js.map +1 -0
  86. package/dist/core/flows/map-pipeline/operations/unset.js +65 -0
  87. package/dist/core/flows/map-pipeline/operations/unset.js.map +1 -0
  88. package/dist/core/flows/map-pipeline/types.js +8 -0
  89. package/dist/core/flows/map-pipeline/types.js.map +1 -0
  90. package/dist/core/flows/map-pipeline/utils.js +278 -0
  91. package/dist/core/flows/map-pipeline/utils.js.map +1 -0
  92. package/dist/core/flows/platform-converter.js +328 -0
  93. package/dist/core/flows/platform-converter.js.map +1 -0
  94. package/dist/core/flows/source-resolver.js +192 -0
  95. package/dist/core/flows/source-resolver.js.map +1 -0
  96. package/dist/core/flows/toml-domain-transforms.js +23 -0
  97. package/dist/core/flows/toml-domain-transforms.js.map +1 -0
  98. package/dist/core/install/bulk-install-pipeline.js +68 -7
  99. package/dist/core/install/bulk-install-pipeline.js.map +1 -1
  100. package/dist/core/install/canonical-plan.js +3 -3
  101. package/dist/core/install/canonical-plan.js.map +1 -1
  102. package/dist/core/install/dry-run.js +3 -3
  103. package/dist/core/install/dry-run.js.map +1 -1
  104. package/dist/core/install/flow-based-installer.js +1158 -0
  105. package/dist/core/install/flow-based-installer.js.map +1 -0
  106. package/dist/core/install/flow-workspace-tracker.js +111 -0
  107. package/dist/core/install/flow-workspace-tracker.js.map +1 -0
  108. package/dist/core/install/format-detector.js +228 -0
  109. package/dist/core/install/format-detector.js.map +1 -0
  110. package/dist/core/install/git-package-loader.js +20 -0
  111. package/dist/core/install/git-package-loader.js.map +1 -0
  112. package/dist/core/install/install-errors.js +1 -1
  113. package/dist/core/install/install-errors.js.map +1 -1
  114. package/dist/core/install/install-flow.js +34 -14
  115. package/dist/core/install/install-flow.js.map +1 -1
  116. package/dist/core/install/install-pipeline.js +52 -17
  117. package/dist/core/install/install-pipeline.js.map +1 -1
  118. package/dist/core/install/install-reporting.js +26 -8
  119. package/dist/core/install/install-reporting.js.map +1 -1
  120. package/dist/core/install/local-source-resolution.js +103 -0
  121. package/dist/core/install/local-source-resolution.js.map +1 -0
  122. package/dist/core/install/marketplace-handler.js +221 -0
  123. package/dist/core/install/marketplace-handler.js.map +1 -0
  124. package/dist/core/install/path-install-pipeline.js +241 -0
  125. package/dist/core/install/path-install-pipeline.js.map +1 -0
  126. package/dist/core/install/path-package-loader.js +116 -0
  127. package/dist/core/install/path-package-loader.js.map +1 -0
  128. package/dist/core/install/plugin-detector.js +72 -0
  129. package/dist/core/install/plugin-detector.js.map +1 -0
  130. package/dist/core/install/plugin-to-universal-converter.js +218 -0
  131. package/dist/core/install/plugin-to-universal-converter.js.map +1 -0
  132. package/dist/core/install/plugin-transformer.js +191 -0
  133. package/dist/core/install/plugin-transformer.js.map +1 -0
  134. package/dist/core/install/version-selection.js +1 -1
  135. package/dist/core/install/version-selection.js.map +1 -1
  136. package/dist/core/openpackage.js +40 -22
  137. package/dist/core/openpackage.js.map +1 -1
  138. package/dist/core/pack/pack-output.js +62 -0
  139. package/dist/core/pack/pack-output.js.map +1 -0
  140. package/dist/core/pack/pack-pipeline.js +186 -0
  141. package/dist/core/pack/pack-pipeline.js.map +1 -0
  142. package/dist/core/package-context.js +45 -70
  143. package/dist/core/package-context.js.map +1 -1
  144. package/dist/core/package-creation.js +203 -0
  145. package/dist/core/package-creation.js.map +1 -0
  146. package/dist/core/package.js +20 -6
  147. package/dist/core/package.js.map +1 -1
  148. package/dist/core/platforms.js +665 -209
  149. package/dist/core/platforms.js.map +1 -1
  150. package/dist/core/push/push-context.js +1 -1
  151. package/dist/core/push/push-context.js.map +1 -1
  152. package/dist/core/push/push-upload.js +2 -2
  153. package/dist/core/push/push-upload.js.map +1 -1
  154. package/dist/core/registry.js +6 -6
  155. package/dist/core/registry.js.map +1 -1
  156. package/dist/core/remote-pull.js +2 -2
  157. package/dist/core/remote-pull.js.map +1 -1
  158. package/dist/core/remove/removal-collector.js +52 -0
  159. package/dist/core/remove/removal-collector.js.map +1 -0
  160. package/dist/core/remove/removal-confirmation.js +39 -0
  161. package/dist/core/remove/removal-confirmation.js.map +1 -0
  162. package/dist/core/remove/remove-from-source-pipeline.js +173 -0
  163. package/dist/core/remove/remove-from-source-pipeline.js.map +1 -0
  164. package/dist/core/save/constants.js +3 -3
  165. package/dist/core/save/constants.js.map +1 -1
  166. package/dist/core/save/flow-based-saver.js +270 -0
  167. package/dist/core/save/flow-based-saver.js.map +1 -0
  168. package/dist/core/save/name-resolution.js +1 -1
  169. package/dist/core/save/name-resolution.js.map +1 -1
  170. package/dist/core/save/package-yml-generator.js +4 -5
  171. package/dist/core/save/package-yml-generator.js.map +1 -1
  172. package/dist/core/save/save-candidate-builder.js +215 -0
  173. package/dist/core/save/save-candidate-builder.js.map +1 -0
  174. package/dist/core/save/save-candidate-loader.js +12 -11
  175. package/dist/core/save/save-candidate-loader.js.map +1 -1
  176. package/dist/core/save/save-conflict-analyzer.js +150 -0
  177. package/dist/core/save/save-conflict-analyzer.js.map +1 -0
  178. package/dist/core/save/save-conflict-resolution.js +28 -14
  179. package/dist/core/save/save-conflict-resolution.js.map +1 -1
  180. package/dist/core/save/save-conflict-resolver.js +31 -275
  181. package/dist/core/save/save-conflict-resolver.js.map +1 -1
  182. package/dist/core/save/save-group-builder.js +52 -0
  183. package/dist/core/save/save-group-builder.js.map +1 -0
  184. package/dist/core/save/save-interactive-resolver.js +190 -0
  185. package/dist/core/save/save-interactive-resolver.js.map +1 -0
  186. package/dist/core/save/save-pipeline.js +58 -34
  187. package/dist/core/save/save-pipeline.js.map +1 -1
  188. package/dist/core/save/save-platform-handler.js +53 -0
  189. package/dist/core/save/save-platform-handler.js.map +1 -0
  190. package/dist/core/save/save-resolution-executor.js +145 -0
  191. package/dist/core/save/save-resolution-executor.js.map +1 -0
  192. package/dist/core/save/save-result-reporter.js +167 -0
  193. package/dist/core/save/save-result-reporter.js.map +1 -0
  194. package/dist/core/save/save-to-source-pipeline.js +154 -0
  195. package/dist/core/save/save-to-source-pipeline.js.map +1 -0
  196. package/dist/core/save/save-versioning.js +4 -4
  197. package/dist/core/save/save-versioning.js.map +1 -1
  198. package/dist/core/save/save-write-coordinator.js +204 -0
  199. package/dist/core/save/save-write-coordinator.js.map +1 -0
  200. package/dist/core/save/save-yml-resolution.js +28 -216
  201. package/dist/core/save/save-yml-resolution.js.map +1 -1
  202. package/dist/core/save/workspace-rename.js +7 -8
  203. package/dist/core/save/workspace-rename.js.map +1 -1
  204. package/dist/core/set/set-output.js +72 -0
  205. package/dist/core/set/set-output.js.map +1 -0
  206. package/dist/core/set/set-pipeline.js +361 -0
  207. package/dist/core/set/set-pipeline.js.map +1 -0
  208. package/dist/core/set/set-types.js +5 -0
  209. package/dist/core/set/set-types.js.map +1 -0
  210. package/dist/core/show/package-resolver.js +257 -0
  211. package/dist/core/show/package-resolver.js.map +1 -0
  212. package/dist/core/show/scope-discovery.js +165 -0
  213. package/dist/core/show/scope-discovery.js.map +1 -0
  214. package/dist/core/show/show-output.js +168 -0
  215. package/dist/core/show/show-output.js.map +1 -0
  216. package/dist/core/show/show-pipeline.js +113 -0
  217. package/dist/core/show/show-pipeline.js.map +1 -0
  218. package/dist/core/show/show-types.js +5 -0
  219. package/dist/core/show/show-types.js.map +1 -0
  220. package/dist/core/source-resolution/dependency-graph.js +104 -0
  221. package/dist/core/source-resolution/dependency-graph.js.map +1 -0
  222. package/dist/core/source-resolution/resolve-mutable-source.js +109 -0
  223. package/dist/core/source-resolution/resolve-mutable-source.js.map +1 -0
  224. package/dist/core/source-resolution/resolve-package-source.js +29 -0
  225. package/dist/core/source-resolution/resolve-package-source.js.map +1 -0
  226. package/dist/core/source-resolution/resolve-registry-version.js +35 -0
  227. package/dist/core/source-resolution/resolve-registry-version.js.map +1 -0
  228. package/dist/core/source-resolution/types.js.map +1 -0
  229. package/dist/core/status/status-file-discovery.js +23 -12
  230. package/dist/core/status/status-file-discovery.js.map +1 -1
  231. package/dist/core/status/status-pipeline.js +134 -0
  232. package/dist/core/status/status-pipeline.js.map +1 -0
  233. package/dist/core/sync/platform-sync-summary.js +27 -0
  234. package/dist/core/sync/platform-sync-summary.js.map +1 -0
  235. package/dist/core/uninstall/flow-aware-uninstaller.js +189 -0
  236. package/dist/core/uninstall/flow-aware-uninstaller.js.map +1 -0
  237. package/dist/core/uninstall/uninstall-file-discovery.js +11 -6
  238. package/dist/core/uninstall/uninstall-file-discovery.js.map +1 -1
  239. package/dist/core/uninstall/uninstall-pipeline.js +141 -0
  240. package/dist/core/uninstall/uninstall-pipeline.js.map +1 -0
  241. package/dist/core/universal-patterns.js +64 -0
  242. package/dist/core/universal-patterns.js.map +1 -0
  243. package/dist/index.js +99 -6
  244. package/dist/index.js.map +1 -1
  245. package/dist/types/flows.js +8 -0
  246. package/dist/types/flows.js.map +1 -0
  247. package/dist/types/index.js +3 -0
  248. package/dist/types/index.js.map +1 -1
  249. package/dist/types/platform-flows.js +8 -0
  250. package/dist/types/platform-flows.js.map +1 -0
  251. package/dist/types/workspace-index.js +6 -0
  252. package/dist/types/workspace-index.js.map +1 -0
  253. package/dist/utils/custom-path-resolution.js +160 -0
  254. package/dist/utils/custom-path-resolution.js.map +1 -0
  255. package/dist/utils/dependency-coverage.js +1 -1
  256. package/dist/utils/dependency-coverage.js.map +1 -1
  257. package/dist/utils/file-processing.js +1 -1
  258. package/dist/utils/flow-index-installer.js +209 -0
  259. package/dist/utils/flow-index-installer.js.map +1 -0
  260. package/dist/utils/formatters.js +47 -1
  261. package/dist/utils/formatters.js.map +1 -1
  262. package/dist/utils/fs.js +17 -0
  263. package/dist/utils/fs.js.map +1 -1
  264. package/dist/utils/git-clone-registry.js +88 -0
  265. package/dist/utils/git-clone-registry.js.map +1 -0
  266. package/dist/utils/git-clone.js +69 -0
  267. package/dist/utils/git-clone.js.map +1 -0
  268. package/dist/utils/git-spec.js +96 -0
  269. package/dist/utils/git-spec.js.map +1 -0
  270. package/dist/utils/http-client.js +7 -0
  271. package/dist/utils/http-client.js.map +1 -1
  272. package/dist/utils/index-based-installer.js +356 -163
  273. package/dist/utils/index-based-installer.js.map +1 -1
  274. package/dist/utils/install-conflict-handler.js +2 -2
  275. package/dist/utils/install-conflict-handler.js.map +1 -1
  276. package/dist/utils/install-file-discovery.js +18 -13
  277. package/dist/utils/install-file-discovery.js.map +1 -1
  278. package/dist/utils/install-helpers.js +43 -20
  279. package/dist/utils/install-helpers.js.map +1 -1
  280. package/dist/utils/jsonc.js +23 -1
  281. package/dist/utils/jsonc.js.map +1 -1
  282. package/dist/utils/manifest-paths.js +1 -1
  283. package/dist/utils/manifest-paths.js.map +1 -1
  284. package/dist/utils/markdown-frontmatter.js +46 -0
  285. package/dist/utils/markdown-frontmatter.js.map +1 -1
  286. package/dist/utils/package-copy.js +5 -103
  287. package/dist/utils/package-copy.js.map +1 -1
  288. package/dist/utils/package-filters.js +9 -105
  289. package/dist/utils/package-filters.js.map +1 -1
  290. package/dist/utils/package-index-yml.js +27 -6
  291. package/dist/utils/package-index-yml.js.map +1 -1
  292. package/dist/utils/package-input.js +98 -0
  293. package/dist/utils/package-input.js.map +1 -0
  294. package/dist/utils/package-management.js +80 -28
  295. package/dist/utils/package-management.js.map +1 -1
  296. package/dist/utils/package-name-resolution.js +327 -0
  297. package/dist/utils/package-name-resolution.js.map +1 -0
  298. package/dist/utils/package-name.js +18 -16
  299. package/dist/utils/package-name.js.map +1 -1
  300. package/dist/utils/package-versioning.js +2 -33
  301. package/dist/utils/package-versioning.js.map +1 -1
  302. package/dist/utils/package-yml.js +19 -28
  303. package/dist/utils/package-yml.js.map +1 -1
  304. package/dist/utils/path-resolution.js +102 -0
  305. package/dist/utils/path-resolution.js.map +1 -0
  306. package/dist/utils/paths.js +6 -6
  307. package/dist/utils/paths.js.map +1 -1
  308. package/dist/utils/platform-file.js +36 -24
  309. package/dist/utils/platform-file.js.map +1 -1
  310. package/dist/utils/platform-mapper.js +222 -68
  311. package/dist/utils/platform-mapper.js.map +1 -1
  312. package/dist/utils/platform-root-files.js +44 -0
  313. package/dist/utils/platform-root-files.js.map +1 -0
  314. package/dist/utils/platform-utils.js +35 -54
  315. package/dist/utils/platform-utils.js.map +1 -1
  316. package/dist/utils/platform-yaml-merge.js +20 -140
  317. package/dist/utils/platform-yaml-merge.js.map +1 -1
  318. package/dist/utils/prompts.js +92 -7
  319. package/dist/utils/prompts.js.map +1 -1
  320. package/dist/utils/registry-entry-filter.js +50 -27
  321. package/dist/utils/registry-entry-filter.js.map +1 -1
  322. package/dist/utils/registry-paths.js +5 -4
  323. package/dist/utils/registry-paths.js.map +1 -1
  324. package/dist/utils/scope-resolution.js +156 -0
  325. package/dist/utils/scope-resolution.js.map +1 -0
  326. package/dist/utils/source-mutability.js +15 -0
  327. package/dist/utils/source-mutability.js.map +1 -0
  328. package/dist/utils/tarball.js +29 -4
  329. package/dist/utils/tarball.js.map +1 -1
  330. package/dist/utils/version-ranges.js +1 -32
  331. package/dist/utils/version-ranges.js.map +1 -1
  332. package/dist/utils/workspace-index-helpers.js +28 -0
  333. package/dist/utils/workspace-index-helpers.js.map +1 -0
  334. package/dist/utils/workspace-index-ownership.js +100 -0
  335. package/dist/utils/workspace-index-ownership.js.map +1 -0
  336. package/dist/utils/workspace-index-yml.js +173 -0
  337. package/dist/utils/workspace-index-yml.js.map +1 -0
  338. package/examples/custom-subdirs-platform.jsonc +157 -0
  339. package/package.json +7 -2
  340. package/platforms.jsonc +531 -84
  341. package/schemas/map-pipeline-v1.json +256 -0
  342. package/schemas/platforms-v1.json +400 -0
  343. package/specs/README.md +88 -0
  344. package/specs/add/README.md +166 -0
  345. package/specs/agents-claude.md +570 -0
  346. package/specs/agents-opencode.md +622 -0
  347. package/specs/apply/README.md +21 -0
  348. package/specs/apply/apply-behavior.md +58 -0
  349. package/specs/apply/apply-command.md +51 -0
  350. package/specs/apply/conflicts.md +41 -0
  351. package/specs/apply/index-effects.md +81 -0
  352. package/specs/architecture.md +107 -0
  353. package/specs/auth/README.md +17 -0
  354. package/specs/auth/auth-http-contract.md +25 -0
  355. package/specs/auth/cli/credentials.md +39 -0
  356. package/specs/auth/cli/login.md +32 -0
  357. package/specs/auth/cli/logout.md +16 -0
  358. package/specs/claude-mcp.md +1065 -0
  359. package/specs/claude-plugins-marketplace.md +363 -0
  360. package/specs/claude-plugins.md +413 -0
  361. package/specs/cli-options.md +52 -0
  362. package/specs/codex-mcp.md +114 -0
  363. package/specs/commands-overview.md +175 -0
  364. package/specs/directory-layout.md +95 -0
  365. package/specs/install/README.md +12 -4
  366. package/specs/install/git-sources.md +230 -0
  367. package/specs/install/install-behavior.md +483 -73
  368. package/specs/install/package-yml-canonical.md +67 -35
  369. package/specs/install/version-resolution.md +69 -115
  370. package/specs/new/README.md +769 -0
  371. package/specs/new/SUMMARY.md +310 -0
  372. package/specs/new/scope-behavior.md +793 -0
  373. package/specs/pack/README.md +77 -0
  374. package/specs/pack/package-name-resolution.md +330 -0
  375. package/specs/package/README.md +18 -17
  376. package/specs/package/nested-packages-and-parent-packages.md +32 -31
  377. package/specs/package/package-index-yml.md +95 -101
  378. package/specs/package/package-root-layout.md +64 -46
  379. package/specs/package/registry-payload-and-copy.md +50 -44
  380. package/specs/package/universal-content.md +33 -56
  381. package/specs/package-sources.md +248 -0
  382. package/specs/platforms/README.md +52 -0
  383. package/specs/platforms/configuration.md +571 -0
  384. package/specs/platforms/detection.md +552 -0
  385. package/specs/platforms/directory-layout.md +599 -0
  386. package/specs/platforms/examples.md +1146 -0
  387. package/specs/platforms/flow-reference.md +1240 -0
  388. package/specs/platforms/flows.md +1488 -0
  389. package/specs/platforms/map-pipeline.md +801 -0
  390. package/specs/platforms/overview.md +349 -0
  391. package/specs/platforms/specification.md +700 -0
  392. package/specs/platforms/troubleshooting.md +697 -0
  393. package/specs/platforms/universal-converter.md +520 -0
  394. package/specs/push/README.md +1 -0
  395. package/specs/push/push-behavior.md +11 -3
  396. package/specs/push/push-remote-upload.md +1 -1
  397. package/specs/push/push-scoping.md +1 -1
  398. package/specs/push/push-version-selection.md +1 -1
  399. package/specs/registry.md +111 -0
  400. package/specs/remove/README.md +257 -0
  401. package/specs/save/README.md +21 -17
  402. package/specs/save/save-conflict-resolution.md +205 -83
  403. package/specs/save/save-file-discovery.md +6 -4
  404. package/specs/save/save-frontmatter-overrides.md +11 -15
  405. package/specs/save/save-modes-inputs.md +9 -39
  406. package/specs/save/save-naming-scoping.md +4 -4
  407. package/specs/save/save-package-detection.md +13 -13
  408. package/specs/save/save-registry-sync.md +16 -106
  409. package/specs/save/save-versioning.md +80 -0
  410. package/specs/scope-management.md +92 -0
  411. package/specs/set/README.md +520 -0
  412. package/specs/set/set-behavior.md +563 -0
  413. package/specs/show/README.md +483 -0
  414. package/specs/show/show-remote.md +494 -0
  415. package/specs/status/README.md +38 -0
  416. package/specs/uninstall/README.md +231 -0
  417. package/dist/commands/duplicate.js +0 -69
  418. package/dist/commands/duplicate.js.map +0 -1
  419. package/dist/commands/init.js +0 -117
  420. package/dist/commands/init.js.map +0 -1
  421. package/dist/commands/prune.js +0 -357
  422. package/dist/commands/prune.js.map +0 -1
  423. package/dist/commands/tui.js +0 -61
  424. package/dist/commands/tui.js.map +0 -1
  425. package/dist/core/install/index.js +0 -3
  426. package/dist/core/install/index.js.map +0 -1
  427. package/dist/core/push/push-single-file.js +0 -56
  428. package/dist/core/push/push-single-file.js.map +0 -1
  429. package/dist/core/save/package-detection.js +0 -147
  430. package/dist/core/save/package-detection.js.map +0 -1
  431. package/dist/core/save/save-single-file.js +0 -124
  432. package/dist/core/save/save-single-file.js.map +0 -1
  433. package/dist/core/token-store.js +0 -73
  434. package/dist/core/token-store.js.map +0 -1
  435. package/dist/tui/app.js +0 -95
  436. package/dist/tui/app.js.map +0 -1
  437. package/dist/tui/components/package-list.js +0 -73
  438. package/dist/tui/components/package-list.js.map +0 -1
  439. package/dist/tui/controller.js +0 -365
  440. package/dist/tui/controller.js.map +0 -1
  441. package/dist/tui/index.js +0 -12
  442. package/dist/tui/index.js.map +0 -1
  443. package/dist/tui/services/file-index.js +0 -64
  444. package/dist/tui/services/file-index.js.map +0 -1
  445. package/dist/tui/services/packages.js +0 -18
  446. package/dist/tui/services/packages.js.map +0 -1
  447. package/dist/tui/services/save.js +0 -21
  448. package/dist/tui/services/save.js.map +0 -1
  449. package/dist/tui/state/app-state.js +0 -15
  450. package/dist/tui/state/app-state.js.map +0 -1
  451. package/dist/tui/state.js +0 -17
  452. package/dist/tui/state.js.map +0 -1
  453. package/dist/tui/types.js.map +0 -1
  454. package/dist/tui/views/add-file-modal.js +0 -129
  455. package/dist/tui/views/add-file-modal.js.map +0 -1
  456. package/dist/tui/views/file-preview.js +0 -44
  457. package/dist/tui/views/file-preview.js.map +0 -1
  458. package/dist/tui/views/list-packages.js +0 -73
  459. package/dist/tui/views/list-packages.js.map +0 -1
  460. package/dist/tui/views/main-menu.js +0 -29
  461. package/dist/tui/views/main-menu.js.map +0 -1
  462. package/dist/tui/views/manage-view.js +0 -81
  463. package/dist/tui/views/manage-view.js.map +0 -1
  464. package/dist/tui/views/package-hub.js +0 -120
  465. package/dist/tui/views/package-hub.js.map +0 -1
  466. package/dist/tui/views/placeholder.js +0 -24
  467. package/dist/tui/views/placeholder.js.map +0 -1
  468. package/dist/utils/bun-bootstrap.js +0 -72
  469. package/dist/utils/bun-bootstrap.js.map +0 -1
  470. package/dist/utils/entity-id.js +0 -19
  471. package/dist/utils/entity-id.js.map +0 -1
  472. package/dist/utils/package-local-files.js +0 -5
  473. package/dist/utils/package-local-files.js.map +0 -1
  474. package/dist/utils/path-matching.js +0 -74
  475. package/dist/utils/path-matching.js.map +0 -1
  476. package/dist/utils/root-file-operations.js +0 -39
  477. package/dist/utils/root-file-operations.js.map +0 -1
  478. package/dist/utils/root-file-transformer.js +0 -27
  479. package/dist/utils/root-file-transformer.js.map +0 -1
  480. package/dist/utils/yaml-frontmatter.js +0 -25
  481. package/dist/utils/yaml-frontmatter.js.map +0 -1
  482. package/specs/auth/auth-device-flow.md +0 -70
  483. package/specs/login/login-device-flow.md +0 -70
  484. package/specs/platforms.md +0 -193
  485. package/specs/save-pack-versioning.md +0 -224
  486. package/specs/save-pack.md +0 -68
  487. /package/dist/{tui → core/source-resolution}/types.js +0 -0
@@ -0,0 +1,570 @@
1
+ # Subagents
2
+
3
+ > Create and use specialized AI subagents in Claude Code for task-specific workflows and improved context management.
4
+
5
+ Custom subagents in Claude Code are specialized AI assistants that can be invoked to handle specific types of tasks. They enable more efficient problem-solving by providing task-specific configurations with customized system prompts, tools and a separate context window.
6
+
7
+ ## What are subagents?
8
+
9
+ Subagents are pre-configured AI personalities that Claude Code can delegate tasks to. Each subagent:
10
+
11
+ * Has a specific purpose and expertise area
12
+ * Uses its own context window separate from the main conversation
13
+ * Can be configured with specific tools it's allowed to use
14
+ * Includes a custom system prompt that guides its behavior
15
+
16
+ When Claude Code encounters a task that matches a subagent's expertise, it can delegate that task to the specialized subagent, which works independently and returns results.
17
+
18
+ ## Key benefits
19
+
20
+ <CardGroup cols={2}>
21
+ <Card title="Context preservation" icon="layer-group">
22
+ Each subagent operates in its own context, preventing pollution of the main conversation and keeping it focused on high-level objectives.
23
+ </Card>
24
+
25
+ <Card title="Specialized expertise" icon="brain">
26
+ Subagents can be fine-tuned with detailed instructions for specific domains, leading to higher success rates on designated tasks.
27
+ </Card>
28
+
29
+ <Card title="Reusability" icon="rotate">
30
+ Once created, you can use subagents across different projects and share them with your team for consistent workflows.
31
+ </Card>
32
+
33
+ <Card title="Flexible permissions" icon="shield-check">
34
+ Each subagent can have different tool access levels, allowing you to limit powerful tools to specific subagent types.
35
+ </Card>
36
+ </CardGroup>
37
+
38
+ ## Quick start
39
+
40
+ To create your first subagent:
41
+
42
+ <Steps>
43
+ <Step title="Open the subagents interface">
44
+ Run the following command:
45
+
46
+ ```
47
+ /agents
48
+ ```
49
+ </Step>
50
+
51
+ <Step title="Select 'Create New Agent'">
52
+ Choose whether to create a project-level or user-level subagent
53
+ </Step>
54
+
55
+ <Step title="Define the subagent">
56
+ * **Recommended**: generate with Claude first, then customize to make it yours
57
+ * Describe your subagent in detail, including when Claude should use it
58
+ * Select the tools you want to grant access to, or leave this blank to inherit all tools
59
+ * The interface shows all available tools
60
+ * If you're generating with Claude, you can also edit the system prompt in your own editor by pressing `e`
61
+ </Step>
62
+
63
+ <Step title="Save and use">
64
+ Your subagent is now available. Claude uses it automatically when appropriate, or you can invoke it explicitly:
65
+
66
+ ```
67
+ > Use the code-reviewer subagent to check my recent changes
68
+ ```
69
+ </Step>
70
+ </Steps>
71
+
72
+ ## Subagent configuration
73
+
74
+ ### File locations
75
+
76
+ Subagents are stored as Markdown files with YAML frontmatter in two possible locations:
77
+
78
+ | Type | Location | Scope | Priority |
79
+ | :-------------------- | :------------------ | :---------------------------- | :------- |
80
+ | **Project subagents** | `.claude/agents/` | Available in current project | Highest |
81
+ | **User subagents** | `~/.claude/agents/` | Available across all projects | Lower |
82
+
83
+ When subagent names conflict, project-level subagents take precedence over user-level subagents.
84
+
85
+ ### Plugin agents
86
+
87
+ [Plugins](/en/plugins) can provide custom subagents that integrate seamlessly with Claude Code. Plugin agents work identically to user-defined agents and appear in the `/agents` interface.
88
+
89
+ **Plugin agent locations**: plugins include agents in their `agents/` directory (or custom paths specified in the plugin manifest).
90
+
91
+ **Using plugin agents**:
92
+
93
+ * Plugin agents appear in `/agents` alongside your custom agents
94
+ * Can be invoked explicitly: "Use the code-reviewer agent from the security-plugin"
95
+ * Can be invoked automatically by Claude when appropriate
96
+ * Can be managed (viewed, inspected) through `/agents` interface
97
+
98
+ See the [plugin components reference](/en/plugins-reference#agents) for details on creating plugin agents.
99
+
100
+ ### CLI-based configuration
101
+
102
+ You can also define subagents dynamically using the `--agents` CLI flag, which accepts a JSON object:
103
+
104
+ ```bash theme={null}
105
+ claude --agents '{
106
+ "code-reviewer": {
107
+ "description": "Expert code reviewer. Use proactively after code changes.",
108
+ "prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.",
109
+ "tools": ["Read", "Grep", "Glob", "Bash"],
110
+ "model": "sonnet"
111
+ }
112
+ }'
113
+ ```
114
+
115
+ **Priority**: CLI-defined subagents have lower priority than project-level subagents but higher priority than user-level subagents.
116
+
117
+ **Use case**: This approach is useful for:
118
+
119
+ * Quick testing of subagent configurations
120
+ * Session-specific subagents that don't need to be saved
121
+ * Automation scripts that need custom subagents
122
+ * Sharing subagent definitions in documentation or scripts
123
+
124
+ For detailed information about the JSON format and all available options, see the [CLI reference documentation](/en/cli-reference#agents-flag-format).
125
+
126
+ ### File format
127
+
128
+ Each subagent is defined in a Markdown file with this structure:
129
+
130
+ ```markdown theme={null}
131
+ ---
132
+ name: your-sub-agent-name
133
+ description: Description of when this subagent should be invoked
134
+ tools: tool1, tool2, tool3 # Optional - inherits all tools if omitted
135
+ model: sonnet # Optional - specify model alias or 'inherit'
136
+ permissionMode: default # Optional - permission mode for the subagent
137
+ skills: skill1, skill2 # Optional - skills to auto-load
138
+ ---
139
+
140
+ Your subagent's system prompt goes here. This can be multiple paragraphs
141
+ and should clearly define the subagent's role, capabilities, and approach
142
+ to solving problems.
143
+
144
+ Include specific instructions, best practices, and any constraints
145
+ the subagent should follow.
146
+ ```
147
+
148
+ #### Configuration fields
149
+
150
+ | Field | Required | Description |
151
+ | :--------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
152
+ | `name` | Yes | Unique identifier using lowercase letters and hyphens |
153
+ | `description` | Yes | Natural language description of the subagent's purpose |
154
+ | `tools` | No | Comma-separated list of specific tools. If omitted, inherits all tools from the main thread |
155
+ | `model` | No | Model to use for this subagent. Can be a model alias (`sonnet`, `opus`, `haiku`) or `'inherit'` to use the main conversation's model. If omitted, defaults to the [configured subagent model](/en/model-config) |
156
+ | `permissionMode` | No | Permission mode for the subagent. Valid values: `default`, `acceptEdits`, `dontAsk`, `bypassPermissions`, `plan`, `ignore`. Controls how the subagent handles permission requests |
157
+ | `skills` | No | Comma-separated list of skill names to auto-load when the subagent starts. Subagents do not inherit Skills from the parent conversation. If omitted, no Skills are preloaded. |
158
+
159
+ ### Model selection
160
+
161
+ The `model` field allows you to control which [AI model](/en/model-config) the subagent uses:
162
+
163
+ * **Model alias**: Use one of the available aliases: `sonnet`, `opus`, or `haiku`
164
+ * **`'inherit'`**: Use the same model as the main conversation (useful for consistency)
165
+ * **Omitted**: If not specified, uses the default model configured for subagents (`sonnet`)
166
+
167
+ <Note>
168
+ Using `'inherit'` is particularly useful when you want your subagents to adapt to the model choice of the main conversation, ensuring consistent capabilities and response style throughout your session.
169
+ </Note>
170
+
171
+ ### Available tools
172
+
173
+ Subagents can be granted access to any of Claude Code's internal tools. See the [tools documentation](/en/settings#tools-available-to-claude) for a complete list of available tools.
174
+
175
+ <Tip>
176
+ **Recommended:** Use the `/agents` command to modify tool access - it provides an interactive interface that lists all available tools, including any connected MCP server tools, making it easier to select the ones you need.
177
+ </Tip>
178
+
179
+ You have two options for configuring tools:
180
+
181
+ * **Omit the `tools` field** to inherit all tools from the main thread (default), including MCP tools
182
+ * **Specify individual tools** as a comma-separated list for more granular control (can be edited manually or via `/agents`)
183
+
184
+ **MCP Tools**: Subagents can access MCP tools from configured MCP servers. When the `tools` field is omitted, subagents inherit all MCP tools available to the main thread.
185
+
186
+ ## Managing subagents
187
+
188
+ ### Using the /agents command (Recommended)
189
+
190
+ The `/agents` command provides a comprehensive interface for subagent management:
191
+
192
+ ```
193
+ /agents
194
+ ```
195
+
196
+ This opens an interactive menu where you can:
197
+
198
+ * View all available subagents (built-in, user, and project)
199
+ * Create new subagents with guided setup
200
+ * Edit existing custom subagents, including their tool access
201
+ * Delete custom subagents
202
+ * See which subagents are active when duplicates exist
203
+ * **Manage tool permissions** with a complete list of available tools
204
+
205
+ ### Direct file management
206
+
207
+ You can also manage subagents by working directly with their files:
208
+
209
+ ```bash theme={null}
210
+ # Create a project subagent
211
+ mkdir -p .claude/agents
212
+ echo '---
213
+ name: test-runner
214
+ description: Use proactively to run tests and fix failures
215
+ ---
216
+
217
+ You are a test automation expert. When you see code changes, proactively run the appropriate tests. If tests fail, analyze the failures and fix them while preserving the original test intent.' > .claude/agents/test-runner.md
218
+
219
+ # Create a user subagent
220
+ mkdir -p ~/.claude/agents
221
+ # ... create subagent file
222
+ ```
223
+
224
+ <Note>
225
+ Subagents created by manually adding files will be loaded the next time you start a Claude Code session. To create and use a subagent immediately without restarting, use the `/agents` command instead.
226
+ </Note>
227
+
228
+ ## Using subagents effectively
229
+
230
+ ### Automatic delegation
231
+
232
+ Claude Code proactively delegates tasks based on:
233
+
234
+ * The task description in your request
235
+ * The `description` field in subagent configurations
236
+ * Current context and available tools
237
+
238
+ <Tip>
239
+ To encourage more proactive subagent use, include phrases like "use PROACTIVELY" or "MUST BE USED" in your `description` field.
240
+ </Tip>
241
+
242
+ ### Explicit invocation
243
+
244
+ Request a specific subagent by mentioning it in your command:
245
+
246
+ ```
247
+ > Use the test-runner subagent to fix failing tests
248
+ > Have the code-reviewer subagent look at my recent changes
249
+ > Ask the debugger subagent to investigate this error
250
+ ```
251
+
252
+ ## Built-in subagents
253
+
254
+ Claude Code includes built-in subagents that are available out of the box:
255
+
256
+ ### General-purpose subagent
257
+
258
+ The general-purpose subagent is a capable agent for complex, multi-step tasks that require both exploration and action. Unlike the Explore subagent, it can modify files and execute a wider range of operations.
259
+
260
+ **Key characteristics:**
261
+
262
+ * **Model**: Uses Sonnet for more capable reasoning
263
+ * **Tools**: Has access to all tools
264
+ * **Mode**: Can read and write files, execute commands, make changes
265
+ * **Purpose**: Complex research tasks, multi-step operations, code modifications
266
+
267
+ **When Claude uses it:**
268
+
269
+ Claude delegates to the general-purpose subagent when:
270
+
271
+ * The task requires both exploration and modification
272
+ * Complex reasoning is needed to interpret search results
273
+ * Multiple strategies may be needed if initial searches fail
274
+ * The task has multiple steps that depend on each other
275
+
276
+ **Example scenario:**
277
+
278
+ ```
279
+ User: Find all the places where we handle authentication and update them to use the new token format
280
+
281
+ Claude: [Invokes general-purpose subagent]
282
+ [Agent searches for auth-related code across codebase]
283
+ [Agent reads and analyzes multiple files]
284
+ [Agent makes necessary edits]
285
+ [Returns detailed writeup of changes made]
286
+ ```
287
+
288
+ ### Plan subagent
289
+
290
+ The Plan subagent is a specialized built-in agent designed for use during plan mode. When Claude is operating in plan mode (non-execution mode), it uses the Plan subagent to conduct research and gather information about your codebase before presenting a plan.
291
+
292
+ **Key characteristics:**
293
+
294
+ * **Model**: Uses Sonnet for more capable analysis
295
+ * **Tools**: Has access to Read, Glob, Grep, and Bash tools for codebase exploration
296
+ * **Purpose**: Searches files, analyzes code structure, and gathers context
297
+ * **Automatic invocation**: Claude automatically uses this agent when in plan mode and needs to research the codebase
298
+
299
+ **How it works:**
300
+ When you're in plan mode and Claude needs to understand your codebase to create a plan, it delegates research tasks to the Plan subagent. This prevents infinite nesting of agents (subagents cannot spawn other subagents) while still allowing Claude to gather the necessary context.
301
+
302
+ **Example scenario:**
303
+
304
+ ```
305
+ User: [In plan mode] Help me refactor the authentication module
306
+
307
+ Claude: Let me research your authentication implementation first...
308
+ [Internally invokes Plan subagent to explore auth-related files]
309
+ [Plan subagent searches codebase and returns findings]
310
+ Claude: Based on my research, here's my proposed plan...
311
+ ```
312
+
313
+ <Tip>
314
+ The Plan subagent is only used in plan mode. In normal execution mode, Claude uses the general-purpose agent or other custom subagents you've created.
315
+ </Tip>
316
+
317
+ ### Explore subagent
318
+
319
+ The Explore subagent is a fast, lightweight agent optimized for searching and analyzing codebases. It operates in strict read-only mode and is designed for rapid file discovery and code exploration.
320
+
321
+ **Key characteristics:**
322
+
323
+ * **Model**: Uses Haiku for fast, low-latency searches
324
+ * **Mode**: Strictly read-only - cannot create, modify, or delete files
325
+ * **Tools available**:
326
+ * Glob - File pattern matching
327
+ * Grep - Content searching with regular expressions
328
+ * Read - Reading file contents
329
+ * Bash - Read-only commands only (ls, git status, git log, git diff, find, cat, head, tail)
330
+
331
+ **When Claude uses it:**
332
+
333
+ Claude will delegate to the Explore subagent when it needs to search or understand a codebase but doesn't need to make changes. This is more efficient than the main agent running multiple search commands directly, as content found during the exploration process doesn't bloat the main conversation.
334
+
335
+ **Thoroughness levels:**
336
+
337
+ When invoking the Explore subagent, Claude specifies a thoroughness level:
338
+
339
+ * **Quick** - Fast searches with minimal exploration. Good for targeted lookups.
340
+ * **Medium** - Moderate exploration. Balances speed and thoroughness.
341
+ * **Very thorough** - Comprehensive analysis across multiple locations and naming conventions. Used when the target might be in unexpected places.
342
+
343
+ **Example scenarios:**
344
+
345
+ ```
346
+ User: Where are errors from the client handled?
347
+
348
+ Claude: [Invokes Explore subagent with "medium" thoroughness]
349
+ [Explore uses Grep to search for error handling patterns]
350
+ [Explore uses Read to examine promising files]
351
+ [Returns findings with absolute file paths]
352
+ Claude: Client errors are handled in src/services/process.ts:712...
353
+ ```
354
+
355
+ ```
356
+ User: What's the codebase structure?
357
+
358
+ Claude: [Invokes Explore subagent with "quick" thoroughness]
359
+ [Explore uses Glob and ls to map directory structure]
360
+ [Returns overview of key directories and their purposes]
361
+ ```
362
+
363
+ ## Example subagents
364
+
365
+ ### Code reviewer
366
+
367
+ ```markdown theme={null}
368
+ ---
369
+ name: code-reviewer
370
+ description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
371
+ tools: Read, Grep, Glob, Bash
372
+ model: inherit
373
+ ---
374
+
375
+ You are a senior code reviewer ensuring high standards of code quality and security.
376
+
377
+ When invoked:
378
+ 1. Run git diff to see recent changes
379
+ 2. Focus on modified files
380
+ 3. Begin review immediately
381
+
382
+ Review checklist:
383
+ - Code is clear and readable
384
+ - Functions and variables are well-named
385
+ - No duplicated code
386
+ - Proper error handling
387
+ - No exposed secrets or API keys
388
+ - Input validation implemented
389
+ - Good test coverage
390
+ - Performance considerations addressed
391
+
392
+ Provide feedback organized by priority:
393
+ - Critical issues (must fix)
394
+ - Warnings (should fix)
395
+ - Suggestions (consider improving)
396
+
397
+ Include specific examples of how to fix issues.
398
+ ```
399
+
400
+ ### Debugger
401
+
402
+ ```markdown theme={null}
403
+ ---
404
+ name: debugger
405
+ description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
406
+ tools: Read, Edit, Bash, Grep, Glob
407
+ ---
408
+
409
+ You are an expert debugger specializing in root cause analysis.
410
+
411
+ When invoked:
412
+ 1. Capture error message and stack trace
413
+ 2. Identify reproduction steps
414
+ 3. Isolate the failure location
415
+ 4. Implement minimal fix
416
+ 5. Verify solution works
417
+
418
+ Debugging process:
419
+ - Analyze error messages and logs
420
+ - Check recent code changes
421
+ - Form and test hypotheses
422
+ - Add strategic debug logging
423
+ - Inspect variable states
424
+
425
+ For each issue, provide:
426
+ - Root cause explanation
427
+ - Evidence supporting the diagnosis
428
+ - Specific code fix
429
+ - Testing approach
430
+ - Prevention recommendations
431
+
432
+ Focus on fixing the underlying issue, not the symptoms.
433
+ ```
434
+
435
+ ### Data scientist
436
+
437
+ ```markdown theme={null}
438
+ ---
439
+ name: data-scientist
440
+ description: Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks and queries.
441
+ tools: Bash, Read, Write
442
+ model: sonnet
443
+ ---
444
+
445
+ You are a data scientist specializing in SQL and BigQuery analysis.
446
+
447
+ When invoked:
448
+ 1. Understand the data analysis requirement
449
+ 2. Write efficient SQL queries
450
+ 3. Use BigQuery command line tools (bq) when appropriate
451
+ 4. Analyze and summarize results
452
+ 5. Present findings clearly
453
+
454
+ Key practices:
455
+ - Write optimized SQL queries with proper filters
456
+ - Use appropriate aggregations and joins
457
+ - Include comments explaining complex logic
458
+ - Format results for readability
459
+ - Provide data-driven recommendations
460
+
461
+ For each analysis:
462
+ - Explain the query approach
463
+ - Document any assumptions
464
+ - Highlight key findings
465
+ - Suggest next steps based on data
466
+
467
+ Always ensure queries are efficient and cost-effective.
468
+ ```
469
+
470
+ ## Best practices
471
+
472
+ * **Start with Claude-generated agents**: We highly recommend generating your initial subagent with Claude and then iterating on it to make it personally yours. This approach gives you the best results - a solid foundation that you can customize to your specific needs.
473
+
474
+ * **Design focused subagents**: Create subagents with single, clear responsibilities rather than trying to make one subagent do everything. This improves performance and makes subagents more predictable.
475
+
476
+ * **Write detailed prompts**: Include specific instructions, examples, and constraints in your system prompts. The more guidance you provide, the better the subagent will perform.
477
+
478
+ * **Limit tool access**: Only grant tools that are necessary for the subagent's purpose. This improves security and helps the subagent focus on relevant actions.
479
+
480
+ * **Version control**: Check project subagents into version control so your team can benefit from and improve them collaboratively.
481
+
482
+ ## Advanced usage
483
+
484
+ ### Chaining subagents
485
+
486
+ For complex workflows, you can chain multiple subagents:
487
+
488
+ ```
489
+ > First use the code-analyzer subagent to find performance issues, then use the optimizer subagent to fix them
490
+ ```
491
+
492
+ ### Dynamic subagent selection
493
+
494
+ Claude Code intelligently selects subagents based on context. Make your `description` fields specific and action-oriented for best results.
495
+
496
+ ### Resumable subagents
497
+
498
+ Subagents can be resumed to continue previous conversations, which is particularly useful for long-running research or analysis tasks that need to be continued across multiple invocations.
499
+
500
+ **How it works:**
501
+
502
+ * Each subagent execution is assigned a unique `agentId`
503
+ * The agent's conversation is stored in a separate transcript file: `agent-{agentId}.jsonl`
504
+ * You can resume a previous agent by providing its `agentId` via the `resume` parameter
505
+ * When resumed, the agent continues with full context from its previous conversation
506
+
507
+ **Example workflow:**
508
+
509
+ Initial invocation:
510
+
511
+ ```
512
+ > Use the code-analyzer agent to start reviewing the authentication module
513
+
514
+ [Agent completes initial analysis and returns agentId: "abc123"]
515
+ ```
516
+
517
+ Resume the agent:
518
+
519
+ ```
520
+ > Resume agent abc123 and now analyze the authorization logic as well
521
+
522
+ [Agent continues with full context from previous conversation]
523
+ ```
524
+
525
+ **Use cases:**
526
+
527
+ * **Long-running research**: Break down large codebase analysis into multiple sessions
528
+ * **Iterative refinement**: Continue refining a subagent's work without losing context
529
+ * **Multi-step workflows**: Have a subagent work on related tasks sequentially while maintaining context
530
+
531
+ **Technical details:**
532
+
533
+ * Agent transcripts are stored in your project directory
534
+ * Recording is disabled during resume to avoid duplicating messages
535
+ * Both synchronous and asynchronous agents can be resumed
536
+ * The `resume` parameter accepts the agent ID from a previous execution
537
+
538
+ **Programmatic usage:**
539
+
540
+ If you're using the Agent SDK or interacting with the AgentTool directly, you can pass the `resume` parameter:
541
+
542
+ ```typescript theme={null}
543
+ {
544
+ "description": "Continue analysis",
545
+ "prompt": "Now examine the error handling patterns",
546
+ "subagent_type": "code-analyzer",
547
+ "resume": "abc123" // Agent ID from previous execution
548
+ }
549
+ ```
550
+
551
+ <Tip>
552
+ Keep track of agent IDs for tasks you may want to resume later. Claude Code displays the agent ID when a subagent completes its work.
553
+ </Tip>
554
+
555
+ ## Performance considerations
556
+
557
+ * **Context efficiency**: Agents help preserve main context, enabling longer overall sessions
558
+ * **Latency**: Subagents start off with a clean slate each time they are invoked and may add latency as they gather context that they require to do their job effectively.
559
+
560
+ ## Related documentation
561
+
562
+ * [Plugins](/en/plugins) - Extend Claude Code with custom agents through plugins
563
+ * [Slash commands](/en/slash-commands) - Learn about other built-in commands
564
+ * [Settings](/en/settings) - Configure Claude Code behavior
565
+ * [Hooks](/en/hooks) - Automate workflows with event handlers
566
+
567
+
568
+ ---
569
+
570
+ > To find navigation and other pages in this documentation, fetch the llms.txt file at: https://code.claude.com/docs/llms.txt