@heytherevibin/skillforge 0.2.1
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.
- package/CHANGELOG.md +16 -0
- package/CODE_OF_CONDUCT.md +34 -0
- package/CONTRIBUTING.md +38 -0
- package/LICENSE +21 -0
- package/README.md +337 -0
- package/RELEASING.md +93 -0
- package/SECURITY.md +31 -0
- package/STRATEGY.md +26 -0
- package/bin/cli.js +547 -0
- package/lib/packs.js +184 -0
- package/package.json +38 -0
- package/python/app/__init__.py +0 -0
- package/python/app/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/app/__pycache__/auth.cpython-312.pyc +0 -0
- package/python/app/__pycache__/main.cpython-312.pyc +0 -0
- package/python/app/auth.py +63 -0
- package/python/app/cli.py +78 -0
- package/python/app/db_paths.py +26 -0
- package/python/app/events_cli.py +175 -0
- package/python/app/main.py +647 -0
- package/python/app/materialize.py +138 -0
- package/python/app/mcp_server.py +610 -0
- package/python/app/route_cli.py +117 -0
- package/python/requirements-dev.txt +1 -0
- package/python/requirements.txt +7 -0
- package/python/tests/test_db_paths.py +41 -0
- package/skills/accessibility/SKILL.md +145 -0
- package/skills/agent-architecture-audit/SKILL.md +256 -0
- package/skills/agent-eval/SKILL.md +144 -0
- package/skills/agent-harness-construction/SKILL.md +72 -0
- package/skills/agent-introspection-debugging/SKILL.md +152 -0
- package/skills/agent-payment-x402/SKILL.md +224 -0
- package/skills/agent-sort/SKILL.md +214 -0
- package/skills/agentic-engineering/SKILL.md +62 -0
- package/skills/agentic-os/SKILL.md +386 -0
- package/skills/ai-first-engineering/SKILL.md +50 -0
- package/skills/ai-regression-testing/SKILL.md +384 -0
- package/skills/android-clean-architecture/SKILL.md +338 -0
- package/skills/angular-developer/SKILL.md +153 -0
- package/skills/angular-developer/references/angular-animations.md +160 -0
- package/skills/angular-developer/references/angular-aria.md +410 -0
- package/skills/angular-developer/references/cli.md +86 -0
- package/skills/angular-developer/references/component-harnesses.md +59 -0
- package/skills/angular-developer/references/component-styling.md +91 -0
- package/skills/angular-developer/references/components.md +117 -0
- package/skills/angular-developer/references/creating-services.md +97 -0
- package/skills/angular-developer/references/data-resolvers.md +69 -0
- package/skills/angular-developer/references/define-routes.md +67 -0
- package/skills/angular-developer/references/defining-providers.md +72 -0
- package/skills/angular-developer/references/di-fundamentals.md +120 -0
- package/skills/angular-developer/references/e2e-testing.md +56 -0
- package/skills/angular-developer/references/effects.md +83 -0
- package/skills/angular-developer/references/hierarchical-injectors.md +43 -0
- package/skills/angular-developer/references/host-elements.md +80 -0
- package/skills/angular-developer/references/injection-context.md +63 -0
- package/skills/angular-developer/references/inputs.md +101 -0
- package/skills/angular-developer/references/linked-signal.md +59 -0
- package/skills/angular-developer/references/loading-strategies.md +61 -0
- package/skills/angular-developer/references/mcp.md +108 -0
- package/skills/angular-developer/references/navigate-to-routes.md +69 -0
- package/skills/angular-developer/references/outputs.md +86 -0
- package/skills/angular-developer/references/reactive-forms.md +122 -0
- package/skills/angular-developer/references/rendering-strategies.md +44 -0
- package/skills/angular-developer/references/resource.md +77 -0
- package/skills/angular-developer/references/route-animations.md +56 -0
- package/skills/angular-developer/references/route-guards.md +52 -0
- package/skills/angular-developer/references/router-lifecycle.md +45 -0
- package/skills/angular-developer/references/router-testing.md +87 -0
- package/skills/angular-developer/references/show-routes-with-outlets.md +68 -0
- package/skills/angular-developer/references/signal-forms.md +795 -0
- package/skills/angular-developer/references/signals-overview.md +94 -0
- package/skills/angular-developer/references/tailwind-css.md +69 -0
- package/skills/angular-developer/references/template-driven-forms.md +114 -0
- package/skills/angular-developer/references/testing-fundamentals.md +65 -0
- package/skills/api-connector-builder/SKILL.md +120 -0
- package/skills/api-design/SKILL.md +522 -0
- package/skills/architecture-decision-records/SKILL.md +178 -0
- package/skills/article-writing/SKILL.md +78 -0
- package/skills/automation-audit-ops/SKILL.md +141 -0
- package/skills/autonomous-agent-harness/SKILL.md +272 -0
- package/skills/autonomous-loops/SKILL.md +609 -0
- package/skills/backend-patterns/SKILL.md +560 -0
- package/skills/benchmark/SKILL.md +92 -0
- package/skills/blueprint/SKILL.md +104 -0
- package/skills/browser-qa/SKILL.md +86 -0
- package/skills/bun-runtime/SKILL.md +83 -0
- package/skills/canary-watch/SKILL.md +98 -0
- package/skills/carrier-relationship-management/SKILL.md +211 -0
- package/skills/cisco-ios-patterns/SKILL.md +163 -0
- package/skills/ck/SKILL.md +147 -0
- package/skills/ck/commands/forget.mjs +44 -0
- package/skills/ck/commands/info.mjs +24 -0
- package/skills/ck/commands/init.mjs +143 -0
- package/skills/ck/commands/list.mjs +40 -0
- package/skills/ck/commands/migrate.mjs +202 -0
- package/skills/ck/commands/resume.mjs +36 -0
- package/skills/ck/commands/save.mjs +210 -0
- package/skills/ck/commands/shared.mjs +387 -0
- package/skills/ck/hooks/session-start.mjs +224 -0
- package/skills/claude-devfleet/SKILL.md +103 -0
- package/skills/click-path-audit/SKILL.md +244 -0
- package/skills/clickhouse-io/SKILL.md +438 -0
- package/skills/code-tour/SKILL.md +235 -0
- package/skills/codebase-onboarding/SKILL.md +232 -0
- package/skills/coding-standards/SKILL.md +548 -0
- package/skills/compose-multiplatform-patterns/SKILL.md +298 -0
- package/skills/connections-optimizer/SKILL.md +188 -0
- package/skills/content-engine/SKILL.md +126 -0
- package/skills/content-hash-cache-pattern/SKILL.md +160 -0
- package/skills/context-budget/SKILL.md +134 -0
- package/skills/continuous-agent-loop/SKILL.md +44 -0
- package/skills/continuous-learning/SKILL.md +129 -0
- package/skills/continuous-learning/config.json +18 -0
- package/skills/continuous-learning/evaluate-session.sh +69 -0
- package/skills/continuous-learning-v2/SKILL.md +358 -0
- package/skills/continuous-learning-v2/agents/observer-loop.sh +322 -0
- package/skills/continuous-learning-v2/agents/observer.md +198 -0
- package/skills/continuous-learning-v2/agents/session-guardian.sh +150 -0
- package/skills/continuous-learning-v2/agents/start-observer.sh +248 -0
- package/skills/continuous-learning-v2/config.json +8 -0
- package/skills/continuous-learning-v2/hooks/observe.sh +476 -0
- package/skills/continuous-learning-v2/scripts/detect-project.sh +288 -0
- package/skills/continuous-learning-v2/scripts/instinct-cli.py +1519 -0
- package/skills/continuous-learning-v2/scripts/lib/homunculus-dir.sh +31 -0
- package/skills/continuous-learning-v2/scripts/migrate-homunculus.sh +62 -0
- package/skills/continuous-learning-v2/scripts/test_parse_instinct.py +1018 -0
- package/skills/cost-aware-llm-pipeline/SKILL.md +182 -0
- package/skills/cost-tracking/SKILL.md +147 -0
- package/skills/council/SKILL.md +202 -0
- package/skills/cpp-coding-standards/SKILL.md +722 -0
- package/skills/cpp-testing/SKILL.md +323 -0
- package/skills/crosspost/SKILL.md +110 -0
- package/skills/csharp-testing/SKILL.md +320 -0
- package/skills/customer-billing-ops/SKILL.md +139 -0
- package/skills/customs-trade-compliance/SKILL.md +262 -0
- package/skills/dart-flutter-patterns/SKILL.md +562 -0
- package/skills/dashboard-builder/SKILL.md +108 -0
- package/skills/data-scraper-agent/SKILL.md +764 -0
- package/skills/database-migrations/SKILL.md +428 -0
- package/skills/deep-research/SKILL.md +158 -0
- package/skills/defi-amm-security/SKILL.md +166 -0
- package/skills/deployment-patterns/SKILL.md +426 -0
- package/skills/design-system/SKILL.md +81 -0
- package/skills/django-celery/SKILL.md +456 -0
- package/skills/django-patterns/SKILL.md +733 -0
- package/skills/django-security/SKILL.md +592 -0
- package/skills/django-tdd/SKILL.md +728 -0
- package/skills/django-verification/SKILL.md +468 -0
- package/skills/dmux-workflows/SKILL.md +190 -0
- package/skills/docker-patterns/SKILL.md +363 -0
- package/skills/documentation-lookup/SKILL.md +89 -0
- package/skills/dotnet-patterns/SKILL.md +320 -0
- package/skills/e2e-testing/SKILL.md +325 -0
- package/skills/email-ops/SKILL.md +120 -0
- package/skills/energy-procurement/SKILL.md +227 -0
- package/skills/enterprise-agent-ops/SKILL.md +49 -0
- package/skills/error-handling/SKILL.md +375 -0
- package/skills/eval-harness/SKILL.md +269 -0
- package/skills/evm-token-decimals/SKILL.md +130 -0
- package/skills/exa-search/SKILL.md +106 -0
- package/skills/fal-ai-media/SKILL.md +287 -0
- package/skills/fastapi-patterns/SKILL.md +327 -0
- package/skills/finance-billing-ops/SKILL.md +126 -0
- package/skills/flox-environments/SKILL.md +496 -0
- package/skills/flutter-dart-code-review/SKILL.md +434 -0
- package/skills/foundation-models-on-device/SKILL.md +243 -0
- package/skills/frontend-design-direction/SKILL.md +92 -0
- package/skills/frontend-patterns/SKILL.md +641 -0
- package/skills/frontend-slides/SKILL.md +183 -0
- package/skills/frontend-slides/STYLE_PRESETS.md +330 -0
- package/skills/frontend-slides/animation-patterns.md +122 -0
- package/skills/frontend-slides/html-template.md +419 -0
- package/skills/frontend-slides/scripts/export-pdf.sh +418 -0
- package/skills/frontend-slides/scripts/extract-pptx.py +96 -0
- package/skills/frontend-slides/viewport-base.css +153 -0
- package/skills/fsharp-testing/SKILL.md +279 -0
- package/skills/gan-style-harness/SKILL.md +278 -0
- package/skills/gateguard/SKILL.md +125 -0
- package/skills/git-workflow/SKILL.md +714 -0
- package/skills/github-ops/SKILL.md +143 -0
- package/skills/golang-patterns/SKILL.md +673 -0
- package/skills/golang-testing/SKILL.md +719 -0
- package/skills/google-workspace-ops/SKILL.md +94 -0
- package/skills/healthcare-cdss-patterns/SKILL.md +245 -0
- package/skills/healthcare-emr-patterns/SKILL.md +159 -0
- package/skills/healthcare-eval-harness/SKILL.md +207 -0
- package/skills/healthcare-phi-compliance/SKILL.md +145 -0
- package/skills/hermes-imports/SKILL.md +87 -0
- package/skills/hexagonal-architecture/SKILL.md +275 -0
- package/skills/hipaa-compliance/SKILL.md +78 -0
- package/skills/homelab-network-readiness/SKILL.md +169 -0
- package/skills/homelab-network-setup/SKILL.md +129 -0
- package/skills/homelab-pihole-dns/SKILL.md +274 -0
- package/skills/homelab-vlan-segmentation/SKILL.md +311 -0
- package/skills/homelab-wireguard-vpn/SKILL.md +305 -0
- package/skills/hookify-rules/SKILL.md +128 -0
- package/skills/inventory-demand-planning/SKILL.md +246 -0
- package/skills/investor-materials/SKILL.md +95 -0
- package/skills/investor-outreach/SKILL.md +90 -0
- package/skills/ios-icon-gen/SKILL.md +157 -0
- package/skills/ios-icon-gen/scripts/generate_icons.swift +258 -0
- package/skills/ios-icon-gen/scripts/iconify_gen.sh +235 -0
- package/skills/iterative-retrieval/SKILL.md +209 -0
- package/skills/java-coding-standards/SKILL.md +382 -0
- package/skills/jira-integration/SKILL.md +292 -0
- package/skills/jpa-patterns/SKILL.md +150 -0
- package/skills/knowledge-ops/SKILL.md +153 -0
- package/skills/kotlin-coroutines-flows/SKILL.md +283 -0
- package/skills/kotlin-exposed-patterns/SKILL.md +718 -0
- package/skills/kotlin-ktor-patterns/SKILL.md +688 -0
- package/skills/kotlin-patterns/SKILL.md +710 -0
- package/skills/kotlin-testing/SKILL.md +823 -0
- package/skills/laravel-patterns/SKILL.md +414 -0
- package/skills/laravel-plugin-discovery/SKILL.md +228 -0
- package/skills/laravel-security/SKILL.md +284 -0
- package/skills/laravel-tdd/SKILL.md +282 -0
- package/skills/laravel-verification/SKILL.md +178 -0
- package/skills/lead-intelligence/SKILL.md +320 -0
- package/skills/lead-intelligence/agents/enrichment-agent.md +85 -0
- package/skills/lead-intelligence/agents/mutual-mapper.md +75 -0
- package/skills/lead-intelligence/agents/outreach-drafter.md +98 -0
- package/skills/lead-intelligence/agents/signal-scorer.md +60 -0
- package/skills/liquid-glass-design/SKILL.md +279 -0
- package/skills/llm-trading-agent-security/SKILL.md +146 -0
- package/skills/logistics-exception-management/SKILL.md +221 -0
- package/skills/make-interfaces-feel-better/SKILL.md +151 -0
- package/skills/manim-video/SKILL.md +88 -0
- package/skills/manim-video/assets/network_graph_scene.py +52 -0
- package/skills/market-research/SKILL.md +74 -0
- package/skills/mcp-server-patterns/SKILL.md +68 -0
- package/skills/messages-ops/SKILL.md +103 -0
- package/skills/mle-workflow/SKILL.md +345 -0
- package/skills/motion-advanced/SKILL.md +596 -0
- package/skills/motion-foundations/SKILL.md +299 -0
- package/skills/motion-patterns/SKILL.md +435 -0
- package/skills/motion-ui/SKILL.md +574 -0
- package/skills/mysql-patterns/SKILL.md +411 -0
- package/skills/nanoclaw-repl/SKILL.md +32 -0
- package/skills/nestjs-patterns/SKILL.md +229 -0
- package/skills/netmiko-ssh-automation/SKILL.md +173 -0
- package/skills/network-bgp-diagnostics/SKILL.md +167 -0
- package/skills/network-config-validation/SKILL.md +210 -0
- package/skills/network-interface-health/SKILL.md +152 -0
- package/skills/nextjs-turbopack/SKILL.md +43 -0
- package/skills/nodejs-keccak256/SKILL.md +102 -0
- package/skills/nutrient-document-processing/SKILL.md +166 -0
- package/skills/nuxt4-patterns/SKILL.md +99 -0
- package/skills/openclaw-persona-forge/SKILL.md +288 -0
- package/skills/openclaw-persona-forge/gacha.py +224 -0
- package/skills/openclaw-persona-forge/gacha.sh +5 -0
- package/skills/openclaw-persona-forge/references/avatar-style.md +124 -0
- package/skills/openclaw-persona-forge/references/boundary-rules.md +53 -0
- package/skills/openclaw-persona-forge/references/error-handling.md +53 -0
- package/skills/openclaw-persona-forge/references/identity-tension.md +48 -0
- package/skills/openclaw-persona-forge/references/naming-system.md +39 -0
- package/skills/openclaw-persona-forge/references/output-template.md +166 -0
- package/skills/opensource-pipeline/SKILL.md +254 -0
- package/skills/perl-patterns/SKILL.md +503 -0
- package/skills/perl-security/SKILL.md +502 -0
- package/skills/perl-testing/SKILL.md +474 -0
- package/skills/plan-orchestrate/SKILL.md +253 -0
- package/skills/plankton-code-quality/SKILL.md +236 -0
- package/skills/postgres-patterns/SKILL.md +146 -0
- package/skills/product-capability/SKILL.md +140 -0
- package/skills/product-lens/SKILL.md +91 -0
- package/skills/production-audit/SKILL.md +206 -0
- package/skills/production-scheduling/SKILL.md +237 -0
- package/skills/project-flow-ops/SKILL.md +110 -0
- package/skills/prompt-optimizer/SKILL.md +398 -0
- package/skills/python-patterns/SKILL.md +749 -0
- package/skills/python-testing/SKILL.md +815 -0
- package/skills/pytorch-patterns/SKILL.md +395 -0
- package/skills/quality-nonconformance/SKILL.md +259 -0
- package/skills/quarkus-patterns/SKILL.md +721 -0
- package/skills/quarkus-security/SKILL.md +466 -0
- package/skills/quarkus-tdd/SKILL.md +810 -0
- package/skills/quarkus-verification/SKILL.md +478 -0
- package/skills/ralphinho-rfc-pipeline/SKILL.md +66 -0
- package/skills/redis-patterns/SKILL.md +402 -0
- package/skills/regex-vs-llm-structured-text/SKILL.md +219 -0
- package/skills/remotion-video-creation/SKILL.md +43 -0
- package/skills/remotion-video-creation/rules/3d.md +86 -0
- package/skills/remotion-video-creation/rules/animations.md +29 -0
- package/skills/remotion-video-creation/rules/assets/charts-bar-chart.tsx +173 -0
- package/skills/remotion-video-creation/rules/assets/text-animations-typewriter.tsx +100 -0
- package/skills/remotion-video-creation/rules/assets/text-animations-word-highlight.tsx +108 -0
- package/skills/remotion-video-creation/rules/assets.md +78 -0
- package/skills/remotion-video-creation/rules/audio.md +172 -0
- package/skills/remotion-video-creation/rules/calculate-metadata.md +104 -0
- package/skills/remotion-video-creation/rules/can-decode.md +75 -0
- package/skills/remotion-video-creation/rules/charts.md +58 -0
- package/skills/remotion-video-creation/rules/compositions.md +146 -0
- package/skills/remotion-video-creation/rules/display-captions.md +126 -0
- package/skills/remotion-video-creation/rules/extract-frames.md +229 -0
- package/skills/remotion-video-creation/rules/fonts.md +152 -0
- package/skills/remotion-video-creation/rules/get-audio-duration.md +58 -0
- package/skills/remotion-video-creation/rules/get-video-dimensions.md +68 -0
- package/skills/remotion-video-creation/rules/get-video-duration.md +58 -0
- package/skills/remotion-video-creation/rules/gifs.md +138 -0
- package/skills/remotion-video-creation/rules/images.md +130 -0
- package/skills/remotion-video-creation/rules/import-srt-captions.md +67 -0
- package/skills/remotion-video-creation/rules/lottie.md +67 -0
- package/skills/remotion-video-creation/rules/measuring-dom-nodes.md +34 -0
- package/skills/remotion-video-creation/rules/measuring-text.md +143 -0
- package/skills/remotion-video-creation/rules/sequencing.md +106 -0
- package/skills/remotion-video-creation/rules/tailwind.md +11 -0
- package/skills/remotion-video-creation/rules/text-animations.md +20 -0
- package/skills/remotion-video-creation/rules/timing.md +179 -0
- package/skills/remotion-video-creation/rules/transcribe-captions.md +19 -0
- package/skills/remotion-video-creation/rules/transitions.md +122 -0
- package/skills/remotion-video-creation/rules/trimming.md +52 -0
- package/skills/remotion-video-creation/rules/videos.md +171 -0
- package/skills/repo-scan/SKILL.md +78 -0
- package/skills/research-ops/SKILL.md +111 -0
- package/skills/returns-reverse-logistics/SKILL.md +239 -0
- package/skills/rules-distill/SKILL.md +263 -0
- package/skills/rules-distill/scripts/scan-rules.sh +58 -0
- package/skills/rules-distill/scripts/scan-skills.sh +129 -0
- package/skills/rust-patterns/SKILL.md +498 -0
- package/skills/rust-testing/SKILL.md +499 -0
- package/skills/safety-guard/SKILL.md +74 -0
- package/skills/santa-method/SKILL.md +306 -0
- package/skills/scientific-db-pubmed-database/SKILL.md +175 -0
- package/skills/scientific-db-uspto-database/SKILL.md +177 -0
- package/skills/scientific-pkg-gget/SKILL.md +166 -0
- package/skills/scientific-thinking-literature-review/SKILL.md +192 -0
- package/skills/scientific-thinking-scholar-evaluation/SKILL.md +160 -0
- package/skills/search-first/SKILL.md +181 -0
- package/skills/security-bounty-hunter/SKILL.md +99 -0
- package/skills/security-review/SKILL.md +502 -0
- package/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/skills/seo/SKILL.md +153 -0
- package/skills/skill-comply/SKILL.md +57 -0
- package/skills/skill-comply/fixtures/compliant_trace.jsonl +5 -0
- package/skills/skill-comply/fixtures/noncompliant_trace.jsonl +3 -0
- package/skills/skill-comply/fixtures/tdd_spec.yaml +44 -0
- package/skills/skill-comply/prompts/classifier.md +24 -0
- package/skills/skill-comply/prompts/scenario_generator.md +62 -0
- package/skills/skill-comply/prompts/spec_generator.md +42 -0
- package/skills/skill-comply/pyproject.toml +15 -0
- package/skills/skill-comply/scripts/__init__.py +0 -0
- package/skills/skill-comply/scripts/classifier.py +85 -0
- package/skills/skill-comply/scripts/grader.py +124 -0
- package/skills/skill-comply/scripts/parser.py +107 -0
- package/skills/skill-comply/scripts/report.py +170 -0
- package/skills/skill-comply/scripts/run.py +127 -0
- package/skills/skill-comply/scripts/runner.py +186 -0
- package/skills/skill-comply/scripts/scenario_generator.py +70 -0
- package/skills/skill-comply/scripts/spec_generator.py +72 -0
- package/skills/skill-comply/scripts/utils.py +13 -0
- package/skills/skill-comply/tests/test_grader.py +197 -0
- package/skills/skill-comply/tests/test_parser.py +90 -0
- package/skills/skill-comply/tests/test_runner.py +172 -0
- package/skills/skill-scout/SKILL.md +139 -0
- package/skills/skill-stocktake/SKILL.md +193 -0
- package/skills/skill-stocktake/scripts/quick-diff.sh +87 -0
- package/skills/skill-stocktake/scripts/save-results.sh +56 -0
- package/skills/skill-stocktake/scripts/scan.sh +170 -0
- package/skills/social-graph-ranker/SKILL.md +153 -0
- package/skills/springboot-patterns/SKILL.md +313 -0
- package/skills/springboot-security/SKILL.md +271 -0
- package/skills/springboot-tdd/SKILL.md +157 -0
- package/skills/springboot-verification/SKILL.md +230 -0
- package/skills/strategic-compact/SKILL.md +129 -0
- package/skills/strategic-compact/suggest-compact.sh +54 -0
- package/skills/swift-actor-persistence/SKILL.md +142 -0
- package/skills/swift-concurrency-6-2/SKILL.md +216 -0
- package/skills/swift-protocol-di-testing/SKILL.md +189 -0
- package/skills/swiftui-patterns/SKILL.md +259 -0
- package/skills/tdd-workflow/SKILL.md +462 -0
- package/skills/team-builder/SKILL.md +166 -0
- package/skills/terminal-ops/SKILL.md +108 -0
- package/skills/tinystruct-patterns/SKILL.md +130 -0
- package/skills/tinystruct-patterns/references/architecture.md +77 -0
- package/skills/tinystruct-patterns/references/data-handling.md +35 -0
- package/skills/tinystruct-patterns/references/routing.md +57 -0
- package/skills/tinystruct-patterns/references/system-usage.md +74 -0
- package/skills/tinystruct-patterns/references/testing.md +59 -0
- package/skills/token-budget-advisor/SKILL.md +133 -0
- package/skills/ui-demo/SKILL.md +464 -0
- package/skills/ui-to-vue/SKILL.md +134 -0
- package/skills/unified-notifications-ops/SKILL.md +186 -0
- package/skills/verification-loop/SKILL.md +125 -0
- package/skills/video-editing/SKILL.md +309 -0
- package/skills/videodb/SKILL.md +373 -0
- package/skills/videodb/reference/api-reference.md +550 -0
- package/skills/videodb/reference/capture-reference.md +407 -0
- package/skills/videodb/reference/capture.md +101 -0
- package/skills/videodb/reference/editor.md +443 -0
- package/skills/videodb/reference/generative.md +331 -0
- package/skills/videodb/reference/rtstream-reference.md +564 -0
- package/skills/videodb/reference/rtstream.md +65 -0
- package/skills/videodb/reference/search.md +230 -0
- package/skills/videodb/reference/streaming.md +406 -0
- package/skills/videodb/reference/use-cases.md +118 -0
- package/skills/videodb/scripts/ws_listener.py +282 -0
- package/skills/visa-doc-translate/README.md +86 -0
- package/skills/visa-doc-translate/SKILL.md +117 -0
- package/skills/vite-patterns/SKILL.md +448 -0
- package/skills/windows-desktop-e2e/SKILL.md +787 -0
- package/skills/workspace-surface-audit/SKILL.md +124 -0
- package/skills/x-api/SKILL.md +233 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: redis-patterns
|
|
3
|
+
description: Redis data structure patterns, caching strategies, distributed locks, rate limiting, pub/sub, and connection management for production applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Redis Patterns
|
|
7
|
+
|
|
8
|
+
Quick reference for Redis best practices across common backend use cases.
|
|
9
|
+
|
|
10
|
+
## How It Works
|
|
11
|
+
|
|
12
|
+
Redis is an in-memory data structure store that supports strings, hashes, lists, sets, sorted sets, streams, and more. Individual Redis commands are atomic on a single instance; multi-step workflows require Lua scripts, MULTI/EXEC transactions, or explicit synchronization to stay atomic. Data is optionally persisted via RDB snapshots or AOF logs. Clients communicate over TCP using the RESP protocol; connection pools are essential to avoid per-request handshake overhead.
|
|
13
|
+
|
|
14
|
+
## When to Activate
|
|
15
|
+
|
|
16
|
+
- Adding caching to an application
|
|
17
|
+
- Implementing rate limiting or throttling
|
|
18
|
+
- Building distributed locks or coordination
|
|
19
|
+
- Setting up session or token storage
|
|
20
|
+
- Using Pub/Sub or Redis Streams for messaging
|
|
21
|
+
- Configuring Redis in production (pooling, eviction, clustering)
|
|
22
|
+
|
|
23
|
+
## Data Structure Cheat Sheet
|
|
24
|
+
|
|
25
|
+
| Use Case | Structure | Example Key |
|
|
26
|
+
|----------|-----------|-------------|
|
|
27
|
+
| Simple cache | String | `product:123` |
|
|
28
|
+
| User session | Hash | `session:abc` |
|
|
29
|
+
| Leaderboard | Sorted Set | `scores:weekly` |
|
|
30
|
+
| Unique visitors | Set | `visitors:2024-01-01` |
|
|
31
|
+
| Activity feed | List | `feed:user:456` |
|
|
32
|
+
| Event stream | Stream | `events:orders` |
|
|
33
|
+
| Counters / rate limits | String (INCR) | `ratelimit:user:123` |
|
|
34
|
+
| Bloom filter / HLL | HyperLogLog | `hll:pageviews` |
|
|
35
|
+
|
|
36
|
+
## Core Patterns
|
|
37
|
+
|
|
38
|
+
### Cache-Aside (Lazy Loading)
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import redis
|
|
42
|
+
import json
|
|
43
|
+
|
|
44
|
+
r = redis.Redis(host='localhost', port=6379, decode_responses=True)
|
|
45
|
+
|
|
46
|
+
def get_product(product_id: int):
|
|
47
|
+
cache_key = f"product:{product_id}"
|
|
48
|
+
cached = r.get(cache_key)
|
|
49
|
+
|
|
50
|
+
if cached:
|
|
51
|
+
return json.loads(cached)
|
|
52
|
+
|
|
53
|
+
product = db.query("SELECT * FROM products WHERE id = %s", product_id)
|
|
54
|
+
r.setex(cache_key, 3600, json.dumps(product)) # TTL: 1 hour
|
|
55
|
+
return product
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Write-Through Cache
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
def update_product(product_id: int, data: dict):
|
|
62
|
+
# Write to DB first
|
|
63
|
+
db.execute("UPDATE products SET ... WHERE id = %s", product_id)
|
|
64
|
+
|
|
65
|
+
# Immediately update cache
|
|
66
|
+
cache_key = f"product:{product_id}"
|
|
67
|
+
r.setex(cache_key, 3600, json.dumps(data))
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Cache Invalidation
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
# Tag-based invalidation — group related keys under a set
|
|
74
|
+
def cache_product(product_id: int, category_id: int, data: dict):
|
|
75
|
+
key = f"product:{product_id}"
|
|
76
|
+
tag = f"tag:category:{category_id}"
|
|
77
|
+
pipe = r.pipeline(transaction=True)
|
|
78
|
+
pipe.setex(key, 3600, json.dumps(data))
|
|
79
|
+
pipe.sadd(tag, key)
|
|
80
|
+
pipe.expire(tag, 3600)
|
|
81
|
+
pipe.execute()
|
|
82
|
+
|
|
83
|
+
def invalidate_category(category_id: int):
|
|
84
|
+
tag = f"tag:category:{category_id}"
|
|
85
|
+
keys = r.smembers(tag)
|
|
86
|
+
if keys:
|
|
87
|
+
r.delete(*keys)
|
|
88
|
+
r.delete(tag)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Session Storage
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import time
|
|
95
|
+
import uuid
|
|
96
|
+
|
|
97
|
+
def create_session(user_id: int, ttl: int = 86400) -> str:
|
|
98
|
+
session_id = str(uuid.uuid4())
|
|
99
|
+
key = f"session:{session_id}"
|
|
100
|
+
pipe = r.pipeline(transaction=True)
|
|
101
|
+
pipe.hset(key, mapping={
|
|
102
|
+
"user_id": user_id,
|
|
103
|
+
"created_at": int(time.time()),
|
|
104
|
+
})
|
|
105
|
+
pipe.expire(key, ttl)
|
|
106
|
+
pipe.execute()
|
|
107
|
+
return session_id
|
|
108
|
+
|
|
109
|
+
def get_session(session_id: str) -> dict | None:
|
|
110
|
+
data = r.hgetall(f"session:{session_id}")
|
|
111
|
+
return data if data else None
|
|
112
|
+
|
|
113
|
+
def delete_session(session_id: str):
|
|
114
|
+
r.delete(f"session:{session_id}")
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Rate Limiting
|
|
118
|
+
|
|
119
|
+
### Fixed Window (Simple)
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
def is_rate_limited(user_id: int, limit: int = 100, window: int = 60) -> bool:
|
|
123
|
+
key = f"ratelimit:{user_id}:{int(time.time()) // window}"
|
|
124
|
+
pipe = r.pipeline(transaction=True)
|
|
125
|
+
pipe.incr(key)
|
|
126
|
+
pipe.expire(key, window)
|
|
127
|
+
count, _ = pipe.execute()
|
|
128
|
+
return count > limit
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Sliding Window (Lua — Atomic)
|
|
132
|
+
|
|
133
|
+
```lua
|
|
134
|
+
-- sliding_window.lua
|
|
135
|
+
local key = KEYS[1]
|
|
136
|
+
local now = tonumber(ARGV[1])
|
|
137
|
+
local window = tonumber(ARGV[2])
|
|
138
|
+
local limit = tonumber(ARGV[3])
|
|
139
|
+
|
|
140
|
+
redis.call('ZREMRANGEBYSCORE', key, 0, now - window)
|
|
141
|
+
local count = redis.call('ZCARD', key)
|
|
142
|
+
|
|
143
|
+
if count < limit then
|
|
144
|
+
-- Use unique member (now + sequence) to avoid collisions within the same millisecond
|
|
145
|
+
local seq_key = key .. ':seq'
|
|
146
|
+
local seq = redis.call('INCR', seq_key)
|
|
147
|
+
redis.call('EXPIRE', seq_key, math.ceil(window / 1000))
|
|
148
|
+
redis.call('ZADD', key, now, now .. '-' .. seq)
|
|
149
|
+
redis.call('EXPIRE', key, math.ceil(window / 1000))
|
|
150
|
+
return 1
|
|
151
|
+
end
|
|
152
|
+
return 0
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
sliding_window = r.register_script(open('sliding_window.lua').read())
|
|
157
|
+
|
|
158
|
+
def allow_request(user_id: int) -> bool:
|
|
159
|
+
key = f"ratelimit:sliding:{user_id}"
|
|
160
|
+
now = int(time.time() * 1000)
|
|
161
|
+
return bool(sliding_window(keys=[key], args=[now, 60000, 100]))
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Distributed Locks
|
|
165
|
+
|
|
166
|
+
### Distributed Lock (Single Node — SET NX PX)
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
import uuid
|
|
170
|
+
|
|
171
|
+
def acquire_lock(resource: str, ttl_ms: int = 5000) -> str | None:
|
|
172
|
+
lock_key = f"lock:{resource}"
|
|
173
|
+
token = str(uuid.uuid4())
|
|
174
|
+
acquired = r.set(lock_key, token, px=ttl_ms, nx=True)
|
|
175
|
+
return token if acquired else None
|
|
176
|
+
|
|
177
|
+
def release_lock(resource: str, token: str) -> bool:
|
|
178
|
+
release_script = """
|
|
179
|
+
if redis.call('get', KEYS[1]) == ARGV[1] then
|
|
180
|
+
return redis.call('del', KEYS[1])
|
|
181
|
+
else
|
|
182
|
+
return 0
|
|
183
|
+
end
|
|
184
|
+
"""
|
|
185
|
+
result = r.eval(release_script, 1, f"lock:{resource}", token)
|
|
186
|
+
return bool(result)
|
|
187
|
+
|
|
188
|
+
# Usage
|
|
189
|
+
token = acquire_lock("order:payment:123")
|
|
190
|
+
if token:
|
|
191
|
+
try:
|
|
192
|
+
process_payment()
|
|
193
|
+
finally:
|
|
194
|
+
release_lock("order:payment:123", token)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
> For multi-node setups use the `redlock-py` library which implements the full Redlock algorithm.
|
|
198
|
+
|
|
199
|
+
## Pub/Sub & Streams
|
|
200
|
+
|
|
201
|
+
### Pub/Sub (Fire-and-Forget)
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
# Publisher
|
|
205
|
+
def publish_event(channel: str, payload: dict):
|
|
206
|
+
r.publish(channel, json.dumps(payload))
|
|
207
|
+
|
|
208
|
+
# Subscriber (blocking — run in separate thread/process)
|
|
209
|
+
def subscribe_events(channel: str):
|
|
210
|
+
pubsub = r.pubsub()
|
|
211
|
+
pubsub.subscribe(channel)
|
|
212
|
+
for message in pubsub.listen():
|
|
213
|
+
if message['type'] == 'message':
|
|
214
|
+
handle(json.loads(message['data']))
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Redis Streams (Durable Queue)
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
# Producer
|
|
221
|
+
def emit(stream: str, event: dict):
|
|
222
|
+
r.xadd(stream, event, maxlen=10000) # Cap stream length
|
|
223
|
+
|
|
224
|
+
# Consumer group — guarantees at-least-once delivery
|
|
225
|
+
try:
|
|
226
|
+
r.xgroup_create('events:orders', 'processor', id='0', mkstream=True)
|
|
227
|
+
except Exception:
|
|
228
|
+
pass # Group already exists
|
|
229
|
+
|
|
230
|
+
def consume(stream: str, group: str, consumer: str):
|
|
231
|
+
while True:
|
|
232
|
+
messages = r.xreadgroup(group, consumer, {stream: '>'}, count=10, block=2000)
|
|
233
|
+
for _, entries in (messages or []):
|
|
234
|
+
for msg_id, data in entries:
|
|
235
|
+
process(data)
|
|
236
|
+
r.xack(stream, group, msg_id)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
> Prefer **Streams** over Pub/Sub when you need delivery guarantees, consumer groups, or replay.
|
|
240
|
+
|
|
241
|
+
## Key Design
|
|
242
|
+
|
|
243
|
+
### Naming Conventions
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
# Pattern: resource:id:field
|
|
247
|
+
user:123:profile
|
|
248
|
+
order:456:status
|
|
249
|
+
cache:product:789
|
|
250
|
+
|
|
251
|
+
# Pattern: namespace:resource:id
|
|
252
|
+
myapp:session:abc123
|
|
253
|
+
myapp:ratelimit:user:123
|
|
254
|
+
|
|
255
|
+
# Pattern: resource:date (time-bound keys)
|
|
256
|
+
stats:pageviews:2024-01-01
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### TTL Strategy
|
|
260
|
+
|
|
261
|
+
| Data Type | Suggested TTL |
|
|
262
|
+
|-----------|--------------|
|
|
263
|
+
| User session | 24h (`86400`) |
|
|
264
|
+
| API response cache | 5–15 min |
|
|
265
|
+
| Rate limit window | Match window size |
|
|
266
|
+
| Short-lived tokens | 5–10 min |
|
|
267
|
+
| Leaderboard | 1h–24h |
|
|
268
|
+
| Static/reference data | 1h–1 week |
|
|
269
|
+
|
|
270
|
+
Always set a TTL. Keys without TTL accumulate indefinitely and cause memory pressure.
|
|
271
|
+
|
|
272
|
+
## Connection Management
|
|
273
|
+
|
|
274
|
+
### Connection Pooling
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from redis import ConnectionPool, Redis
|
|
278
|
+
|
|
279
|
+
pool = ConnectionPool(
|
|
280
|
+
host='localhost',
|
|
281
|
+
port=6379,
|
|
282
|
+
db=0,
|
|
283
|
+
max_connections=20,
|
|
284
|
+
decode_responses=True,
|
|
285
|
+
socket_connect_timeout=2,
|
|
286
|
+
socket_timeout=2,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
r = Redis(connection_pool=pool)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Cluster Mode
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
from redis.cluster import RedisCluster
|
|
296
|
+
|
|
297
|
+
r = RedisCluster(
|
|
298
|
+
startup_nodes=[{"host": "redis-1", "port": 6379}],
|
|
299
|
+
decode_responses=True,
|
|
300
|
+
skip_full_coverage_check=True,
|
|
301
|
+
)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Sentinel (High Availability)
|
|
305
|
+
|
|
306
|
+
```python
|
|
307
|
+
from redis.sentinel import Sentinel
|
|
308
|
+
|
|
309
|
+
sentinel = Sentinel(
|
|
310
|
+
[('sentinel-1', 26379), ('sentinel-2', 26379)],
|
|
311
|
+
socket_timeout=0.5,
|
|
312
|
+
)
|
|
313
|
+
master = sentinel.master_for('mymaster', decode_responses=True)
|
|
314
|
+
replica = sentinel.slave_for('mymaster', decode_responses=True)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Eviction Policies
|
|
318
|
+
|
|
319
|
+
| Policy | Behavior | Best For |
|
|
320
|
+
|--------|----------|----------|
|
|
321
|
+
| `noeviction` | Error on write when full | Queues / critical data |
|
|
322
|
+
| `allkeys-lru` | Evict least recently used | General cache |
|
|
323
|
+
| `volatile-lru` | LRU only among keys with TTL | Mixed data store |
|
|
324
|
+
| `allkeys-lfu` | Evict least frequently used | Skewed access patterns |
|
|
325
|
+
| `volatile-ttl` | Evict soonest-to-expire | Prioritize long-lived data |
|
|
326
|
+
|
|
327
|
+
Set via `redis.conf`: `maxmemory-policy allkeys-lru`
|
|
328
|
+
|
|
329
|
+
## Anti-Patterns
|
|
330
|
+
|
|
331
|
+
| Anti-Pattern | Problem | Fix |
|
|
332
|
+
|---|---|---|
|
|
333
|
+
| Keys with no TTL | Memory grows unbounded | Always set TTL |
|
|
334
|
+
| `KEYS *` in production | Blocks the server (O(N)) | Use `SCAN` cursor |
|
|
335
|
+
| Storing large blobs (>100KB) | Slow serialization, memory pressure | Store reference + fetch from object store |
|
|
336
|
+
| Single Redis for everything | No isolation between cache & queue | Use separate DBs or instances |
|
|
337
|
+
| Ignoring connection pool limits | Connection exhaustion under load | Size pool to workload |
|
|
338
|
+
| Not handling cache miss stampede | Thundering herd on cold start | Use locks or probabilistic early expiry |
|
|
339
|
+
| `FLUSHALL` without thought | Wipes entire instance | Scope deletes by key pattern |
|
|
340
|
+
|
|
341
|
+
### Cache Miss Stampede Prevention
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
import threading
|
|
345
|
+
|
|
346
|
+
_locks: dict[str, threading.Lock] = {}
|
|
347
|
+
_locks_mutex = threading.Lock()
|
|
348
|
+
|
|
349
|
+
def get_with_lock(key: str, fetch_fn, ttl: int = 300):
|
|
350
|
+
cached = r.get(key)
|
|
351
|
+
if cached:
|
|
352
|
+
return json.loads(cached)
|
|
353
|
+
|
|
354
|
+
with _locks_mutex:
|
|
355
|
+
if key not in _locks:
|
|
356
|
+
_locks[key] = threading.Lock()
|
|
357
|
+
lock = _locks[key]
|
|
358
|
+
with lock:
|
|
359
|
+
cached = r.get(key) # Re-check after acquiring lock
|
|
360
|
+
if cached:
|
|
361
|
+
return json.loads(cached)
|
|
362
|
+
value = fetch_fn()
|
|
363
|
+
r.setex(key, ttl, json.dumps(value))
|
|
364
|
+
return value
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
> Note: for multi-process deployments, replace the in-process lock with `acquire_lock`/`release_lock` from the Distributed Locks section above.
|
|
368
|
+
|
|
369
|
+
## Examples
|
|
370
|
+
|
|
371
|
+
**Add caching to a Django/Flask API endpoint:**
|
|
372
|
+
Use cache-aside with `setex` and a 5-minute TTL on the response. Key on the request parameters.
|
|
373
|
+
|
|
374
|
+
**Rate-limit an API by user:**
|
|
375
|
+
Use fixed-window with `pipeline(transaction=True)` for low-traffic endpoints; use sliding-window Lua for accurate per-user throttling.
|
|
376
|
+
|
|
377
|
+
**Coordinate a background job across workers:**
|
|
378
|
+
Use `acquire_lock` with a TTL that exceeds the expected job duration. Always release in a `finally` block.
|
|
379
|
+
|
|
380
|
+
**Fan-out notifications to multiple subscribers:**
|
|
381
|
+
Use Pub/Sub for fire-and-forget. Switch to Streams if you need guaranteed delivery or replay for late consumers.
|
|
382
|
+
|
|
383
|
+
## Quick Reference
|
|
384
|
+
|
|
385
|
+
| Pattern | When to Use |
|
|
386
|
+
|---------|-------------|
|
|
387
|
+
| Cache-aside | Read-heavy, tolerate slight staleness |
|
|
388
|
+
| Write-through | Strong consistency required |
|
|
389
|
+
| Distributed lock | Prevent concurrent access to a resource |
|
|
390
|
+
| Sliding window rate limit | Accurate per-user throttling |
|
|
391
|
+
| Redis Streams | Durable event queue with consumer groups |
|
|
392
|
+
| Pub/Sub | Broadcast with no delivery guarantees needed |
|
|
393
|
+
| Sorted Set leaderboard | Ranked scoring, pagination |
|
|
394
|
+
| HyperLogLog | Approximate unique count at low memory |
|
|
395
|
+
|
|
396
|
+
## Related
|
|
397
|
+
|
|
398
|
+
- Skill: `postgres-patterns` — relational data patterns
|
|
399
|
+
- Skill: `backend-patterns` — API and service layer patterns
|
|
400
|
+
- Skill: `database-migrations` — schema versioning
|
|
401
|
+
- Skill: `django-patterns` — Django cache framework integration
|
|
402
|
+
- Agent: `database-reviewer` — full database review workflow
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: regex-vs-llm-structured-text
|
|
3
|
+
description: Decision framework for choosing between regex and LLM when parsing structured text — start with regex, add LLM only for low-confidence edge cases.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Regex vs LLM for Structured Text Parsing
|
|
7
|
+
|
|
8
|
+
A practical decision framework for parsing structured text (quizzes, forms, invoices, documents). The key insight: regex handles 95-98% of cases cheaply and deterministically. Reserve expensive LLM calls for the remaining edge cases.
|
|
9
|
+
|
|
10
|
+
## When to Activate
|
|
11
|
+
|
|
12
|
+
- Parsing structured text with repeating patterns (questions, forms, tables)
|
|
13
|
+
- Deciding between regex and LLM for text extraction
|
|
14
|
+
- Building hybrid pipelines that combine both approaches
|
|
15
|
+
- Optimizing cost/accuracy tradeoffs in text processing
|
|
16
|
+
|
|
17
|
+
## Decision Framework
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Is the text format consistent and repeating?
|
|
21
|
+
├── Yes (>90% follows a pattern) → Start with Regex
|
|
22
|
+
│ ├── Regex handles 95%+ → Done, no LLM needed
|
|
23
|
+
│ └── Regex handles <95% → Add LLM for edge cases only
|
|
24
|
+
└── No (free-form, highly variable) → Use LLM directly
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Architecture Pattern
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Source Text
|
|
31
|
+
│
|
|
32
|
+
▼
|
|
33
|
+
[Regex Parser] ─── Extracts structure (95-98% accuracy)
|
|
34
|
+
│
|
|
35
|
+
▼
|
|
36
|
+
[Text Cleaner] ─── Removes noise (markers, page numbers, artifacts)
|
|
37
|
+
│
|
|
38
|
+
▼
|
|
39
|
+
[Confidence Scorer] ─── Flags low-confidence extractions
|
|
40
|
+
│
|
|
41
|
+
├── High confidence (≥0.95) → Direct output
|
|
42
|
+
│
|
|
43
|
+
└── Low confidence (<0.95) → [LLM Validator] → Output
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Implementation
|
|
47
|
+
|
|
48
|
+
### 1. Regex Parser (Handles the Majority)
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import re
|
|
52
|
+
from dataclasses import dataclass
|
|
53
|
+
|
|
54
|
+
@dataclass(frozen=True)
|
|
55
|
+
class ParsedItem:
|
|
56
|
+
id: str
|
|
57
|
+
text: str
|
|
58
|
+
choices: tuple[str, ...]
|
|
59
|
+
answer: str
|
|
60
|
+
confidence: float = 1.0
|
|
61
|
+
|
|
62
|
+
def parse_structured_text(content: str) -> list[ParsedItem]:
|
|
63
|
+
"""Parse structured text using regex patterns."""
|
|
64
|
+
pattern = re.compile(
|
|
65
|
+
r"(?P<id>\d+)\.\s*(?P<text>.+?)\n"
|
|
66
|
+
r"(?P<choices>(?:[A-D]\..+?\n)+)"
|
|
67
|
+
r"Answer:\s*(?P<answer>[A-D])",
|
|
68
|
+
re.MULTILINE | re.DOTALL,
|
|
69
|
+
)
|
|
70
|
+
items = []
|
|
71
|
+
for match in pattern.finditer(content):
|
|
72
|
+
choices = tuple(
|
|
73
|
+
c.strip() for c in re.findall(r"[A-D]\.\s*(.+)", match.group("choices"))
|
|
74
|
+
)
|
|
75
|
+
items.append(ParsedItem(
|
|
76
|
+
id=match.group("id"),
|
|
77
|
+
text=match.group("text").strip(),
|
|
78
|
+
choices=choices,
|
|
79
|
+
answer=match.group("answer"),
|
|
80
|
+
))
|
|
81
|
+
return items
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Confidence Scoring
|
|
85
|
+
|
|
86
|
+
Flag items that may need LLM review:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
@dataclass(frozen=True)
|
|
90
|
+
class ConfidenceFlag:
|
|
91
|
+
item_id: str
|
|
92
|
+
score: float
|
|
93
|
+
reasons: tuple[str, ...]
|
|
94
|
+
|
|
95
|
+
def score_confidence(item: ParsedItem) -> ConfidenceFlag:
|
|
96
|
+
"""Score extraction confidence and flag issues."""
|
|
97
|
+
reasons = []
|
|
98
|
+
score = 1.0
|
|
99
|
+
|
|
100
|
+
if len(item.choices) < 3:
|
|
101
|
+
reasons.append("few_choices")
|
|
102
|
+
score -= 0.3
|
|
103
|
+
|
|
104
|
+
if not item.answer:
|
|
105
|
+
reasons.append("missing_answer")
|
|
106
|
+
score -= 0.5
|
|
107
|
+
|
|
108
|
+
if len(item.text) < 10:
|
|
109
|
+
reasons.append("short_text")
|
|
110
|
+
score -= 0.2
|
|
111
|
+
|
|
112
|
+
return ConfidenceFlag(
|
|
113
|
+
item_id=item.id,
|
|
114
|
+
score=max(0.0, score),
|
|
115
|
+
reasons=tuple(reasons),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
def identify_low_confidence(
|
|
119
|
+
items: list[ParsedItem],
|
|
120
|
+
threshold: float = 0.95,
|
|
121
|
+
) -> list[ConfidenceFlag]:
|
|
122
|
+
"""Return items below confidence threshold."""
|
|
123
|
+
flags = [score_confidence(item) for item in items]
|
|
124
|
+
return [f for f in flags if f.score < threshold]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 3. LLM Validator (Edge Cases Only)
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
def validate_with_llm(
|
|
131
|
+
item: ParsedItem,
|
|
132
|
+
original_text: str,
|
|
133
|
+
client,
|
|
134
|
+
) -> ParsedItem:
|
|
135
|
+
"""Use LLM to fix low-confidence extractions."""
|
|
136
|
+
response = client.messages.create(
|
|
137
|
+
model="claude-haiku-4-5-20251001", # Cheapest model for validation
|
|
138
|
+
max_tokens=500,
|
|
139
|
+
messages=[{
|
|
140
|
+
"role": "user",
|
|
141
|
+
"content": (
|
|
142
|
+
f"Extract the question, choices, and answer from this text.\n\n"
|
|
143
|
+
f"Text: {original_text}\n\n"
|
|
144
|
+
f"Current extraction: {item}\n\n"
|
|
145
|
+
f"Return corrected JSON if needed, or 'CORRECT' if accurate."
|
|
146
|
+
),
|
|
147
|
+
}],
|
|
148
|
+
)
|
|
149
|
+
# Parse LLM response and return corrected item...
|
|
150
|
+
return corrected_item
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 4. Hybrid Pipeline
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
def process_document(
|
|
157
|
+
content: str,
|
|
158
|
+
*,
|
|
159
|
+
llm_client=None,
|
|
160
|
+
confidence_threshold: float = 0.95,
|
|
161
|
+
) -> list[ParsedItem]:
|
|
162
|
+
"""Full pipeline: regex -> confidence check -> LLM for edge cases."""
|
|
163
|
+
# Step 1: Regex extraction (handles 95-98%)
|
|
164
|
+
items = parse_structured_text(content)
|
|
165
|
+
|
|
166
|
+
# Step 2: Confidence scoring
|
|
167
|
+
low_confidence = identify_low_confidence(items, confidence_threshold)
|
|
168
|
+
|
|
169
|
+
if not low_confidence or llm_client is None:
|
|
170
|
+
return items
|
|
171
|
+
|
|
172
|
+
# Step 3: LLM validation (only for flagged items)
|
|
173
|
+
low_conf_ids = {f.item_id for f in low_confidence}
|
|
174
|
+
result = []
|
|
175
|
+
for item in items:
|
|
176
|
+
if item.id in low_conf_ids:
|
|
177
|
+
result.append(validate_with_llm(item, content, llm_client))
|
|
178
|
+
else:
|
|
179
|
+
result.append(item)
|
|
180
|
+
|
|
181
|
+
return result
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Real-World Metrics
|
|
185
|
+
|
|
186
|
+
From a production quiz parsing pipeline (410 items):
|
|
187
|
+
|
|
188
|
+
| Metric | Value |
|
|
189
|
+
|--------|-------|
|
|
190
|
+
| Regex success rate | 98.0% |
|
|
191
|
+
| Low confidence items | 8 (2.0%) |
|
|
192
|
+
| LLM calls needed | ~5 |
|
|
193
|
+
| Cost savings vs all-LLM | ~95% |
|
|
194
|
+
| Test coverage | 93% |
|
|
195
|
+
|
|
196
|
+
## Best Practices
|
|
197
|
+
|
|
198
|
+
- **Start with regex** — even imperfect regex gives you a baseline to improve
|
|
199
|
+
- **Use confidence scoring** to programmatically identify what needs LLM help
|
|
200
|
+
- **Use the cheapest LLM** for validation (Haiku-class models are sufficient)
|
|
201
|
+
- **Never mutate** parsed items — return new instances from cleaning/validation steps
|
|
202
|
+
- **TDD works well** for parsers — write tests for known patterns first, then edge cases
|
|
203
|
+
- **Log metrics** (regex success rate, LLM call count) to track pipeline health
|
|
204
|
+
|
|
205
|
+
## Anti-Patterns to Avoid
|
|
206
|
+
|
|
207
|
+
- Sending all text to an LLM when regex handles 95%+ of cases (expensive and slow)
|
|
208
|
+
- Using regex for free-form, highly variable text (LLM is better here)
|
|
209
|
+
- Skipping confidence scoring and hoping regex "just works"
|
|
210
|
+
- Mutating parsed objects during cleaning/validation steps
|
|
211
|
+
- Not testing edge cases (malformed input, missing fields, encoding issues)
|
|
212
|
+
|
|
213
|
+
## When to Use
|
|
214
|
+
|
|
215
|
+
- Quiz/exam question parsing
|
|
216
|
+
- Form data extraction
|
|
217
|
+
- Invoice/receipt processing
|
|
218
|
+
- Document structure parsing (headers, sections, tables)
|
|
219
|
+
- Any structured text with repeating patterns where cost matters
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: remotion-video-creation
|
|
3
|
+
description: Best practices for Remotion - Video creation in React. 29 domain-specific rules covering 3D, animations, audio, captions, charts, transitions, and more.
|
|
4
|
+
metadata:
|
|
5
|
+
tags: remotion, video, react, animation, composition, three.js, lottie
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
|
|
10
|
+
Use this skills whenever you are dealing with Remotion code to obtain the domain-specific knowledge.
|
|
11
|
+
|
|
12
|
+
## How to use
|
|
13
|
+
|
|
14
|
+
Read individual rule files for detailed explanations and code examples:
|
|
15
|
+
|
|
16
|
+
- [rules/3d.md](rules/3d.md) - 3D content in Remotion using Three.js and React Three Fiber
|
|
17
|
+
- [rules/animations.md](rules/animations.md) - Fundamental animation skills for Remotion
|
|
18
|
+
- [rules/assets.md](rules/assets.md) - Importing images, videos, audio, and fonts into Remotion
|
|
19
|
+
- [rules/audio.md](rules/audio.md) - Using audio and sound in Remotion - importing, trimming, volume, speed, pitch
|
|
20
|
+
- [rules/calculate-metadata.md](rules/calculate-metadata.md) - Dynamically set composition duration, dimensions, and props
|
|
21
|
+
- [rules/can-decode.md](rules/can-decode.md) - Check if a video can be decoded by the browser using Mediabunny
|
|
22
|
+
- [rules/charts.md](rules/charts.md) - Chart and data visualization patterns for Remotion
|
|
23
|
+
- [rules/compositions.md](rules/compositions.md) - Defining compositions, stills, folders, default props and dynamic metadata
|
|
24
|
+
- [rules/display-captions.md](rules/display-captions.md) - Displaying captions in Remotion with TikTok-style pages and word highlighting
|
|
25
|
+
- [rules/extract-frames.md](rules/extract-frames.md) - Extract frames from videos at specific timestamps using Mediabunny
|
|
26
|
+
- [rules/fonts.md](rules/fonts.md) - Loading Google Fonts and local fonts in Remotion
|
|
27
|
+
- [rules/get-audio-duration.md](rules/get-audio-duration.md) - Getting the duration of an audio file in seconds with Mediabunny
|
|
28
|
+
- [rules/get-video-dimensions.md](rules/get-video-dimensions.md) - Getting the width and height of a video file with Mediabunny
|
|
29
|
+
- [rules/get-video-duration.md](rules/get-video-duration.md) - Getting the duration of a video file in seconds with Mediabunny
|
|
30
|
+
- [rules/gifs.md](rules/gifs.md) - Displaying GIFs synchronized with Remotion's timeline
|
|
31
|
+
- [rules/images.md](rules/images.md) - Embedding images in Remotion using the Img component
|
|
32
|
+
- [rules/import-srt-captions.md](rules/import-srt-captions.md) - Importing .srt subtitle files into Remotion using @remotion/captions
|
|
33
|
+
- [rules/lottie.md](rules/lottie.md) - Embedding Lottie animations in Remotion
|
|
34
|
+
- [rules/measuring-dom-nodes.md](rules/measuring-dom-nodes.md) - Measuring DOM element dimensions in Remotion
|
|
35
|
+
- [rules/measuring-text.md](rules/measuring-text.md) - Measuring text dimensions, fitting text to containers, and checking overflow
|
|
36
|
+
- [rules/sequencing.md](rules/sequencing.md) - Sequencing patterns for Remotion - delay, trim, limit duration of items
|
|
37
|
+
- [rules/tailwind.md](rules/tailwind.md) - Using TailwindCSS in Remotion
|
|
38
|
+
- [rules/text-animations.md](rules/text-animations.md) - Typography and text animation patterns for Remotion
|
|
39
|
+
- [rules/timing.md](rules/timing.md) - Interpolation curves in Remotion - linear, easing, spring animations
|
|
40
|
+
- [rules/transcribe-captions.md](rules/transcribe-captions.md) - Transcribing audio to generate captions in Remotion
|
|
41
|
+
- [rules/transitions.md](rules/transitions.md) - Scene transition patterns for Remotion
|
|
42
|
+
- [rules/trimming.md](rules/trimming.md) - Trimming patterns for Remotion - cut the beginning or end of animations
|
|
43
|
+
- [rules/videos.md](rules/videos.md) - Embedding videos in Remotion - trimming, volume, speed, looping, pitch
|