@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,493 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Token cost estimation tool for Claude skills.
4
+ Predicts token consumption and monthly costs using progressive disclosure analysis.
5
+
6
+ Usage:
7
+ python token_estimator.py <skill_path> [--volume N] [--model MODEL] [--format FORMAT]
8
+
9
+ References:
10
+ - File 05: Token economics and optimization strategies
11
+ - File 10: Progressive disclosure architecture (3-level model)
12
+ - File 15: Cost optimization techniques
13
+ """
14
+
15
+ import sys
16
+ import json
17
+ from pathlib import Path
18
+ from typing import Dict, List
19
+ from dataclasses import dataclass
20
+
21
+ # Import shared utilities for standardized output
22
+ try:
23
+ from utils.output_formatter import add_format_argument, format_success_response, format_error_response, output_json
24
+ except ImportError:
25
+ # Fallback if utils not in path
26
+ sys.path.insert(0, str(Path(__file__).parent))
27
+ from utils.output_formatter import add_format_argument, format_success_response, format_error_response, output_json
28
+
29
+
30
+ @dataclass
31
+ class CostBreakdown:
32
+ """Token and cost breakdown for a usage scenario."""
33
+ scenario: str
34
+ tokens: int
35
+ cost_per_use: float
36
+ monthly_cost: float
37
+
38
+
39
+ class TokenEstimator:
40
+ """Token cost estimation and progressive disclosure analysis."""
41
+
42
+ # Pricing per million tokens (November 2024)
43
+ PRICING = {
44
+ 'claude-sonnet-4.5': {
45
+ 'input': 3.00,
46
+ 'output': 15.00
47
+ },
48
+ 'claude-opus-4': {
49
+ 'input': 15.00,
50
+ 'output': 75.00
51
+ }
52
+ }
53
+
54
+ def __init__(self, skill_path: str, model: str = 'claude-sonnet-4.5', output_format: str = 'text'):
55
+ """Initialize estimator with skill path, pricing model, and output format."""
56
+ self.skill_path = Path(skill_path)
57
+ self.model = model
58
+ self.output_format = output_format
59
+ self.pricing = self.PRICING.get(model, self.PRICING['claude-sonnet-4.5'])
60
+
61
+ if not self.skill_path.exists():
62
+ raise FileNotFoundError(f"Skill path not found: {skill_path}")
63
+
64
+ # ========== TOKEN COUNTING ==========
65
+
66
+ def count_tokens(self, text: str) -> int:
67
+ """
68
+ Estimate token count using averaged method.
69
+
70
+ Combines two approaches:
71
+ 1. Word count * 1.3 (conservative estimate)
72
+ 2. Character count / 4 (average estimate)
73
+
74
+ Returns average of both methods for accuracy.
75
+ Reference: File 05 (token estimation methodology)
76
+ """
77
+ words = len(text.split())
78
+ chars = len(text)
79
+
80
+ token_by_words = int(words * 1.3)
81
+ token_by_chars = int(chars / 4)
82
+
83
+ return int((token_by_words + token_by_chars) / 2)
84
+
85
+ def _extract_frontmatter(self, content: str) -> str:
86
+ """Extract YAML frontmatter from markdown."""
87
+ if content.startswith('---'):
88
+ parts = content.split('---', 2)
89
+ if len(parts) >= 3:
90
+ return f"---{parts[1]}---"
91
+ return ""
92
+
93
+ def _extract_body(self, content: str) -> str:
94
+ """Extract body content (excluding frontmatter)."""
95
+ if content.startswith('---'):
96
+ parts = content.split('---', 2)
97
+ if len(parts) >= 3:
98
+ return parts[2].strip()
99
+ return content
100
+
101
+ # ========== PROGRESSIVE DISCLOSURE ANALYSIS ==========
102
+
103
+ def analyze_progressive_disclosure(self) -> Dict:
104
+ """
105
+ Analyze skill using 3-level progressive disclosure model.
106
+
107
+ Levels:
108
+ - Level 1: Metadata (always loaded)
109
+ - Level 2: SKILL.md body (loaded when triggered)
110
+ - Level 3: References (loaded on-demand)
111
+
112
+ Returns:
113
+ Dict with token counts per level
114
+
115
+ Reference: File 10 (progressive disclosure architecture)
116
+ """
117
+ breakdown = {
118
+ 'level_1_metadata': 0,
119
+ 'level_2_skill_body': 0,
120
+ 'level_3_references': {},
121
+ 'scripts': []
122
+ }
123
+
124
+ # Level 1: Metadata (YAML frontmatter)
125
+ skill_md = self.skill_path / 'SKILL.md'
126
+ if skill_md.exists():
127
+ content = skill_md.read_text(encoding='utf-8')
128
+ frontmatter = self._extract_frontmatter(content)
129
+ breakdown['level_1_metadata'] = self.count_tokens(frontmatter)
130
+
131
+ # Level 2: Body content
132
+ body = self._extract_body(content)
133
+ breakdown['level_2_skill_body'] = self.count_tokens(body)
134
+
135
+ # Level 3: Reference files
136
+ refs_dir = self.skill_path / 'references'
137
+ if refs_dir.exists():
138
+ for ref_file in refs_dir.glob('*.md'):
139
+ content = ref_file.read_text(encoding='utf-8')
140
+ tokens = self.count_tokens(content)
141
+ breakdown['level_3_references'][ref_file.name] = tokens
142
+
143
+ # Scripts (output only, conservative 200 tokens estimate)
144
+ scripts_dir = self.skill_path / 'scripts'
145
+ if scripts_dir.exists():
146
+ for script in scripts_dir.glob('*.py'):
147
+ breakdown['scripts'].append({
148
+ 'name': script.name,
149
+ 'estimated_output': 200
150
+ })
151
+
152
+ return breakdown
153
+
154
+ # ========== USAGE SCENARIOS ==========
155
+
156
+ def estimate_usage_scenarios(self, breakdown: Dict) -> Dict[str, int]:
157
+ """
158
+ Calculate token usage for different scenarios.
159
+
160
+ Scenarios:
161
+ - idle: Only metadata (skill in context but not triggered)
162
+ - typical: Metadata + SKILL.md body (normal skill use)
163
+ - with_reference: + smallest reference file (common case)
164
+ - worst_case: All content loaded (rare but possible)
165
+
166
+ Reference: File 15 (cost scenarios)
167
+ """
168
+ scenarios = {}
169
+
170
+ # Idle: Just metadata
171
+ scenarios['idle'] = breakdown['level_1_metadata']
172
+
173
+ # Typical: Metadata + body
174
+ scenarios['typical'] = (
175
+ breakdown['level_1_metadata'] +
176
+ breakdown['level_2_skill_body']
177
+ )
178
+
179
+ # With reference: + most common (smallest) reference
180
+ if breakdown['level_3_references']:
181
+ smallest_ref = min(breakdown['level_3_references'].values())
182
+ scenarios['with_reference'] = scenarios['typical'] + smallest_ref
183
+ else:
184
+ scenarios['with_reference'] = scenarios['typical']
185
+
186
+ # Worst-case: Everything
187
+ total_refs = sum(breakdown['level_3_references'].values())
188
+ scenarios['worst_case'] = (
189
+ breakdown['level_1_metadata'] +
190
+ breakdown['level_2_skill_body'] +
191
+ total_refs
192
+ )
193
+
194
+ return scenarios
195
+
196
+ def estimate_behavioral_testing_cost(self, skill_type: str) -> Dict:
197
+ """
198
+ Estimate token cost for behavioral testing in full mode.
199
+
200
+ Costs:
201
+ - Per pressure test: ~2000 tokens
202
+ - Combined test: ~3000 tokens
203
+ - Total overhead: ~11,000 tokens
204
+ """
205
+ per_test = 2000
206
+ combined_test = 3000
207
+ num_tests = 4 # time, sunk_cost, authority, exhaustion
208
+ total = (per_test * num_tests) + combined_test
209
+
210
+ return {
211
+ "skill_type": skill_type,
212
+ "fast_mode_tokens": 0,
213
+ "full_mode_tokens": total,
214
+ "overhead": total,
215
+ "breakdown": {
216
+ "individual_tests": per_test * num_tests,
217
+ "combined_test": combined_test
218
+ },
219
+ "note": "Behavioral testing adds ~11k tokens but prevents skill failures"
220
+ }
221
+
222
+ def get_mode_recommendation(self, structural_tokens: int) -> str:
223
+ """Recommend workflow mode based on structural token budget."""
224
+ behavioral_cost = 11000
225
+
226
+ if structural_tokens < 2000:
227
+ return f"fast mode recommended (skill is small, {structural_tokens} tokens)"
228
+ if structural_tokens > 5000:
229
+ return (
230
+ "full mode recommended "
231
+ f"(skill is large, behavioral testing justifies +{behavioral_cost} tokens)"
232
+ )
233
+ return (
234
+ "either mode "
235
+ f"(structural: {structural_tokens}, behavioral overhead: {behavioral_cost})"
236
+ )
237
+
238
+ # ========== COST CALCULATION ==========
239
+
240
+ def calculate_costs(
241
+ self,
242
+ scenarios: Dict[str, int],
243
+ monthly_volume: int,
244
+ avg_output_tokens: int = 500
245
+ ) -> Dict[str, CostBreakdown]:
246
+ """
247
+ Calculate monthly cost projections for each scenario.
248
+
249
+ Args:
250
+ scenarios: Token counts per scenario
251
+ monthly_volume: Projected monthly usage
252
+ avg_output_tokens: Average response length
253
+
254
+ Reference: File 05 (token economics)
255
+ """
256
+ costs = {}
257
+
258
+ for scenario_name, input_tokens in scenarios.items():
259
+ # Input cost
260
+ input_cost = (input_tokens / 1_000_000) * self.pricing['input']
261
+
262
+ # Output cost (estimated response)
263
+ output_cost = (avg_output_tokens / 1_000_000) * self.pricing['output']
264
+
265
+ # Per-use and monthly
266
+ cost_per_use = input_cost + output_cost
267
+ monthly_cost = cost_per_use * monthly_volume
268
+
269
+ costs[scenario_name] = CostBreakdown(
270
+ scenario=scenario_name,
271
+ tokens=input_tokens,
272
+ cost_per_use=cost_per_use,
273
+ monthly_cost=monthly_cost
274
+ )
275
+
276
+ return costs
277
+
278
+ # ========== RECOMMENDATIONS ==========
279
+
280
+ def generate_recommendations(
281
+ self,
282
+ breakdown: Dict,
283
+ scenarios: Dict[str, int]
284
+ ) -> List[str]:
285
+ """
286
+ Generate optimization recommendations.
287
+
288
+ Analyzes token distribution and suggests improvements.
289
+ Reference: File 15 (optimization strategies)
290
+ """
291
+ recs = []
292
+
293
+ total_refs = sum(breakdown['level_3_references'].values())
294
+
295
+ # Check if references dominate
296
+ if total_refs > breakdown['level_2_skill_body'] * 2:
297
+ recs.append(f"⚠️ References ({total_refs} tokens) >> SKILL.md. Consider splitting further.")
298
+
299
+ # Check for large individual references
300
+ for ref_name, tokens in breakdown['level_3_references'].items():
301
+ if tokens > 1000:
302
+ recs.append(f"⚠️ {ref_name} is large ({tokens} tokens). Consider splitting.")
303
+
304
+ # Efficiency praise
305
+ typical = scenarios.get('typical', 0)
306
+ if typical < 500 and not recs:
307
+ recs.append(f"✅ Excellent efficiency ({typical} tokens typical). Well-optimized!")
308
+
309
+ if not recs:
310
+ recs.append("✅ Token efficiency looks good. No optimization needed.")
311
+
312
+ return recs
313
+
314
+ # ========== OUTPUT METHODS ==========
315
+
316
+ def _output_json(self, breakdown: Dict, scenarios: Dict, costs: Dict, recommendations: List, monthly_volume: int) -> str:
317
+ """Generate JSON output for agent-layer."""
318
+ # Convert CostBreakdown objects to dicts
319
+ costs_dict = {}
320
+ for scenario, cost_obj in costs.items():
321
+ costs_dict[scenario] = {
322
+ 'tokens': cost_obj.tokens,
323
+ 'cost_per_use': round(cost_obj.cost_per_use, 6),
324
+ 'monthly_cost': round(cost_obj.monthly_cost, 2)
325
+ }
326
+
327
+ output = {
328
+ 'status': 'success',
329
+ 'skill_name': self.skill_path.name,
330
+ 'model': self.model,
331
+ 'token_breakdown': {
332
+ 'level_1_metadata': breakdown['level_1_metadata'],
333
+ 'level_2_skill_body': breakdown['level_2_skill_body'],
334
+ 'level_3_references': breakdown['level_3_references'],
335
+ 'total_references_tokens': sum(breakdown['level_3_references'].values()),
336
+ 'scripts': breakdown.get('scripts', [])
337
+ },
338
+ 'usage_scenarios': scenarios,
339
+ 'cost_analysis': {
340
+ 'pricing': {
341
+ 'input': self.pricing['input'],
342
+ 'output': self.pricing['output'],
343
+ 'unit': 'per_million_tokens'
344
+ },
345
+ 'scenarios': costs_dict,
346
+ 'monthly_volume': monthly_volume
347
+ },
348
+ 'recommendations': recommendations
349
+ }
350
+
351
+ return json.dumps(output, indent=2)
352
+
353
+ def _output_text(self, breakdown: Dict, scenarios: Dict, costs: Dict, recommendations: List, monthly_volume: int) -> str:
354
+ """Generate text output for human reading."""
355
+ lines = []
356
+ lines.append(f"\n{'='*60}")
357
+ lines.append(f"Token Cost Estimation: {self.skill_path.name}")
358
+ lines.append('='*60 + '\n')
359
+
360
+ # Progressive disclosure breakdown
361
+ lines.append("Progressive Disclosure Breakdown:")
362
+ lines.append(f"├─ Level 1 (Metadata): {breakdown['level_1_metadata']} tokens")
363
+ lines.append(f"├─ Level 2 (SKILL.md): {breakdown['level_2_skill_body']} tokens")
364
+
365
+ if breakdown['level_3_references']:
366
+ total_refs = sum(breakdown['level_3_references'].values())
367
+ lines.append(f"└─ Level 3 (References): {total_refs} tokens total")
368
+ for ref_name, tokens in breakdown['level_3_references'].items():
369
+ lines.append(f" ├─ {ref_name}: {tokens} tokens")
370
+ else:
371
+ lines.append(f"└─ Level 3: No references")
372
+
373
+ lines.append("")
374
+
375
+ # Usage scenarios
376
+ lines.append("Usage Scenarios:")
377
+ lines.append("┌─────────────────────┬─────────┬──────────┐")
378
+ lines.append("│ Scenario │ Tokens │ Frequency│")
379
+ lines.append("├─────────────────────┼─────────┼──────────┤")
380
+
381
+ frequency_map = {
382
+ 'idle': 'Always',
383
+ 'typical': 'Common',
384
+ 'with_reference': 'Sometimes',
385
+ 'worst_case': 'Rare'
386
+ }
387
+
388
+ for scenario, tokens in scenarios.items():
389
+ freq = frequency_map.get(scenario, 'Unknown')
390
+ lines.append(f"│ {scenario:19} │ {tokens:7} │ {freq:8} │")
391
+
392
+ lines.append("└─────────────────────┴─────────┴──────────┘")
393
+ lines.append("")
394
+
395
+ # Cost projections
396
+ lines.append(f"Cost Projection ({self.model}):")
397
+ lines.append(f"├─ Input: ${self.pricing['input']:.2f}/M tokens")
398
+ lines.append(f"├─ Output: ${self.pricing['output']:.2f}/M tokens")
399
+ lines.append(f"│")
400
+ lines.append(f"├─ Per-Use Costs:")
401
+ lines.append(f"│ ├─ Idle: ${costs['idle'].cost_per_use:.4f} per use")
402
+ lines.append(f"│ ├─ Typical: ${costs['typical'].cost_per_use:.4f} per use")
403
+ lines.append(f"│ ├─ With reference: ${costs['with_reference'].cost_per_use:.4f} per use")
404
+ lines.append(f"│ └─ Worst-case: ${costs['worst_case'].cost_per_use:.4f} per use")
405
+ lines.append(f"│")
406
+ lines.append(f"└─ Monthly Projection ({monthly_volume:,} uses/month):")
407
+
408
+ typical_cost = costs['typical'].monthly_cost
409
+ worst_cost = costs['worst_case'].monthly_cost
410
+
411
+ lines.append(f" ├─ Typical: ${typical_cost:.2f}/month")
412
+ lines.append(f" └─ Worst-case: ${worst_cost:.2f}/month")
413
+ lines.append("")
414
+
415
+ # Recommendations
416
+ lines.append("Recommendations:")
417
+ for rec in recommendations:
418
+ lines.append(f" {rec}")
419
+
420
+ lines.append("")
421
+
422
+ return '\n'.join(lines)
423
+
424
+ # ========== REPORT GENERATION ==========
425
+
426
+ def generate_report(self, monthly_volume: int = 1000) -> str:
427
+ """Generate comprehensive cost estimation report."""
428
+ # Gather data
429
+ breakdown = self.analyze_progressive_disclosure()
430
+ scenarios = self.estimate_usage_scenarios(breakdown)
431
+ costs = self.calculate_costs(scenarios, monthly_volume)
432
+ recommendations = self.generate_recommendations(breakdown, scenarios)
433
+
434
+ # Output based on format
435
+ if self.output_format == 'json':
436
+ return self._output_json(breakdown, scenarios, costs, recommendations, monthly_volume)
437
+ else:
438
+ return self._output_text(breakdown, scenarios, costs, recommendations, monthly_volume)
439
+
440
+
441
+ def main():
442
+ """CLI entry point."""
443
+ import argparse
444
+
445
+ parser = argparse.ArgumentParser(
446
+ description='Estimate token costs for Claude skills',
447
+ epilog='References: Files 05, 10, 15 for cost optimization'
448
+ )
449
+ parser.add_argument('skill_path', help='Path to skill directory')
450
+ parser.add_argument('--volume', type=int, default=1000,
451
+ help='Monthly usage volume (default: 1000)')
452
+ parser.add_argument('--model', default='claude-sonnet-4.5',
453
+ choices=['claude-sonnet-4.5', 'claude-opus-4'],
454
+ help='Pricing model (default: claude-sonnet-4.5)')
455
+ add_format_argument(parser) # Standardized --format argument
456
+
457
+ args = parser.parse_args()
458
+
459
+ try:
460
+ estimator = TokenEstimator(args.skill_path, model=args.model, output_format=args.format)
461
+ report = estimator.generate_report(monthly_volume=args.volume)
462
+ print(report)
463
+ sys.exit(0)
464
+
465
+ except FileNotFoundError as e:
466
+ if args.format == 'json':
467
+ response = format_error_response(
468
+ error_type='FileNotFoundError',
469
+ message=str(e),
470
+ tool_name='token_estimator',
471
+ help_text='Ensure skill directory exists and contains SKILL.md'
472
+ )
473
+ output_json(response)
474
+ else:
475
+ print(f"Error: {e}", file=sys.stderr)
476
+ sys.exit(1)
477
+
478
+ except Exception as e:
479
+ if args.format == 'json':
480
+ response = format_error_response(
481
+ error_type=type(e).__name__,
482
+ message=str(e),
483
+ tool_name='token_estimator',
484
+ help_text='Check skill structure and permissions'
485
+ )
486
+ output_json(response)
487
+ else:
488
+ print(f"Error: {e}", file=sys.stderr)
489
+ sys.exit(2)
490
+
491
+
492
+ if __name__ == '__main__':
493
+ main()
@@ -0,0 +1,49 @@
1
+ """
2
+ Shared utilities for skillkit automation scripts.
3
+
4
+ Modules:
5
+ - output_formatter: Standardized JSON/text output (v1.0)
6
+ - budget_tracker: File content budget enforcement (v1.2)
7
+ - reference_validator: Cross-reference validation (v1.2)
8
+ """
9
+
10
+ from .output_formatter import (
11
+ add_format_argument,
12
+ output_json,
13
+ output_error,
14
+ format_success_response,
15
+ format_error_response
16
+ )
17
+
18
+ from .budget_tracker import (
19
+ FileContentBudget,
20
+ BudgetExceeded,
21
+ TokenCounter,
22
+ create_budget,
23
+ STANDARD_BUDGETS
24
+ )
25
+
26
+ from .reference_validator import (
27
+ CrossReferenceValidator,
28
+ SkillPackageValidator,
29
+ ValidationResult
30
+ )
31
+
32
+ __all__ = [
33
+ # Output formatting (v1.0)
34
+ 'add_format_argument',
35
+ 'output_json',
36
+ 'output_error',
37
+ 'format_success_response',
38
+ 'format_error_response',
39
+ # Budget tracking (v1.2)
40
+ 'FileContentBudget',
41
+ 'BudgetExceeded',
42
+ 'TokenCounter',
43
+ 'create_budget',
44
+ 'STANDARD_BUDGETS',
45
+ # Reference validation (v1.2)
46
+ 'CrossReferenceValidator',
47
+ 'SkillPackageValidator',
48
+ 'ValidationResult'
49
+ ]