@rfxlamia/skillkit 1.0.0 → 1.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 (269) hide show
  1. package/agents/agents/creative-copywriter.md +212 -0
  2. package/agents/agents/dario-amodei.md +135 -0
  3. package/agents/agents/doc-simplifier.md +63 -0
  4. package/agents/agents/kotlin-pro.md +433 -0
  5. package/agents/agents/red-team.md +136 -0
  6. package/agents/agents/sam-altman.md +121 -0
  7. package/agents/agents/seo-manager.md +184 -0
  8. package/package.json +7 -2
  9. package/skills/quick-spec/tests/__pycache__/test_skill.cpython-314-pytest-9.0.2.pyc +0 -0
  10. package/skills/skillkit/.claude/settings.local.json +7 -0
  11. package/skills/skillkit/scripts/__pycache__/decision_helper.cpython-314.pyc +0 -0
  12. package/skills/skillkit/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
  13. package/skills/skillkit/scripts/__pycache__/quick_validate.cpython-314.pyc +0 -0
  14. package/skills/skillkit/scripts/__pycache__/test_generator.cpython-314-pytest-9.0.2.pyc +0 -0
  15. package/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-312.pyc +0 -0
  16. package/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-314.pyc +0 -0
  17. package/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-312.pyc +0 -0
  18. package/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-314.pyc +0 -0
  19. package/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-312.pyc +0 -0
  20. package/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-314.pyc +0 -0
  21. package/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-312.pyc +0 -0
  22. package/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-314.pyc +0 -0
  23. package/skills/skillkit-help/SKILL.md +81 -0
  24. package/skills/skillkit-help/knowledge/application/09-case-studies.md +257 -0
  25. package/skills/skillkit-help/knowledge/application/12-testing-and-validation.md +276 -0
  26. package/skills/skillkit-help/knowledge/foundation/01-why-skills-exist.md +246 -0
  27. package/skills/skillkit-help/knowledge/foundation/02-skills-vs-subagents-comparison.md +312 -0
  28. package/skills/skillkit-help/knowledge/foundation/03-skills-vs-subagents-decision-tree.md +346 -0
  29. package/skills/skillkit-help/knowledge/foundation/06-platform-constraints.md +237 -0
  30. package/skills/skillkit-help/knowledge/foundation/08-when-not-to-use-skills.md +270 -0
  31. package/skills/skillkit-help/template/SKILL.md +52 -0
  32. package/skills/skills/adversarial-review/SKILL.md +219 -0
  33. package/skills/skills/baby-education/SKILL.md +260 -0
  34. package/skills/skills/baby-education/references/advanced-techniques.md +323 -0
  35. package/skills/skills/baby-education/references/transformations.md +345 -0
  36. package/skills/skills/been-there-done-that/SKILL.md +455 -0
  37. package/skills/skills/been-there-done-that/references/analysis-patterns.md +162 -0
  38. package/skills/skills/been-there-done-that/references/git-commands.md +132 -0
  39. package/skills/skills/been-there-done-that/references/tree-insertion-logic.md +145 -0
  40. package/skills/skills/coolhunter/SKILL.md +270 -0
  41. package/skills/skills/coolhunter/assets/elicitation-methods.csv +51 -0
  42. package/skills/skills/coolhunter/knowledge/elicitation-methods.md +312 -0
  43. package/skills/skills/coolhunter/references/workflow-execution.md +238 -0
  44. package/skills/skills/coolhunter/workflow-plan-coolhunter.md +232 -0
  45. package/skills/skills/creative-copywriting/SKILL.md +324 -0
  46. package/skills/skills/creative-copywriting/databases/README.md +60 -0
  47. package/skills/skills/creative-copywriting/databases/carousel-structures.csv +16 -0
  48. package/skills/skills/creative-copywriting/databases/emotional-arcs.csv +11 -0
  49. package/skills/skills/creative-copywriting/databases/hook-formulas.csv +51 -0
  50. package/skills/skills/creative-copywriting/databases/power-words.csv +201 -0
  51. package/skills/skills/creative-copywriting/databases/psychological-triggers.csv +21 -0
  52. package/skills/skills/creative-copywriting/databases/read-more-patterns.csv +26 -0
  53. package/skills/skills/creative-copywriting/databases/swipe-triggers.csv +31 -0
  54. package/skills/skills/creative-copywriting/references/carousel-psychology.md +223 -0
  55. package/skills/skills/creative-copywriting/references/hook-anatomy.md +169 -0
  56. package/skills/skills/creative-copywriting/references/power-word-science.md +134 -0
  57. package/skills/skills/creative-copywriting/references/storytelling-frameworks.md +157 -0
  58. package/skills/skills/diverse-content-gen/SKILL.md +201 -0
  59. package/skills/skills/diverse-content-gen/references/advanced-techniques.md +320 -0
  60. package/skills/skills/diverse-content-gen/references/research-findings.md +379 -0
  61. package/skills/skills/diverse-content-gen/references/task-workflows.md +241 -0
  62. package/skills/skills/diverse-content-gen/references/tool-integration.md +419 -0
  63. package/skills/skills/diverse-content-gen/references/troubleshooting.md +426 -0
  64. package/skills/skills/diverse-content-gen/references/vs-core-technique.md +240 -0
  65. package/skills/skills/framework-critical-thinking/SKILL.md +220 -0
  66. package/skills/skills/framework-critical-thinking/references/bias_detector.md +375 -0
  67. package/skills/skills/framework-critical-thinking/references/fallback_handler.md +239 -0
  68. package/skills/skills/framework-critical-thinking/references/memory_curator.md +161 -0
  69. package/skills/skills/framework-critical-thinking/references/metacognitive_monitor.md +297 -0
  70. package/skills/skills/framework-critical-thinking/references/producer_critic_orchestrator.md +333 -0
  71. package/skills/skills/framework-critical-thinking/references/reasoning_router.md +235 -0
  72. package/skills/skills/framework-critical-thinking/references/reasoning_validator.md +97 -0
  73. package/skills/skills/framework-critical-thinking/references/reflection_trigger.md +78 -0
  74. package/skills/skills/framework-critical-thinking/references/self_verification.md +388 -0
  75. package/skills/skills/framework-critical-thinking/references/uncertainty_quantifier.md +207 -0
  76. package/skills/skills/framework-initiative/SKILL.md +231 -0
  77. package/skills/skills/framework-initiative/references/examples.md +150 -0
  78. package/skills/skills/framework-initiative/references/impact-analysis.md +157 -0
  79. package/skills/skills/framework-initiative/references/intent-patterns.md +145 -0
  80. package/skills/skills/framework-initiative/references/star-framework.md +165 -0
  81. package/skills/skills/humanize-docs/SKILL.md +203 -0
  82. package/skills/skills/humanize-docs/references/advanced-techniques.md +13 -0
  83. package/skills/skills/humanize-docs/references/core-transformations.md +368 -0
  84. package/skills/skills/humanize-docs/references/detection-patterns.md +400 -0
  85. package/skills/skills/humanize-docs/references/examples-gallery.md +374 -0
  86. package/skills/skills/imagine/SKILL.md +190 -0
  87. package/skills/skills/imagine/references/artstyle-corporate-memphis.md +625 -0
  88. package/skills/skills/imagine/references/artstyle-crewdson-hyperrealism.md +295 -0
  89. package/skills/skills/imagine/references/artstyle-iphone-social-media.md +426 -0
  90. package/skills/skills/imagine/references/artstyle-sciencesaru.md +276 -0
  91. package/skills/skills/pre-deploy-checklist/README.md +26 -0
  92. package/skills/skills/pre-deploy-checklist/SKILL.md +153 -0
  93. package/skills/skills/pre-deploy-checklist/references/checklist-categories.md +174 -0
  94. package/skills/skills/pre-deploy-checklist/references/domain-prompts.md +216 -0
  95. package/skills/skills/prompt-engineering/SKILL.md +209 -0
  96. package/skills/skills/prompt-engineering/references/advanced-combinations.md +444 -0
  97. package/skills/skills/prompt-engineering/references/chain-of-thought.md +140 -0
  98. package/skills/skills/prompt-engineering/references/decision_matrix.md +220 -0
  99. package/skills/skills/prompt-engineering/references/few-shot.md +346 -0
  100. package/skills/skills/prompt-engineering/references/json-format.md +270 -0
  101. package/skills/skills/prompt-engineering/references/natural-language.md +420 -0
  102. package/skills/skills/prompt-engineering/references/pitfalls.md +365 -0
  103. package/skills/skills/prompt-engineering/references/prompt-chaining.md +498 -0
  104. package/skills/skills/prompt-engineering/references/react.md +108 -0
  105. package/skills/skills/prompt-engineering/references/self-consistency.md +322 -0
  106. package/skills/skills/prompt-engineering/references/tree-of-thoughts.md +386 -0
  107. package/skills/skills/prompt-engineering/references/xml-format.md +220 -0
  108. package/skills/skills/prompt-engineering/references/yaml-format.md +488 -0
  109. package/skills/skills/prompt-engineering/references/zero-shot.md +74 -0
  110. package/skills/skills/quick-spec/SKILL.md +280 -0
  111. package/skills/skills/quick-spec/assets/tech-spec-template.md +74 -0
  112. package/skills/skills/quick-spec/references/step-01-understand.md +189 -0
  113. package/skills/skills/quick-spec/references/step-02-investigate.md +144 -0
  114. package/skills/skills/quick-spec/references/step-03-generate.md +128 -0
  115. package/skills/skills/quick-spec/references/step-04-review.md +173 -0
  116. package/skills/skills/quick-spec/tests/__pycache__/test_skill.cpython-314-pytest-9.0.2.pyc +0 -0
  117. package/skills/skills/quick-spec/tests/test_scenarios.md +83 -0
  118. package/skills/skills/quick-spec/tests/test_skill.py +136 -0
  119. package/skills/skills/readme-expert/SKILL.md +538 -0
  120. package/skills/skills/readme-expert/knowledge/INDEX.md +192 -0
  121. package/skills/skills/readme-expert/knowledge/application/quality-standards.md +470 -0
  122. package/skills/skills/readme-expert/knowledge/application/script-executor.md +604 -0
  123. package/skills/skills/readme-expert/knowledge/application/template-library.md +822 -0
  124. package/skills/skills/readme-expert/knowledge/foundation/codebase-scanner.md +361 -0
  125. package/skills/skills/readme-expert/knowledge/foundation/validation-checklist.md +481 -0
  126. package/skills/skills/red-teaming/SKILL.md +321 -0
  127. package/skills/skills/red-teaming/references/ai-llm-redteam.md +517 -0
  128. package/skills/skills/red-teaming/references/attack-techniques.md +410 -0
  129. package/skills/skills/red-teaming/references/cybersecurity-redteam.md +383 -0
  130. package/skills/skills/red-teaming/references/tools-frameworks.md +446 -0
  131. package/skills/skills/releasing/.skillkit-mode +1 -0
  132. package/skills/skills/releasing/SKILL.md +225 -0
  133. package/skills/skills/releasing/references/version-detection.md +108 -0
  134. package/skills/skills/screenwriter/SKILL.md +273 -0
  135. package/skills/skills/screenwriter/references/advanced-techniques.md +216 -0
  136. package/skills/skills/screenwriter/references/pipeline-integration.md +266 -0
  137. package/skills/skills/skillkit/.claude/settings.local.json +7 -0
  138. package/skills/skills/skillkit/.claude-plugin/plugin.json +27 -0
  139. package/skills/skills/skillkit/CHANGELOG.md +484 -0
  140. package/skills/skills/skillkit/SKILL.md +511 -0
  141. package/skills/skills/skillkit/commands/skillkit.md +6 -0
  142. package/skills/skills/skillkit/commands/validate-plan.md +6 -0
  143. package/skills/skills/skillkit/commands/verify.md +6 -0
  144. package/skills/skills/skillkit/knowledge/INDEX.md +352 -0
  145. package/skills/skills/skillkit/knowledge/application/09-case-studies.md +257 -0
  146. package/skills/skills/skillkit/knowledge/application/10-technical-architecture.md +324 -0
  147. package/skills/skills/skillkit/knowledge/application/11-adoption-strategy.md +267 -0
  148. package/skills/skills/skillkit/knowledge/application/12-testing-and-validation.md +276 -0
  149. package/skills/skills/skillkit/knowledge/application/13-competitive-landscape.md +198 -0
  150. package/skills/skills/skillkit/knowledge/foundation/01-why-skills-exist.md +246 -0
  151. package/skills/skills/skillkit/knowledge/foundation/02-skills-vs-subagents-comparison.md +312 -0
  152. package/skills/skills/skillkit/knowledge/foundation/03-skills-vs-subagents-decision-tree.md +346 -0
  153. package/skills/skills/skillkit/knowledge/foundation/04-hybrid-patterns.md +308 -0
  154. package/skills/skills/skillkit/knowledge/foundation/05-token-economics.md +275 -0
  155. package/skills/skills/skillkit/knowledge/foundation/06-platform-constraints.md +237 -0
  156. package/skills/skills/skillkit/knowledge/foundation/07-security-concerns.md +322 -0
  157. package/skills/skills/skillkit/knowledge/foundation/08-when-not-to-use-skills.md +270 -0
  158. package/skills/skills/skillkit/knowledge/plugin-guide.md +614 -0
  159. package/skills/skills/skillkit/knowledge/tools/14-validation-tools-guide.md +150 -0
  160. package/skills/skills/skillkit/knowledge/tools/15-cost-tools-guide.md +157 -0
  161. package/skills/skills/skillkit/knowledge/tools/16-security-tools-guide.md +122 -0
  162. package/skills/skills/skillkit/knowledge/tools/17-pattern-tools-guide.md +161 -0
  163. package/skills/skills/skillkit/knowledge/tools/18-decision-helper-guide.md +243 -0
  164. package/skills/skills/skillkit/knowledge/tools/19-test-generator-guide.md +275 -0
  165. package/skills/skills/skillkit/knowledge/tools/20-split-skill-guide.md +149 -0
  166. package/skills/skills/skillkit/knowledge/tools/21-quality-scorer-guide.md +226 -0
  167. package/skills/skills/skillkit/knowledge/tools/22-migration-helper-guide.md +356 -0
  168. package/skills/skills/skillkit/knowledge/tools/23-subagent-creation-guide.md +448 -0
  169. package/skills/skills/skillkit/knowledge/tools/24-behavioral-testing-guide.md +122 -0
  170. package/skills/skills/skillkit/references/proposal-generation.md +982 -0
  171. package/skills/skills/skillkit/references/rationalization-catalog.md +75 -0
  172. package/skills/skills/skillkit/references/research-methodology.md +661 -0
  173. package/skills/skills/skillkit/references/section-2-full-creation-workflow.md +452 -0
  174. package/skills/skills/skillkit/references/section-3-validation-workflow-existing-skill.md +63 -0
  175. package/skills/skills/skillkit/references/section-4-decision-workflow-skills-vs-subagents.md +64 -0
  176. package/skills/skills/skillkit/references/section-5-migration-workflow-doc-to-skill.md +58 -0
  177. package/skills/skills/skillkit/references/section-6-subagent-creation-workflow.md +499 -0
  178. package/skills/skills/skillkit/references/section-7-knowledge-reference-map.md +72 -0
  179. package/skills/skills/skillkit/scripts/__pycache__/decision_helper.cpython-314.pyc +0 -0
  180. package/skills/skills/skillkit/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
  181. package/skills/skills/skillkit/scripts/__pycache__/quick_validate.cpython-314.pyc +0 -0
  182. package/skills/skills/skillkit/scripts/__pycache__/test_generator.cpython-314-pytest-9.0.2.pyc +0 -0
  183. package/skills/skills/skillkit/scripts/decision_helper.py +799 -0
  184. package/skills/skills/skillkit/scripts/init_skill.py +400 -0
  185. package/skills/skills/skillkit/scripts/init_subagent.py +231 -0
  186. package/skills/skills/skillkit/scripts/migration_helper.py +669 -0
  187. package/skills/skills/skillkit/scripts/package_skill.py +211 -0
  188. package/skills/skills/skillkit/scripts/pattern_detector.py +381 -0
  189. package/skills/skills/skillkit/scripts/pattern_detector_new.py +382 -0
  190. package/skills/skills/skillkit/scripts/pressure_tester.py +157 -0
  191. package/skills/skills/skillkit/scripts/quality_scorer.py +999 -0
  192. package/skills/skills/skillkit/scripts/quick_validate.py +100 -0
  193. package/skills/skills/skillkit/scripts/security_scanner.py +474 -0
  194. package/skills/skills/skillkit/scripts/split_skill.py +540 -0
  195. package/skills/skills/skillkit/scripts/test_generator.py +695 -0
  196. package/skills/skills/skillkit/scripts/token_estimator.py +493 -0
  197. package/skills/skills/skillkit/scripts/utils/__init__.py +49 -0
  198. package/skills/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-312.pyc +0 -0
  199. package/skills/skills/skillkit/scripts/utils/__pycache__/__init__.cpython-314.pyc +0 -0
  200. package/skills/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-312.pyc +0 -0
  201. package/skills/skills/skillkit/scripts/utils/__pycache__/budget_tracker.cpython-314.pyc +0 -0
  202. package/skills/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-312.pyc +0 -0
  203. package/skills/skills/skillkit/scripts/utils/__pycache__/output_formatter.cpython-314.pyc +0 -0
  204. package/skills/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-312.pyc +0 -0
  205. package/skills/skills/skillkit/scripts/utils/__pycache__/reference_validator.cpython-314.pyc +0 -0
  206. package/skills/skills/skillkit/scripts/utils/budget_tracker.py +388 -0
  207. package/skills/skills/skillkit/scripts/utils/output_formatter.py +263 -0
  208. package/skills/skills/skillkit/scripts/utils/reference_validator.py +401 -0
  209. package/skills/skills/skillkit/scripts/validate_skill.py +594 -0
  210. package/skills/skills/skillkit/tests/test_behavioral.py +39 -0
  211. package/skills/skills/skillkit/tests/test_scenarios.md +83 -0
  212. package/skills/skills/skillkit/tests/test_skill.py +136 -0
  213. package/skills/skills/skillkit-help/SKILL.md +81 -0
  214. package/skills/skills/skillkit-help/knowledge/application/09-case-studies.md +257 -0
  215. package/skills/skills/skillkit-help/knowledge/application/12-testing-and-validation.md +276 -0
  216. package/skills/skills/skillkit-help/knowledge/foundation/01-why-skills-exist.md +246 -0
  217. package/skills/skills/skillkit-help/knowledge/foundation/02-skills-vs-subagents-comparison.md +312 -0
  218. package/skills/skills/skillkit-help/knowledge/foundation/03-skills-vs-subagents-decision-tree.md +346 -0
  219. package/skills/skills/skillkit-help/knowledge/foundation/06-platform-constraints.md +237 -0
  220. package/skills/skills/skillkit-help/knowledge/foundation/08-when-not-to-use-skills.md +270 -0
  221. package/skills/skills/skillkit-help/template/SKILL.md +52 -0
  222. package/skills/skills/social-media-seo/SKILL.md +278 -0
  223. package/skills/skills/social-media-seo/databases/caption-styles.csv +31 -0
  224. package/skills/skills/social-media-seo/databases/engagement-tactics.csv +16 -0
  225. package/skills/skills/social-media-seo/databases/hashtag-strategies.csv +21 -0
  226. package/skills/skills/social-media-seo/databases/hook-formulas.csv +26 -0
  227. package/skills/skills/social-media-seo/databases/keyword-clusters.csv +11 -0
  228. package/skills/skills/social-media-seo/databases/thread-structures.csv +26 -0
  229. package/skills/skills/social-media-seo/databases/viral-patterns.csv +21 -0
  230. package/skills/skills/social-media-seo/references/analytics-guide.md +321 -0
  231. package/skills/skills/social-media-seo/references/instagram-seo.md +235 -0
  232. package/skills/skills/social-media-seo/references/threads-seo.md +305 -0
  233. package/skills/skills/social-media-seo/references/x-twitter-seo.md +337 -0
  234. package/skills/skills/social-media-seo/scripts/query_database.py +191 -0
  235. package/skills/skills/storyteller/SKILL.md +241 -0
  236. package/skills/skills/storyteller/references/transformation-methodology.md +293 -0
  237. package/skills/skills/storyteller/references/visual-vocabulary.md +177 -0
  238. package/skills/skills/thread-pro/SKILL.md +162 -0
  239. package/skills/skills/thread-pro/anti-ai-patterns.md +120 -0
  240. package/skills/skills/thread-pro/hook-formulas.md +138 -0
  241. package/skills/skills/thread-pro/references/anti-ai-patterns.md +120 -0
  242. package/skills/skills/thread-pro/references/hook-formulas.md +138 -0
  243. package/skills/skills/thread-pro/references/thread-structures.md +240 -0
  244. package/skills/skills/thread-pro/references/voice-injection.md +130 -0
  245. package/skills/skills/thread-pro/thread-structures.md +240 -0
  246. package/skills/skills/thread-pro/voice-injection.md +130 -0
  247. package/skills/skills/tinkering/SKILL.md +251 -0
  248. package/skills/skills/tinkering/references/graduation-checklist.md +100 -0
  249. package/skills/skills/validate-plan/.skillkit-mode +1 -0
  250. package/skills/skills/validate-plan/SKILL.md +406 -0
  251. package/skills/skills/validate-plan/references/dry-principles.md +251 -0
  252. package/skills/skills/validate-plan/references/gap-analysis-guide.md +320 -0
  253. package/skills/skills/validate-plan/references/tdd-patterns.md +413 -0
  254. package/skills/skills/validate-plan/references/yagni-checklist.md +330 -0
  255. package/skills/skills/verify-before-ship/.skillkit-mode +1 -0
  256. package/skills/skills/verify-before-ship/SKILL.md +116 -0
  257. package/skills/skills/verify-before-ship/references/anti-rationalization.md +212 -0
  258. package/skills/skills/verify-before-ship/references/verification-gates.md +305 -0
  259. package/skills-manifest.json +8 -2
  260. package/src/banner.js +1 -1
  261. package/src/cli.js +15 -4
  262. package/src/install.js +45 -29
  263. package/src/install.test.js +75 -7
  264. package/src/picker.js +15 -4
  265. package/src/picker.test.js +36 -1
  266. package/src/scope.js +8 -39
  267. package/src/scope.test.js +9 -13
  268. package/src/tools.js +76 -0
  269. package/src/tools.test.js +80 -0
@@ -0,0 +1,498 @@
1
+ # Prompt Chaining
2
+
3
+ ## Overview
4
+
5
+ Prompt chaining breaks complex tasks into sequential prompts, where each prompt's output feeds into the next. This creates a pipeline of focused, manageable steps.
6
+
7
+ ## When to Use Prompt Chaining
8
+
9
+ ✅ **Use Chaining When:**
10
+ - Task is too complex for single prompt
11
+ - Natural sequential steps exist
12
+ - Each step has different requirements
13
+ - Intermediate outputs need validation
14
+ - Different models/techniques optimal for different steps
15
+ - Need to inspect/modify intermediate results
16
+
17
+ ❌ **Don't Use Chaining When:**
18
+ - Task is simple enough for single prompt
19
+ - Steps can't be cleanly separated
20
+ - Latency is critical (chaining is slower)
21
+ - No need to inspect intermediate results
22
+
23
+ ## Basic Structure
24
+
25
+ ```
26
+ User Input
27
+ → Prompt 1 → Output 1
28
+ → Prompt 2 (uses Output 1) → Output 2
29
+ → Prompt 3 (uses Output 2) → Output 3
30
+ → Final Result
31
+ ```
32
+
33
+ ## Template: 3-Step Chain (YAML)
34
+
35
+ ```yaml
36
+ # Prompt Chain Configuration
37
+ chain:
38
+ - step: 1
39
+ name: "Extract Information"
40
+ model: "gpt-4"
41
+ temperature: 0.3
42
+ prompt: |
43
+ Extract key information from this document:
44
+ {document}
45
+
46
+ Extract:
47
+ - Main topics
48
+ - Key entities (people, organizations, dates)
49
+ - Action items
50
+
51
+ output_to: "extracted_info"
52
+
53
+ - step: 2
54
+ name: "Analyze Sentiment"
55
+ model: "claude-3-sonnet"
56
+ temperature: 0.5
57
+ prompt: |
58
+ Based on this extracted information:
59
+ {extracted_info}
60
+
61
+ Analyze the sentiment and tone of the original document.
62
+ Provide:
63
+ - Overall sentiment (positive/negative/neutral)
64
+ - Emotional tone
65
+ - Key sentiment drivers
66
+
67
+ output_to: "sentiment_analysis"
68
+
69
+ - step: 3
70
+ name: "Generate Summary"
71
+ model: "claude-3-opus"
72
+ temperature: 0.7
73
+ prompt: |
74
+ Create a comprehensive summary using:
75
+
76
+ Extracted information: {extracted_info}
77
+ Sentiment analysis: {sentiment_analysis}
78
+
79
+ Summary should be 200 words, highlighting:
80
+ - Key points
81
+ - Overall tone
82
+ - Action items
83
+
84
+ output_to: "final_summary"
85
+ ```
86
+
87
+ ## Common Chain Patterns
88
+
89
+ ### Pattern 1: Extract → Transform → Generate
90
+
91
+ **Use case:** Document processing
92
+
93
+ ```
94
+ Step 1: Extract data from unstructured text
95
+ Input: Raw document
96
+ Output: Structured data (JSON)
97
+
98
+ Step 2: Transform/clean data
99
+ Input: Structured data
100
+ Output: Cleaned, normalized data
101
+
102
+ Step 3: Generate report
103
+ Input: Cleaned data
104
+ Output: Human-readable report
105
+ ```
106
+
107
+ **Example:**
108
+ ```
109
+ 1. Extract customer feedback → JSON with issues
110
+ 2. Categorize issues → Grouped by category
111
+ 3. Generate executive summary → Final report
112
+ ```
113
+
114
+ ---
115
+
116
+ ### Pattern 2: Research → Analyze → Recommend
117
+
118
+ **Use case:** Decision support
119
+
120
+ ```
121
+ Step 1: Research/gather information
122
+ Tools: Web search, database queries
123
+ Output: Relevant information
124
+
125
+ Step 2: Analyze information
126
+ Method: Compare, evaluate, synthesize
127
+ Output: Analysis with pros/cons
128
+
129
+ Step 3: Generate recommendations
130
+ Input: Analysis
131
+ Output: Actionable recommendations
132
+ ```
133
+
134
+ **Example:**
135
+ ```
136
+ 1. Search for competitor features → Feature list
137
+ 2. Compare with our product → Gap analysis
138
+ 3. Recommend prioritized roadmap → Action plan
139
+ ```
140
+
141
+ ---
142
+
143
+ ### Pattern 3: Generate → Validate → Refine
144
+
145
+ **Use case:** Content creation with quality control
146
+
147
+ ```
148
+ Step 1: Generate initial content
149
+ Temperature: 0.8 (creative)
150
+ Output: Draft content
151
+
152
+ Step 2: Validate content
153
+ Temperature: 0.2 (analytical)
154
+ Check: Accuracy, tone, completeness
155
+ Output: Validation report
156
+
157
+ Step 3: Refine based on validation
158
+ Temperature: 0.5 (balanced)
159
+ Input: Draft + validation
160
+ Output: Final polished content
161
+ ```
162
+
163
+ **Example:**
164
+ ```
165
+ 1. Generate blog post → Draft
166
+ 2. Check facts and tone → Issues list
167
+ 3. Revise and polish → Final post
168
+ ```
169
+
170
+ ---
171
+
172
+ ### Pattern 4: Decompose → Solve → Combine
173
+
174
+ **Use case:** Complex problem solving
175
+
176
+ ```
177
+ Step 1: Decompose problem
178
+ Break into sub-problems
179
+ Output: List of sub-problems
180
+
181
+ Step 2: Solve each sub-problem
182
+ Parallel or sequential
183
+ Output: Solutions for each
184
+
185
+ Step 3: Combine solutions
186
+ Integrate and synthesize
187
+ Output: Complete solution
188
+ ```
189
+
190
+ **Example:**
191
+ ```
192
+ 1. Break system design into components → Component list
193
+ 2. Design each component → Component designs
194
+ 3. Integrate into full architecture → System design
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Advanced: Conditional Chaining
200
+
201
+ **Branching based on intermediate results:**
202
+
203
+ ```yaml
204
+ chain:
205
+ - step: 1
206
+ name: "Classify Query"
207
+ prompt: "Classify this user query: {query}"
208
+ output_to: "classification"
209
+
210
+ - step: 2
211
+ condition: "{classification} == 'technical'"
212
+ name: "Technical Response"
213
+ prompt: "Provide technical answer for: {query}"
214
+ output_to: "response"
215
+
216
+ - step: 2_alt
217
+ condition: "{classification} == 'general'"
218
+ name: "General Response"
219
+ prompt: "Provide general answer for: {query}"
220
+ output_to: "response"
221
+
222
+ - step: 3
223
+ name: "Quality Check"
224
+ prompt: "Review this response: {response}"
225
+ output_to: "final_response"
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Advanced: Loop/Iteration
231
+
232
+ **Repeat steps until condition met:**
233
+
234
+ ```yaml
235
+ chain:
236
+ - step: 1
237
+ name: "Generate Code"
238
+ prompt: "Write function for: {requirement}"
239
+ output_to: "code"
240
+
241
+ - step: 2
242
+ name: "Test Code"
243
+ prompt: "Test this code with: {test_cases}"
244
+ output_to: "test_results"
245
+
246
+ - step: 3
247
+ name: "Check If Passed"
248
+ condition: "{test_results} != 'all passed'"
249
+ action: "loop_to_step_1"
250
+ max_iterations: 3
251
+
252
+ - step: 4
253
+ name: "Return Final Code"
254
+ output: "{code}"
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Benefits of Chaining
260
+
261
+ ### 1. Focused Prompts
262
+ Each prompt handles one clear task:
263
+ ```
264
+ ❌ Single complex prompt (1000 tokens, confusing)
265
+ ✅ 3 focused prompts (300 tokens each, clear)
266
+ ```
267
+
268
+ ### 2. Different Models per Step
269
+ Optimize cost/quality:
270
+ ```
271
+ Step 1 (Extract): GPT-3.5 (cheap, fast)
272
+ Step 2 (Analyze): GPT-4 (quality needed)
273
+ Step 3 (Format): GPT-3.5 (simple formatting)
274
+ ```
275
+
276
+ ### 3. Intermediate Validation
277
+ Catch errors early:
278
+ ```
279
+ Extract → [Validate extraction] → Analyze → [Validate analysis] → Generate
280
+ ```
281
+
282
+ ### 4. Easier Debugging
283
+ Identify which step failed:
284
+ ```
285
+ Step 1: ✓ Success
286
+ Step 2: ✗ Failed (fix this specific step)
287
+ Step 3: Not reached
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Implementation Patterns
293
+
294
+ ### Pattern A: Manual Chaining (Simple)
295
+
296
+ ```python
297
+ # Step 1
298
+ prompt_1 = f"Extract data from: {document}"
299
+ output_1 = llm.generate(prompt_1)
300
+
301
+ # Step 2
302
+ prompt_2 = f"Analyze this data: {output_1}"
303
+ output_2 = llm.generate(prompt_2)
304
+
305
+ # Step 3
306
+ prompt_3 = f"Summarize: {output_2}"
307
+ final_output = llm.generate(prompt_3)
308
+ ```
309
+
310
+ ### Pattern B: Pipeline Function
311
+
312
+ ```python
313
+ def chain_prompts(steps, input_data):
314
+ context = {"input": input_data}
315
+
316
+ for step in steps:
317
+ prompt = step["prompt"].format(**context)
318
+ output = llm.generate(prompt,
319
+ model=step.get("model"),
320
+ temperature=step.get("temperature"))
321
+ context[step["output_to"]] = output
322
+
323
+ return context["final_output"]
324
+ ```
325
+
326
+ ### Pattern C: LangChain (Framework)
327
+
328
+ ```python
329
+ from langchain import PromptTemplate, LLMChain
330
+
331
+ # Define chain
332
+ chain = (
333
+ LLMChain(prompt=extract_prompt)
334
+ | LLMChain(prompt=analyze_prompt)
335
+ | LLMChain(prompt=summarize_prompt)
336
+ )
337
+
338
+ # Execute
339
+ result = chain.run(document=doc)
340
+ ```
341
+
342
+ ---
343
+
344
+ ## Error Handling in Chains
345
+
346
+ ### Strategy 1: Retry Failed Step
347
+
348
+ ```python
349
+ def execute_step(step, context, max_retries=3):
350
+ for attempt in range(max_retries):
351
+ try:
352
+ output = llm.generate(step["prompt"].format(**context))
353
+ return output
354
+ except Exception as e:
355
+ if attempt == max_retries - 1:
356
+ raise
357
+ time.sleep(2 ** attempt) # Exponential backoff
358
+ ```
359
+
360
+ ### Strategy 2: Fallback to Alternative
361
+
362
+ ```python
363
+ def execute_with_fallback(primary_step, fallback_step, context):
364
+ try:
365
+ return execute_step(primary_step, context)
366
+ except:
367
+ return execute_step(fallback_step, context)
368
+ ```
369
+
370
+ ### Strategy 3: Skip Optional Steps
371
+
372
+ ```python
373
+ for step in chain:
374
+ if step.get("optional") and previous_failed:
375
+ continue # Skip optional steps after failure
376
+ execute_step(step, context)
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Cost Optimization
382
+
383
+ ### Use Cheaper Models for Simple Steps
384
+
385
+ ```yaml
386
+ # Expensive: All steps use GPT-4
387
+ total_cost: $0.15
388
+
389
+ # Optimized: GPT-3.5 where possible
390
+ step_1: gpt-3.5-turbo # Extract (simple)
391
+ step_2: gpt-4 # Analyze (complex)
392
+ step_3: gpt-3.5-turbo # Format (simple)
393
+ total_cost: $0.08 # 47% savings
394
+ ```
395
+
396
+ ### Cache Intermediate Results
397
+
398
+ ```python
399
+ cache = {}
400
+
401
+ def execute_with_cache(step, context):
402
+ cache_key = hash(step["prompt"].format(**context))
403
+
404
+ if cache_key in cache:
405
+ return cache[cache_key]
406
+
407
+ output = llm.generate(...)
408
+ cache[cache_key] = output
409
+ return output
410
+ ```
411
+
412
+ ---
413
+
414
+ ## Real-World Example: Customer Support Chain
415
+
416
+ ```yaml
417
+ customer_support_chain:
418
+ - step: 1
419
+ name: "Classify Intent"
420
+ model: "gpt-3.5-turbo"
421
+ temperature: 0.2
422
+ prompt: |
423
+ Classify customer message intent:
424
+ {customer_message}
425
+
426
+ Categories: technical_issue, billing, feature_request, general
427
+ output_to: "intent"
428
+
429
+ - step: 2
430
+ name: "Extract Key Info"
431
+ model: "gpt-3.5-turbo"
432
+ temperature: 0.3
433
+ prompt: |
434
+ Extract from message:
435
+ {customer_message}
436
+
437
+ Extract: account_id, product, issue_description
438
+ output_to: "extracted_info"
439
+
440
+ - step: 3
441
+ name: "Search Knowledge Base"
442
+ action: "tool_call"
443
+ tool: "vector_search"
444
+ query: "{extracted_info.issue_description}"
445
+ output_to: "relevant_articles"
446
+
447
+ - step: 4
448
+ name: "Generate Response"
449
+ model: "claude-3-sonnet"
450
+ temperature: 0.7
451
+ prompt: |
452
+ Generate customer support response:
453
+
454
+ Intent: {intent}
455
+ Customer info: {extracted_info}
456
+ Relevant help: {relevant_articles}
457
+
458
+ Tone: Empathetic and professional
459
+ Length: 100-150 words
460
+ output_to: "draft_response"
461
+
462
+ - step: 5
463
+ name: "Quality Check"
464
+ model: "claude-3-opus"
465
+ temperature: 0.2
466
+ prompt: |
467
+ Review this support response:
468
+ {draft_response}
469
+
470
+ Check:
471
+ - Addresses customer issue
472
+ - Professional tone
473
+ - Includes next steps
474
+
475
+ If issues: suggest improvements
476
+ If good: approve with "APPROVED"
477
+ output_to: "final_response"
478
+ ```
479
+
480
+ ---
481
+
482
+ ## Quick Reference
483
+
484
+ | Aspect | Recommendation |
485
+ |--------|---------------|
486
+ | **Chain length** | 2-5 steps (optimal) |
487
+ | **Step complexity** | Each step = 1 clear task |
488
+ | **Model selection** | Match model to step complexity |
489
+ | **Error handling** | Retry + fallback strategies |
490
+ | **Cost optimization** | Use cheaper models where possible |
491
+ | **Best for** | Complex multi-step workflows |
492
+
493
+ ---
494
+
495
+ **Related:**
496
+ - [ReAct](react.md) - Tool use within prompts
497
+ - [Advanced Combinations](advanced-combinations.md) - Combining techniques
498
+ - [Decision Matrix](decision_matrix.md) - When to use chaining
@@ -0,0 +1,108 @@
1
+ # ReAct (Reasoning + Acting) Prompting
2
+
3
+ ## Overview
4
+
5
+ ReAct interleaves reasoning traces with action execution, allowing LLMs to combine internal reasoning with external tool use and information retrieval.
6
+
7
+ ## Structure
8
+
9
+ ```
10
+ Thought → Action → Observation → Thought → Action → ... → Answer
11
+ ```
12
+
13
+ ## When to Use
14
+
15
+ ✅ **Use ReAct When:**
16
+ - Task requires external tool/API use
17
+ - Need to retrieve information dynamically
18
+ - Multi-step tasks with actions between reasoning
19
+ - Combining LLM reasoning with external systems
20
+
21
+ ❌ **Don't Use ReAct When:**
22
+ - No external tools needed
23
+ - Pure reasoning task (use CoT instead)
24
+ - Simple lookup (use direct API call)
25
+
26
+ ## Template
27
+
28
+ ```
29
+ Available Actions:
30
+ - SEARCH[query]: Search for information
31
+ - LOOKUP[term]: Find specific term in context
32
+ - CALCULATE[expression]: Perform calculation
33
+ - FINISH[answer]: Provide final answer
34
+
35
+ Task: [Your task]
36
+
37
+ Thought 1: [Initial reasoning about what to do]
38
+ Action 1: [Specific action to take]
39
+ Observation 1: [Result of action - filled after executing]
40
+
41
+ Thought 2: [Reasoning based on observation]
42
+ Action 2: [Next action]
43
+ Observation 2: [Result]
44
+ ...
45
+ Thought N: [Final reasoning]
46
+ Action N: FINISH[final answer]
47
+ ```
48
+
49
+ ## JSON Format (for tool calling)
50
+
51
+ ```json
52
+ {
53
+ "task": "[Task description]",
54
+ "available_actions": ["SEARCH", "CALCULATE", "FINISH"],
55
+ "trace": [
56
+ {
57
+ "step": 1,
58
+ "thought": "[What I need to do]",
59
+ "action": "SEARCH[query]",
60
+ "observation": "[Search result]"
61
+ },
62
+ {
63
+ "step": 2,
64
+ "thought": "[Next reasoning]",
65
+ "action": "CALCULATE[expression]",
66
+ "observation": "[Calculation result]"
67
+ }
68
+ ]
69
+ }
70
+ ```
71
+
72
+ ## Example
73
+
74
+ ```
75
+ Task: What is the population of the capital of the country with largest GDP?
76
+
77
+ Thought 1: I need to find which country has the largest GDP
78
+ Action 1: SEARCH[country with largest GDP 2025]
79
+ Observation 1: United States has the largest GDP
80
+
81
+ Thought 2: Now I need the capital of United States
82
+ Action 2: SEARCH[capital of United States]
83
+ Observation 2: Washington, D.C.
84
+
85
+ Thought 3: Now I need the population of Washington, D.C.
86
+ Action 3: SEARCH[Washington DC population 2025]
87
+ Observation 3: Approximately 750,000
88
+
89
+ Thought 4: I have all information needed
90
+ Action 4: FINISH[Population of Washington, D.C. is approximately 750,000]
91
+ ```
92
+
93
+ ## Best Practices
94
+
95
+ ✓ Define available actions upfront
96
+ ✓ Separate Thought/Action/Observation clearly
97
+ ✓ Specify action formats precisely
98
+ ✓ Include FINISH action as stopping criteria
99
+
100
+ ✗ Don't mix reasoning and actions
101
+ ✗ Avoid undefined/ambiguous actions
102
+ ✗ Don't continue after FINISH
103
+
104
+ ---
105
+
106
+ **Related:**
107
+ - [Chain of Thought](chain-of-thought.md) - Pure reasoning without tools
108
+ - [JSON Format](json-format.md) - Best format for tool calling