agim-cli 1.2.147 → 1.2.149
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 +158 -0
- package/dist/core/skills/builtin/ECC_LICENSE +21 -0
- package/dist/core/skills/builtin/ECC_NOTICE.md +28 -0
- package/dist/core/skills/builtin/accessibility/SKILL.md +146 -0
- package/dist/core/skills/builtin/agent-eval/SKILL.md +145 -0
- package/dist/core/skills/builtin/agent-harness-construction/SKILL.md +73 -0
- package/dist/core/skills/builtin/agent-introspection-debugging/SKILL.md +153 -0
- package/dist/core/skills/builtin/agentic-engineering/SKILL.md +63 -0
- package/dist/core/skills/builtin/ai-first-engineering/SKILL.md +51 -0
- package/dist/core/skills/builtin/ai-regression-testing/SKILL.md +385 -0
- package/dist/core/skills/builtin/android-clean-architecture/SKILL.md +339 -0
- package/dist/core/skills/builtin/angular-developer/SKILL.md +154 -0
- package/dist/core/skills/builtin/angular-developer/references/angular-animations.md +160 -0
- package/dist/core/skills/builtin/angular-developer/references/angular-aria.md +410 -0
- package/dist/core/skills/builtin/angular-developer/references/cli.md +86 -0
- package/dist/core/skills/builtin/angular-developer/references/component-harnesses.md +59 -0
- package/dist/core/skills/builtin/angular-developer/references/component-styling.md +91 -0
- package/dist/core/skills/builtin/angular-developer/references/components.md +117 -0
- package/dist/core/skills/builtin/angular-developer/references/creating-services.md +97 -0
- package/dist/core/skills/builtin/angular-developer/references/data-resolvers.md +69 -0
- package/dist/core/skills/builtin/angular-developer/references/define-routes.md +67 -0
- package/dist/core/skills/builtin/angular-developer/references/defining-providers.md +72 -0
- package/dist/core/skills/builtin/angular-developer/references/di-fundamentals.md +120 -0
- package/dist/core/skills/builtin/angular-developer/references/e2e-testing.md +56 -0
- package/dist/core/skills/builtin/angular-developer/references/effects.md +83 -0
- package/dist/core/skills/builtin/angular-developer/references/hierarchical-injectors.md +43 -0
- package/dist/core/skills/builtin/angular-developer/references/host-elements.md +80 -0
- package/dist/core/skills/builtin/angular-developer/references/injection-context.md +63 -0
- package/dist/core/skills/builtin/angular-developer/references/inputs.md +101 -0
- package/dist/core/skills/builtin/angular-developer/references/linked-signal.md +59 -0
- package/dist/core/skills/builtin/angular-developer/references/loading-strategies.md +61 -0
- package/dist/core/skills/builtin/angular-developer/references/mcp.md +108 -0
- package/dist/core/skills/builtin/angular-developer/references/navigate-to-routes.md +69 -0
- package/dist/core/skills/builtin/angular-developer/references/outputs.md +86 -0
- package/dist/core/skills/builtin/angular-developer/references/reactive-forms.md +122 -0
- package/dist/core/skills/builtin/angular-developer/references/rendering-strategies.md +44 -0
- package/dist/core/skills/builtin/angular-developer/references/resource.md +77 -0
- package/dist/core/skills/builtin/angular-developer/references/route-animations.md +56 -0
- package/dist/core/skills/builtin/angular-developer/references/route-guards.md +52 -0
- package/dist/core/skills/builtin/angular-developer/references/router-lifecycle.md +45 -0
- package/dist/core/skills/builtin/angular-developer/references/router-testing.md +87 -0
- package/dist/core/skills/builtin/angular-developer/references/show-routes-with-outlets.md +68 -0
- package/dist/core/skills/builtin/angular-developer/references/signal-forms.md +795 -0
- package/dist/core/skills/builtin/angular-developer/references/signals-overview.md +94 -0
- package/dist/core/skills/builtin/angular-developer/references/tailwind-css.md +69 -0
- package/dist/core/skills/builtin/angular-developer/references/template-driven-forms.md +114 -0
- package/dist/core/skills/builtin/angular-developer/references/testing-fundamentals.md +65 -0
- package/dist/core/skills/builtin/api-connector-builder/SKILL.md +120 -0
- package/dist/core/skills/builtin/api-design/SKILL.md +523 -0
- package/dist/core/skills/builtin/architecture-decision-records/SKILL.md +179 -0
- package/dist/core/skills/builtin/article-writing/SKILL.md +79 -0
- package/dist/core/skills/builtin/automation-audit-ops/SKILL.md +142 -0
- package/dist/core/skills/builtin/autonomous-agent-harness/SKILL.md +273 -0
- package/dist/core/skills/builtin/autonomous-loops/SKILL.md +610 -0
- package/dist/core/skills/builtin/backend-patterns/SKILL.md +561 -0
- package/dist/core/skills/builtin/benchmark/SKILL.md +93 -0
- package/dist/core/skills/builtin/benchmark-optimization-loop/SKILL.md +69 -0
- package/dist/core/skills/builtin/blueprint/SKILL.md +105 -0
- package/dist/core/skills/builtin/browser-qa/SKILL.md +87 -0
- package/dist/core/skills/builtin/bun-runtime/SKILL.md +84 -0
- package/dist/core/skills/builtin/cisco-ios-patterns/SKILL.md +163 -0
- package/dist/core/skills/builtin/claude-devfleet/SKILL.md +111 -0
- package/dist/core/skills/builtin/click-path-audit/SKILL.md +244 -0
- package/dist/core/skills/builtin/clickhouse-io/SKILL.md +439 -0
- package/dist/core/skills/builtin/code-tour/SKILL.md +236 -0
- package/dist/core/skills/builtin/codebase-onboarding/SKILL.md +233 -0
- package/dist/core/skills/builtin/codehealth-mcp/SKILL.md +166 -0
- package/dist/core/skills/builtin/coding-standards/SKILL.md +550 -0
- package/dist/core/skills/builtin/compose-multiplatform-patterns/SKILL.md +299 -0
- package/dist/core/skills/builtin/config-gc/SKILL.md +119 -0
- package/dist/core/skills/builtin/content-engine/SKILL.md +131 -0
- package/dist/core/skills/builtin/content-hash-cache-pattern/SKILL.md +161 -0
- package/dist/core/skills/builtin/context-budget/SKILL.md +135 -0
- package/dist/core/skills/builtin/continuous-agent-loop/SKILL.md +45 -0
- package/dist/core/skills/builtin/continuous-learning/SKILL.md +131 -0
- package/dist/core/skills/builtin/continuous-learning/config.json +18 -0
- package/dist/core/skills/builtin/continuous-learning/evaluate-session.sh +69 -0
- package/dist/core/skills/builtin/continuous-learning-v2/SKILL.md +360 -0
- package/dist/core/skills/builtin/continuous-learning-v2/agents/observer-loop.sh +335 -0
- package/dist/core/skills/builtin/continuous-learning-v2/agents/observer.md +198 -0
- package/dist/core/skills/builtin/continuous-learning-v2/agents/session-guardian.sh +150 -0
- package/dist/core/skills/builtin/continuous-learning-v2/agents/start-observer.sh +248 -0
- package/dist/core/skills/builtin/continuous-learning-v2/config.json +8 -0
- package/dist/core/skills/builtin/continuous-learning-v2/hooks/observe.sh +498 -0
- package/dist/core/skills/builtin/continuous-learning-v2/scripts/detect-project.sh +322 -0
- package/dist/core/skills/builtin/continuous-learning-v2/scripts/instinct-cli.py +1914 -0
- package/dist/core/skills/builtin/continuous-learning-v2/scripts/lib/homunculus-dir.sh +31 -0
- package/dist/core/skills/builtin/continuous-learning-v2/scripts/migrate-homunculus.sh +62 -0
- package/dist/core/skills/builtin/continuous-learning-v2/scripts/test_parse_instinct.py +1045 -0
- package/dist/core/skills/builtin/cost-aware-llm-pipeline/SKILL.md +183 -0
- package/dist/core/skills/builtin/cost-tracking/SKILL.md +147 -0
- package/dist/core/skills/builtin/council/SKILL.md +203 -0
- package/dist/core/skills/builtin/cpp-coding-standards/SKILL.md +723 -0
- package/dist/core/skills/builtin/cpp-testing/SKILL.md +324 -0
- package/dist/core/skills/builtin/crosspost/SKILL.md +111 -0
- package/dist/core/skills/builtin/csharp-testing/SKILL.md +321 -0
- package/dist/core/skills/builtin/customs-trade-compliance/SKILL.md +263 -0
- package/dist/core/skills/builtin/dart-flutter-patterns/SKILL.md +563 -0
- package/dist/core/skills/builtin/dashboard-builder/SKILL.md +108 -0
- package/dist/core/skills/builtin/data-scraper-agent/SKILL.md +764 -0
- package/dist/core/skills/builtin/data-throughput-accelerator/SKILL.md +72 -0
- package/dist/core/skills/builtin/database-migrations/SKILL.md +429 -0
- package/dist/core/skills/builtin/deep-research/SKILL.md +159 -0
- package/dist/core/skills/builtin/defi-amm-security/SKILL.md +166 -0
- package/dist/core/skills/builtin/deployment-patterns/SKILL.md +427 -0
- package/dist/core/skills/builtin/design-system/SKILL.md +82 -0
- package/dist/core/skills/builtin/django-celery/SKILL.md +457 -0
- package/dist/core/skills/builtin/django-patterns/SKILL.md +734 -0
- package/dist/core/skills/builtin/django-security/SKILL.md +593 -0
- package/dist/core/skills/builtin/django-tdd/SKILL.md +729 -0
- package/dist/core/skills/builtin/django-verification/SKILL.md +469 -0
- package/dist/core/skills/builtin/dmux-workflows/SKILL.md +191 -0
- package/dist/core/skills/builtin/docker-patterns/SKILL.md +364 -0
- package/dist/core/skills/builtin/documentation-lookup/SKILL.md +90 -0
- package/dist/core/skills/builtin/dotnet-patterns/SKILL.md +321 -0
- package/dist/core/skills/builtin/dynamic-workflow-mode/SKILL.md +123 -0
- package/dist/core/skills/builtin/e2e-testing/SKILL.md +326 -0
- package/dist/core/skills/builtin/email-ops/SKILL.md +121 -0
- package/dist/core/skills/builtin/energy-procurement/SKILL.md +228 -0
- package/dist/core/skills/builtin/enterprise-agent-ops/SKILL.md +50 -0
- package/dist/core/skills/builtin/error-handling/SKILL.md +376 -0
- package/dist/core/skills/builtin/eval-harness/SKILL.md +270 -0
- package/dist/core/skills/builtin/evm-token-decimals/SKILL.md +130 -0
- package/dist/core/skills/builtin/exa-search/SKILL.md +107 -0
- package/dist/core/skills/builtin/fal-ai-media/SKILL.md +288 -0
- package/dist/core/skills/builtin/fastapi-patterns/SKILL.md +513 -0
- package/dist/core/skills/builtin/finance-billing-ops/SKILL.md +127 -0
- package/dist/core/skills/builtin/flox-environments/SKILL.md +496 -0
- package/dist/core/skills/builtin/flutter-dart-code-review/SKILL.md +435 -0
- package/dist/core/skills/builtin/foundation-models-on-device/SKILL.md +243 -0
- package/dist/core/skills/builtin/frontend-a11y/SKILL.md +445 -0
- package/dist/core/skills/builtin/frontend-design-direction/SKILL.md +92 -0
- package/dist/core/skills/builtin/frontend-patterns/SKILL.md +656 -0
- package/dist/core/skills/builtin/frontend-slides/SKILL.md +184 -0
- package/dist/core/skills/builtin/frontend-slides/STYLE_PRESETS.md +330 -0
- package/dist/core/skills/builtin/frontend-slides/animation-patterns.md +122 -0
- package/dist/core/skills/builtin/frontend-slides/html-template.md +419 -0
- package/dist/core/skills/builtin/frontend-slides/scripts/export-pdf.sh +418 -0
- package/dist/core/skills/builtin/frontend-slides/scripts/extract-pptx.py +96 -0
- package/dist/core/skills/builtin/frontend-slides/viewport-base.css +153 -0
- package/dist/core/skills/builtin/fsharp-testing/SKILL.md +280 -0
- package/dist/core/skills/builtin/gan-style-harness/SKILL.md +278 -0
- package/dist/core/skills/builtin/gateguard/SKILL.md +132 -0
- package/dist/core/skills/builtin/git-workflow/SKILL.md +715 -0
- package/dist/core/skills/builtin/github-ops/SKILL.md +144 -0
- package/dist/core/skills/builtin/golang-patterns/SKILL.md +674 -0
- package/dist/core/skills/builtin/golang-testing/SKILL.md +720 -0
- package/dist/core/skills/builtin/healthcare-cdss-patterns/SKILL.md +245 -0
- package/dist/core/skills/builtin/healthcare-emr-patterns/SKILL.md +159 -0
- package/dist/core/skills/builtin/healthcare-eval-harness/SKILL.md +207 -0
- package/dist/core/skills/builtin/healthcare-phi-compliance/SKILL.md +145 -0
- package/dist/core/skills/builtin/hermes-imports/SKILL.md +88 -0
- package/dist/core/skills/builtin/hexagonal-architecture/SKILL.md +276 -0
- package/dist/core/skills/builtin/hipaa-compliance/SKILL.md +78 -0
- package/dist/core/skills/builtin/hookify-rules/SKILL.md +128 -0
- package/dist/core/skills/builtin/inherit-legacy-style/SKILL.md +156 -0
- package/dist/core/skills/builtin/intent-driven-development/SKILL.md +360 -0
- package/dist/core/skills/builtin/inventory-demand-planning/SKILL.md +247 -0
- package/dist/core/skills/builtin/ios-icon-gen/SKILL.md +157 -0
- package/dist/core/skills/builtin/ios-icon-gen/scripts/generate_icons.swift +258 -0
- package/dist/core/skills/builtin/ios-icon-gen/scripts/iconify_gen.sh +235 -0
- package/dist/core/skills/builtin/iterative-retrieval/SKILL.md +211 -0
- package/dist/core/skills/builtin/java-coding-standards/SKILL.md +383 -0
- package/dist/core/skills/builtin/jira-integration/SKILL.md +302 -0
- package/dist/core/skills/builtin/jpa-patterns/SKILL.md +151 -0
- package/dist/core/skills/builtin/knowledge-ops/SKILL.md +154 -0
- package/dist/core/skills/builtin/kotlin-coroutines-flows/SKILL.md +284 -0
- package/dist/core/skills/builtin/kotlin-exposed-patterns/SKILL.md +719 -0
- package/dist/core/skills/builtin/kotlin-ktor-patterns/SKILL.md +689 -0
- package/dist/core/skills/builtin/kotlin-patterns/SKILL.md +711 -0
- package/dist/core/skills/builtin/kotlin-testing/SKILL.md +824 -0
- package/dist/core/skills/builtin/kubernetes-patterns/SKILL.md +755 -0
- package/dist/core/skills/builtin/laravel-patterns/SKILL.md +415 -0
- package/dist/core/skills/builtin/laravel-plugin-discovery/SKILL.md +229 -0
- package/dist/core/skills/builtin/laravel-security/SKILL.md +947 -0
- package/dist/core/skills/builtin/laravel-tdd/SKILL.md +674 -0
- package/dist/core/skills/builtin/laravel-verification/SKILL.md +179 -0
- package/dist/core/skills/builtin/latency-critical-systems/SKILL.md +73 -0
- package/dist/core/skills/builtin/lead-intelligence/SKILL.md +321 -0
- package/dist/core/skills/builtin/lead-intelligence/agents/enrichment-agent.md +85 -0
- package/dist/core/skills/builtin/lead-intelligence/agents/mutual-mapper.md +75 -0
- package/dist/core/skills/builtin/lead-intelligence/agents/outreach-drafter.md +98 -0
- package/dist/core/skills/builtin/lead-intelligence/agents/signal-scorer.md +60 -0
- package/dist/core/skills/builtin/liquid-glass-design/SKILL.md +279 -0
- package/dist/core/skills/builtin/llm-trading-agent-security/SKILL.md +146 -0
- package/dist/core/skills/builtin/logistics-exception-management/SKILL.md +222 -0
- package/dist/core/skills/builtin/make-interfaces-feel-better/SKILL.md +151 -0
- package/dist/core/skills/builtin/market-research/SKILL.md +75 -0
- package/dist/core/skills/builtin/marketing-campaign/SKILL.md +113 -0
- package/dist/core/skills/builtin/mcp-server-patterns/SKILL.md +69 -0
- package/dist/core/skills/builtin/messages-ops/SKILL.md +104 -0
- package/dist/core/skills/builtin/mle-workflow/SKILL.md +346 -0
- package/dist/core/skills/builtin/motion-advanced/SKILL.md +596 -0
- package/dist/core/skills/builtin/motion-foundations/SKILL.md +299 -0
- package/dist/core/skills/builtin/motion-patterns/SKILL.md +434 -0
- package/dist/core/skills/builtin/motion-ui/SKILL.md +575 -0
- package/dist/core/skills/builtin/mysql-patterns/SKILL.md +412 -0
- package/dist/core/skills/builtin/nanoclaw-repl/SKILL.md +33 -0
- package/dist/core/skills/builtin/nestjs-patterns/SKILL.md +230 -0
- package/dist/core/skills/builtin/netmiko-ssh-automation/SKILL.md +173 -0
- package/dist/core/skills/builtin/network-bgp-diagnostics/SKILL.md +167 -0
- package/dist/core/skills/builtin/network-config-validation/SKILL.md +210 -0
- package/dist/core/skills/builtin/network-interface-health/SKILL.md +152 -0
- package/dist/core/skills/builtin/nextjs-turbopack/SKILL.md +57 -0
- package/dist/core/skills/builtin/nodejs-keccak256/SKILL.md +102 -0
- package/dist/core/skills/builtin/nutrient-document-processing/SKILL.md +167 -0
- package/dist/core/skills/builtin/nuxt4-patterns/SKILL.md +100 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/SKILL.md +288 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/gacha.py +224 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/gacha.sh +5 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/references/avatar-style.md +124 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/references/boundary-rules.md +53 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/references/error-handling.md +53 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/references/identity-tension.md +48 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/references/naming-system.md +39 -0
- package/dist/core/skills/builtin/openclaw-persona-forge/references/output-template.md +166 -0
- package/dist/core/skills/builtin/opensource-pipeline/SKILL.md +255 -0
- package/dist/core/skills/builtin/orch-add-feature/SKILL.md +44 -0
- package/dist/core/skills/builtin/orch-build-mvp/SKILL.md +48 -0
- package/dist/core/skills/builtin/orch-change-feature/SKILL.md +42 -0
- package/dist/core/skills/builtin/orch-fix-defect/SKILL.md +42 -0
- package/dist/core/skills/builtin/orch-pipeline/SKILL.md +120 -0
- package/dist/core/skills/builtin/orch-refine-code/SKILL.md +43 -0
- package/dist/core/skills/builtin/parallel-execution-optimizer/SKILL.md +72 -0
- package/dist/core/skills/builtin/perl-patterns/SKILL.md +504 -0
- package/dist/core/skills/builtin/perl-security/SKILL.md +503 -0
- package/dist/core/skills/builtin/perl-testing/SKILL.md +475 -0
- package/dist/core/skills/builtin/plan-orchestrate/SKILL.md +262 -0
- package/dist/core/skills/builtin/plankton-code-quality/SKILL.md +236 -0
- package/dist/core/skills/builtin/postgres-patterns/SKILL.md +147 -0
- package/dist/core/skills/builtin/prediction-market-oracle-research/SKILL.md +63 -0
- package/dist/core/skills/builtin/prediction-market-risk-review/SKILL.md +60 -0
- package/dist/core/skills/builtin/prisma-patterns/SKILL.md +371 -0
- package/dist/core/skills/builtin/product-capability/SKILL.md +141 -0
- package/dist/core/skills/builtin/product-lens/SKILL.md +92 -0
- package/dist/core/skills/builtin/production-audit/SKILL.md +206 -0
- package/dist/core/skills/builtin/production-scheduling/SKILL.md +238 -0
- package/dist/core/skills/builtin/prompt-optimizer/SKILL.md +398 -0
- package/dist/core/skills/builtin/python-patterns/SKILL.md +750 -0
- package/dist/core/skills/builtin/python-testing/SKILL.md +816 -0
- package/dist/core/skills/builtin/pytorch-patterns/SKILL.md +396 -0
- package/dist/core/skills/builtin/quality-nonconformance/SKILL.md +260 -0
- package/dist/core/skills/builtin/quarkus-patterns/SKILL.md +722 -0
- package/dist/core/skills/builtin/quarkus-security/SKILL.md +467 -0
- package/dist/core/skills/builtin/quarkus-tdd/SKILL.md +811 -0
- package/dist/core/skills/builtin/quarkus-verification/SKILL.md +479 -0
- package/dist/core/skills/builtin/ralphinho-rfc-pipeline/SKILL.md +67 -0
- package/dist/core/skills/builtin/react-patterns/SKILL.md +341 -0
- package/dist/core/skills/builtin/react-performance/SKILL.md +574 -0
- package/dist/core/skills/builtin/react-testing/SKILL.md +423 -0
- package/dist/core/skills/builtin/recsys-pipeline-architect/SKILL.md +114 -0
- package/dist/core/skills/builtin/recursive-decision-ledger/SKILL.md +79 -0
- package/dist/core/skills/builtin/redis-patterns/SKILL.md +403 -0
- package/dist/core/skills/builtin/regex-vs-llm-structured-text/SKILL.md +220 -0
- package/dist/core/skills/builtin/repo-scan/SKILL.md +78 -0
- package/dist/core/skills/builtin/research-ops/SKILL.md +112 -0
- package/dist/core/skills/builtin/returns-reverse-logistics/SKILL.md +240 -0
- package/dist/core/skills/builtin/rules-distill/SKILL.md +264 -0
- package/dist/core/skills/builtin/rules-distill/scripts/scan-rules.sh +58 -0
- package/dist/core/skills/builtin/rules-distill/scripts/scan-skills.sh +129 -0
- package/dist/core/skills/builtin/rust-patterns/SKILL.md +499 -0
- package/dist/core/skills/builtin/rust-testing/SKILL.md +500 -0
- package/dist/core/skills/builtin/safety-guard/SKILL.md +75 -0
- package/dist/core/skills/builtin/santa-method/SKILL.md +306 -0
- package/dist/core/skills/builtin/scientific-db-pubmed-database/SKILL.md +175 -0
- package/dist/core/skills/builtin/scientific-db-uspto-database/SKILL.md +177 -0
- package/dist/core/skills/builtin/scientific-pkg-gget/SKILL.md +166 -0
- package/dist/core/skills/builtin/scientific-thinking-literature-review/SKILL.md +192 -0
- package/dist/core/skills/builtin/scientific-thinking-scholar-evaluation/SKILL.md +160 -0
- package/dist/core/skills/builtin/search-first/SKILL.md +182 -0
- package/dist/core/skills/builtin/security-bounty-hunter/SKILL.md +99 -0
- package/dist/core/skills/builtin/security-review/SKILL.md +503 -0
- package/dist/core/skills/builtin/security-review/cloud-infrastructure-security.md +361 -0
- package/dist/core/skills/builtin/security-scan/SKILL.md +165 -0
- package/dist/core/skills/builtin/seo/SKILL.md +154 -0
- package/dist/core/skills/builtin/skill-comply/SKILL.md +58 -0
- package/dist/core/skills/builtin/skill-comply/fixtures/compliant_trace.jsonl +5 -0
- package/dist/core/skills/builtin/skill-comply/fixtures/noncompliant_trace.jsonl +3 -0
- package/dist/core/skills/builtin/skill-comply/fixtures/tdd_spec.yaml +44 -0
- package/dist/core/skills/builtin/skill-comply/prompts/classifier.md +24 -0
- package/dist/core/skills/builtin/skill-comply/prompts/scenario_generator.md +62 -0
- package/dist/core/skills/builtin/skill-comply/prompts/spec_generator.md +42 -0
- package/dist/core/skills/builtin/skill-comply/pyproject.toml +15 -0
- package/dist/core/skills/builtin/skill-comply/scripts/__init__.py +0 -0
- package/dist/core/skills/builtin/skill-comply/scripts/classifier.py +85 -0
- package/dist/core/skills/builtin/skill-comply/scripts/grader.py +124 -0
- package/dist/core/skills/builtin/skill-comply/scripts/parser.py +107 -0
- package/dist/core/skills/builtin/skill-comply/scripts/report.py +170 -0
- package/dist/core/skills/builtin/skill-comply/scripts/run.py +127 -0
- package/dist/core/skills/builtin/skill-comply/scripts/runner.py +186 -0
- package/dist/core/skills/builtin/skill-comply/scripts/scenario_generator.py +70 -0
- package/dist/core/skills/builtin/skill-comply/scripts/spec_generator.py +72 -0
- package/dist/core/skills/builtin/skill-comply/scripts/utils.py +13 -0
- package/dist/core/skills/builtin/skill-comply/tests/test_grader.py +197 -0
- package/dist/core/skills/builtin/skill-comply/tests/test_parser.py +90 -0
- package/dist/core/skills/builtin/skill-comply/tests/test_runner.py +172 -0
- package/dist/core/skills/builtin/skill-scout/SKILL.md +140 -0
- package/dist/core/skills/builtin/skill-stocktake/SKILL.md +194 -0
- package/dist/core/skills/builtin/skill-stocktake/scripts/quick-diff.sh +87 -0
- package/dist/core/skills/builtin/skill-stocktake/scripts/save-results.sh +56 -0
- package/dist/core/skills/builtin/skill-stocktake/scripts/scan.sh +170 -0
- package/dist/core/skills/builtin/springboot-patterns/SKILL.md +314 -0
- package/dist/core/skills/builtin/springboot-security/SKILL.md +272 -0
- package/dist/core/skills/builtin/springboot-tdd/SKILL.md +158 -0
- package/dist/core/skills/builtin/springboot-verification/SKILL.md +231 -0
- package/dist/core/skills/builtin/strategic-compact/SKILL.md +135 -0
- package/dist/core/skills/builtin/swift-actor-persistence/SKILL.md +143 -0
- package/dist/core/skills/builtin/swift-concurrency-6-2/SKILL.md +216 -0
- package/dist/core/skills/builtin/swift-protocol-di-testing/SKILL.md +190 -0
- package/dist/core/skills/builtin/swiftui-patterns/SKILL.md +259 -0
- package/dist/core/skills/builtin/tdd-workflow/SKILL.md +463 -0
- package/dist/core/skills/builtin/team-agent-orchestration/SKILL.md +110 -0
- package/dist/core/skills/builtin/team-builder/SKILL.md +168 -0
- package/dist/core/skills/builtin/terminal-ops/SKILL.md +109 -0
- package/dist/core/skills/builtin/tinystruct-patterns/SKILL.md +203 -0
- package/dist/core/skills/builtin/tinystruct-patterns/references/architecture.md +90 -0
- package/dist/core/skills/builtin/tinystruct-patterns/references/data-handling.md +60 -0
- package/dist/core/skills/builtin/tinystruct-patterns/references/database.md +99 -0
- package/dist/core/skills/builtin/tinystruct-patterns/references/routing.md +64 -0
- package/dist/core/skills/builtin/tinystruct-patterns/references/system-usage.md +97 -0
- package/dist/core/skills/builtin/tinystruct-patterns/references/testing.md +72 -0
- package/dist/core/skills/builtin/token-budget-advisor/SKILL.md +133 -0
- package/dist/core/skills/builtin/ui-demo/SKILL.md +465 -0
- package/dist/core/skills/builtin/ui-to-vue/SKILL.md +134 -0
- package/dist/core/skills/builtin/uncloud/SKILL.md +343 -0
- package/dist/core/skills/builtin/unified-notifications-ops/SKILL.md +187 -0
- package/dist/core/skills/builtin/verification-loop/SKILL.md +126 -0
- package/dist/core/skills/builtin/video-editing/SKILL.md +310 -0
- package/dist/core/skills/builtin/videodb/SKILL.md +374 -0
- package/dist/core/skills/builtin/videodb/reference/api-reference.md +550 -0
- package/dist/core/skills/builtin/videodb/reference/capture-reference.md +407 -0
- package/dist/core/skills/builtin/videodb/reference/capture.md +101 -0
- package/dist/core/skills/builtin/videodb/reference/editor.md +443 -0
- package/dist/core/skills/builtin/videodb/reference/generative.md +331 -0
- package/dist/core/skills/builtin/videodb/reference/rtstream-reference.md +564 -0
- package/dist/core/skills/builtin/videodb/reference/rtstream.md +65 -0
- package/dist/core/skills/builtin/videodb/reference/search.md +230 -0
- package/dist/core/skills/builtin/videodb/reference/streaming.md +406 -0
- package/dist/core/skills/builtin/videodb/reference/use-cases.md +118 -0
- package/dist/core/skills/builtin/videodb/scripts/ws_listener.py +282 -0
- package/dist/core/skills/builtin/visa-doc-translate/README.md +86 -0
- package/dist/core/skills/builtin/visa-doc-translate/SKILL.md +117 -0
- package/dist/core/skills/builtin/vite-patterns/SKILL.md +449 -0
- package/dist/core/skills/builtin/windows-desktop-e2e/SKILL.md +887 -0
- package/dist/core/skills/builtin/x-api/SKILL.md +234 -0
- package/dist/core/skills/loader.d.ts +23 -12
- package/dist/core/skills/loader.d.ts.map +1 -1
- package/dist/core/skills/loader.js +105 -2
- package/dist/core/skills/loader.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: redis-patterns
|
|
3
|
+
description: [ECC] Redis data structure patterns, caching strategies, distributed locks, rate limiting, pub/sub, and connection management for production applications.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Redis Patterns
|
|
8
|
+
|
|
9
|
+
Quick reference for Redis best practices across common backend use cases.
|
|
10
|
+
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
## When to Activate
|
|
16
|
+
|
|
17
|
+
- Adding caching to an application
|
|
18
|
+
- Implementing rate limiting or throttling
|
|
19
|
+
- Building distributed locks or coordination
|
|
20
|
+
- Setting up session or token storage
|
|
21
|
+
- Using Pub/Sub or Redis Streams for messaging
|
|
22
|
+
- Configuring Redis in production (pooling, eviction, clustering)
|
|
23
|
+
|
|
24
|
+
## Data Structure Cheat Sheet
|
|
25
|
+
|
|
26
|
+
| Use Case | Structure | Example Key |
|
|
27
|
+
|----------|-----------|-------------|
|
|
28
|
+
| Simple cache | String | `product:123` |
|
|
29
|
+
| User session | Hash | `session:abc` |
|
|
30
|
+
| Leaderboard | Sorted Set | `scores:weekly` |
|
|
31
|
+
| Unique visitors | Set | `visitors:2024-01-01` |
|
|
32
|
+
| Activity feed | List | `feed:user:456` |
|
|
33
|
+
| Event stream | Stream | `events:orders` |
|
|
34
|
+
| Counters / rate limits | String (INCR) | `ratelimit:user:123` |
|
|
35
|
+
| Bloom filter / HLL | HyperLogLog | `hll:pageviews` |
|
|
36
|
+
|
|
37
|
+
## Core Patterns
|
|
38
|
+
|
|
39
|
+
### Cache-Aside (Lazy Loading)
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import redis
|
|
43
|
+
import json
|
|
44
|
+
|
|
45
|
+
r = redis.Redis(host='localhost', port=6379, decode_responses=True)
|
|
46
|
+
|
|
47
|
+
def get_product(product_id: int):
|
|
48
|
+
cache_key = f"product:{product_id}"
|
|
49
|
+
cached = r.get(cache_key)
|
|
50
|
+
|
|
51
|
+
if cached:
|
|
52
|
+
return json.loads(cached)
|
|
53
|
+
|
|
54
|
+
product = db.query("SELECT * FROM products WHERE id = %s", product_id)
|
|
55
|
+
r.setex(cache_key, 3600, json.dumps(product)) # TTL: 1 hour
|
|
56
|
+
return product
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Write-Through Cache
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
def update_product(product_id: int, data: dict):
|
|
63
|
+
# Write to DB first
|
|
64
|
+
db.execute("UPDATE products SET ... WHERE id = %s", product_id)
|
|
65
|
+
|
|
66
|
+
# Immediately update cache
|
|
67
|
+
cache_key = f"product:{product_id}"
|
|
68
|
+
r.setex(cache_key, 3600, json.dumps(data))
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Cache Invalidation
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
# Tag-based invalidation — group related keys under a set
|
|
75
|
+
def cache_product(product_id: int, category_id: int, data: dict):
|
|
76
|
+
key = f"product:{product_id}"
|
|
77
|
+
tag = f"tag:category:{category_id}"
|
|
78
|
+
pipe = r.pipeline(transaction=True)
|
|
79
|
+
pipe.setex(key, 3600, json.dumps(data))
|
|
80
|
+
pipe.sadd(tag, key)
|
|
81
|
+
pipe.expire(tag, 3600)
|
|
82
|
+
pipe.execute()
|
|
83
|
+
|
|
84
|
+
def invalidate_category(category_id: int):
|
|
85
|
+
tag = f"tag:category:{category_id}"
|
|
86
|
+
keys = r.smembers(tag)
|
|
87
|
+
if keys:
|
|
88
|
+
r.delete(*keys)
|
|
89
|
+
r.delete(tag)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Session Storage
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import time
|
|
96
|
+
import uuid
|
|
97
|
+
|
|
98
|
+
def create_session(user_id: int, ttl: int = 86400) -> str:
|
|
99
|
+
session_id = str(uuid.uuid4())
|
|
100
|
+
key = f"session:{session_id}"
|
|
101
|
+
pipe = r.pipeline(transaction=True)
|
|
102
|
+
pipe.hset(key, mapping={
|
|
103
|
+
"user_id": user_id,
|
|
104
|
+
"created_at": int(time.time()),
|
|
105
|
+
})
|
|
106
|
+
pipe.expire(key, ttl)
|
|
107
|
+
pipe.execute()
|
|
108
|
+
return session_id
|
|
109
|
+
|
|
110
|
+
def get_session(session_id: str) -> dict | None:
|
|
111
|
+
data = r.hgetall(f"session:{session_id}")
|
|
112
|
+
return data if data else None
|
|
113
|
+
|
|
114
|
+
def delete_session(session_id: str):
|
|
115
|
+
r.delete(f"session:{session_id}")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Rate Limiting
|
|
119
|
+
|
|
120
|
+
### Fixed Window (Simple)
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
def is_rate_limited(user_id: int, limit: int = 100, window: int = 60) -> bool:
|
|
124
|
+
key = f"ratelimit:{user_id}:{int(time.time()) // window}"
|
|
125
|
+
pipe = r.pipeline(transaction=True)
|
|
126
|
+
pipe.incr(key)
|
|
127
|
+
pipe.expire(key, window)
|
|
128
|
+
count, _ = pipe.execute()
|
|
129
|
+
return count > limit
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Sliding Window (Lua — Atomic)
|
|
133
|
+
|
|
134
|
+
```lua
|
|
135
|
+
-- sliding_window.lua
|
|
136
|
+
local key = KEYS[1]
|
|
137
|
+
local now = tonumber(ARGV[1])
|
|
138
|
+
local window = tonumber(ARGV[2])
|
|
139
|
+
local limit = tonumber(ARGV[3])
|
|
140
|
+
|
|
141
|
+
redis.call('ZREMRANGEBYSCORE', key, 0, now - window)
|
|
142
|
+
local count = redis.call('ZCARD', key)
|
|
143
|
+
|
|
144
|
+
if count < limit then
|
|
145
|
+
-- Use unique member (now + sequence) to avoid collisions within the same millisecond
|
|
146
|
+
local seq_key = key .. ':seq'
|
|
147
|
+
local seq = redis.call('INCR', seq_key)
|
|
148
|
+
redis.call('EXPIRE', seq_key, math.ceil(window / 1000))
|
|
149
|
+
redis.call('ZADD', key, now, now .. '-' .. seq)
|
|
150
|
+
redis.call('EXPIRE', key, math.ceil(window / 1000))
|
|
151
|
+
return 1
|
|
152
|
+
end
|
|
153
|
+
return 0
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
sliding_window = r.register_script(open('sliding_window.lua').read())
|
|
158
|
+
|
|
159
|
+
def allow_request(user_id: int) -> bool:
|
|
160
|
+
key = f"ratelimit:sliding:{user_id}"
|
|
161
|
+
now = int(time.time() * 1000)
|
|
162
|
+
return bool(sliding_window(keys=[key], args=[now, 60000, 100]))
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Distributed Locks
|
|
166
|
+
|
|
167
|
+
### Distributed Lock (Single Node — SET NX PX)
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
import uuid
|
|
171
|
+
|
|
172
|
+
def acquire_lock(resource: str, ttl_ms: int = 5000) -> str | None:
|
|
173
|
+
lock_key = f"lock:{resource}"
|
|
174
|
+
token = str(uuid.uuid4())
|
|
175
|
+
acquired = r.set(lock_key, token, px=ttl_ms, nx=True)
|
|
176
|
+
return token if acquired else None
|
|
177
|
+
|
|
178
|
+
def release_lock(resource: str, token: str) -> bool:
|
|
179
|
+
release_script = """
|
|
180
|
+
if redis.call('get', KEYS[1]) == ARGV[1] then
|
|
181
|
+
return redis.call('del', KEYS[1])
|
|
182
|
+
else
|
|
183
|
+
return 0
|
|
184
|
+
end
|
|
185
|
+
"""
|
|
186
|
+
result = r.eval(release_script, 1, f"lock:{resource}", token)
|
|
187
|
+
return bool(result)
|
|
188
|
+
|
|
189
|
+
# Usage
|
|
190
|
+
token = acquire_lock("order:payment:123")
|
|
191
|
+
if token:
|
|
192
|
+
try:
|
|
193
|
+
process_payment()
|
|
194
|
+
finally:
|
|
195
|
+
release_lock("order:payment:123", token)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
> For multi-node setups use the `redlock-py` library which implements the full Redlock algorithm.
|
|
199
|
+
|
|
200
|
+
## Pub/Sub & Streams
|
|
201
|
+
|
|
202
|
+
### Pub/Sub (Fire-and-Forget)
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
# Publisher
|
|
206
|
+
def publish_event(channel: str, payload: dict):
|
|
207
|
+
r.publish(channel, json.dumps(payload))
|
|
208
|
+
|
|
209
|
+
# Subscriber (blocking — run in separate thread/process)
|
|
210
|
+
def subscribe_events(channel: str):
|
|
211
|
+
pubsub = r.pubsub()
|
|
212
|
+
pubsub.subscribe(channel)
|
|
213
|
+
for message in pubsub.listen():
|
|
214
|
+
if message['type'] == 'message':
|
|
215
|
+
handle(json.loads(message['data']))
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Redis Streams (Durable Queue)
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
# Producer
|
|
222
|
+
def emit(stream: str, event: dict):
|
|
223
|
+
r.xadd(stream, event, maxlen=10000) # Cap stream length
|
|
224
|
+
|
|
225
|
+
# Consumer group — guarantees at-least-once delivery
|
|
226
|
+
try:
|
|
227
|
+
r.xgroup_create('events:orders', 'processor', id='0', mkstream=True)
|
|
228
|
+
except Exception:
|
|
229
|
+
pass # Group already exists
|
|
230
|
+
|
|
231
|
+
def consume(stream: str, group: str, consumer: str):
|
|
232
|
+
while True:
|
|
233
|
+
messages = r.xreadgroup(group, consumer, {stream: '>'}, count=10, block=2000)
|
|
234
|
+
for _, entries in (messages or []):
|
|
235
|
+
for msg_id, data in entries:
|
|
236
|
+
process(data)
|
|
237
|
+
r.xack(stream, group, msg_id)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
> Prefer **Streams** over Pub/Sub when you need delivery guarantees, consumer groups, or replay.
|
|
241
|
+
|
|
242
|
+
## Key Design
|
|
243
|
+
|
|
244
|
+
### Naming Conventions
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
# Pattern: resource:id:field
|
|
248
|
+
user:123:profile
|
|
249
|
+
order:456:status
|
|
250
|
+
cache:product:789
|
|
251
|
+
|
|
252
|
+
# Pattern: namespace:resource:id
|
|
253
|
+
myapp:session:abc123
|
|
254
|
+
myapp:ratelimit:user:123
|
|
255
|
+
|
|
256
|
+
# Pattern: resource:date (time-bound keys)
|
|
257
|
+
stats:pageviews:2024-01-01
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### TTL Strategy
|
|
261
|
+
|
|
262
|
+
| Data Type | Suggested TTL |
|
|
263
|
+
|-----------|--------------|
|
|
264
|
+
| User session | 24h (`86400`) |
|
|
265
|
+
| API response cache | 5–15 min |
|
|
266
|
+
| Rate limit window | Match window size |
|
|
267
|
+
| Short-lived tokens | 5–10 min |
|
|
268
|
+
| Leaderboard | 1h–24h |
|
|
269
|
+
| Static/reference data | 1h–1 week |
|
|
270
|
+
|
|
271
|
+
Always set a TTL. Keys without TTL accumulate indefinitely and cause memory pressure.
|
|
272
|
+
|
|
273
|
+
## Connection Management
|
|
274
|
+
|
|
275
|
+
### Connection Pooling
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
from redis import ConnectionPool, Redis
|
|
279
|
+
|
|
280
|
+
pool = ConnectionPool(
|
|
281
|
+
host='localhost',
|
|
282
|
+
port=6379,
|
|
283
|
+
db=0,
|
|
284
|
+
max_connections=20,
|
|
285
|
+
decode_responses=True,
|
|
286
|
+
socket_connect_timeout=2,
|
|
287
|
+
socket_timeout=2,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
r = Redis(connection_pool=pool)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Cluster Mode
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from redis.cluster import RedisCluster
|
|
297
|
+
|
|
298
|
+
r = RedisCluster(
|
|
299
|
+
startup_nodes=[{"host": "redis-1", "port": 6379}],
|
|
300
|
+
decode_responses=True,
|
|
301
|
+
skip_full_coverage_check=True,
|
|
302
|
+
)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Sentinel (High Availability)
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
from redis.sentinel import Sentinel
|
|
309
|
+
|
|
310
|
+
sentinel = Sentinel(
|
|
311
|
+
[('sentinel-1', 26379), ('sentinel-2', 26379)],
|
|
312
|
+
socket_timeout=0.5,
|
|
313
|
+
)
|
|
314
|
+
master = sentinel.master_for('mymaster', decode_responses=True)
|
|
315
|
+
replica = sentinel.slave_for('mymaster', decode_responses=True)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Eviction Policies
|
|
319
|
+
|
|
320
|
+
| Policy | Behavior | Best For |
|
|
321
|
+
|--------|----------|----------|
|
|
322
|
+
| `noeviction` | Error on write when full | Queues / critical data |
|
|
323
|
+
| `allkeys-lru` | Evict least recently used | General cache |
|
|
324
|
+
| `volatile-lru` | LRU only among keys with TTL | Mixed data store |
|
|
325
|
+
| `allkeys-lfu` | Evict least frequently used | Skewed access patterns |
|
|
326
|
+
| `volatile-ttl` | Evict soonest-to-expire | Prioritize long-lived data |
|
|
327
|
+
|
|
328
|
+
Set via `redis.conf`: `maxmemory-policy allkeys-lru`
|
|
329
|
+
|
|
330
|
+
## Anti-Patterns
|
|
331
|
+
|
|
332
|
+
| Anti-Pattern | Problem | Fix |
|
|
333
|
+
|---|---|---|
|
|
334
|
+
| Keys with no TTL | Memory grows unbounded | Always set TTL |
|
|
335
|
+
| `KEYS *` in production | Blocks the server (O(N)) | Use `SCAN` cursor |
|
|
336
|
+
| Storing large blobs (>100KB) | Slow serialization, memory pressure | Store reference + fetch from object store |
|
|
337
|
+
| Single Redis for everything | No isolation between cache & queue | Use separate DBs or instances |
|
|
338
|
+
| Ignoring connection pool limits | Connection exhaustion under load | Size pool to workload |
|
|
339
|
+
| Not handling cache miss stampede | Thundering herd on cold start | Use locks or probabilistic early expiry |
|
|
340
|
+
| `FLUSHALL` without thought | Wipes entire instance | Scope deletes by key pattern |
|
|
341
|
+
|
|
342
|
+
### Cache Miss Stampede Prevention
|
|
343
|
+
|
|
344
|
+
```python
|
|
345
|
+
import threading
|
|
346
|
+
|
|
347
|
+
_locks: dict[str, threading.Lock] = {}
|
|
348
|
+
_locks_mutex = threading.Lock()
|
|
349
|
+
|
|
350
|
+
def get_with_lock(key: str, fetch_fn, ttl: int = 300):
|
|
351
|
+
cached = r.get(key)
|
|
352
|
+
if cached:
|
|
353
|
+
return json.loads(cached)
|
|
354
|
+
|
|
355
|
+
with _locks_mutex:
|
|
356
|
+
if key not in _locks:
|
|
357
|
+
_locks[key] = threading.Lock()
|
|
358
|
+
lock = _locks[key]
|
|
359
|
+
with lock:
|
|
360
|
+
cached = r.get(key) # Re-check after acquiring lock
|
|
361
|
+
if cached:
|
|
362
|
+
return json.loads(cached)
|
|
363
|
+
value = fetch_fn()
|
|
364
|
+
r.setex(key, ttl, json.dumps(value))
|
|
365
|
+
return value
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
> Note: for multi-process deployments, replace the in-process lock with `acquire_lock`/`release_lock` from the Distributed Locks section above.
|
|
369
|
+
|
|
370
|
+
## Examples
|
|
371
|
+
|
|
372
|
+
**Add caching to a Django/Flask API endpoint:**
|
|
373
|
+
Use cache-aside with `setex` and a 5-minute TTL on the response. Key on the request parameters.
|
|
374
|
+
|
|
375
|
+
**Rate-limit an API by user:**
|
|
376
|
+
Use fixed-window with `pipeline(transaction=True)` for low-traffic endpoints; use sliding-window Lua for accurate per-user throttling.
|
|
377
|
+
|
|
378
|
+
**Coordinate a background job across workers:**
|
|
379
|
+
Use `acquire_lock` with a TTL that exceeds the expected job duration. Always release in a `finally` block.
|
|
380
|
+
|
|
381
|
+
**Fan-out notifications to multiple subscribers:**
|
|
382
|
+
Use Pub/Sub for fire-and-forget. Switch to Streams if you need guaranteed delivery or replay for late consumers.
|
|
383
|
+
|
|
384
|
+
## Quick Reference
|
|
385
|
+
|
|
386
|
+
| Pattern | When to Use |
|
|
387
|
+
|---------|-------------|
|
|
388
|
+
| Cache-aside | Read-heavy, tolerate slight staleness |
|
|
389
|
+
| Write-through | Strong consistency required |
|
|
390
|
+
| Distributed lock | Prevent concurrent access to a resource |
|
|
391
|
+
| Sliding window rate limit | Accurate per-user throttling |
|
|
392
|
+
| Redis Streams | Durable event queue with consumer groups |
|
|
393
|
+
| Pub/Sub | Broadcast with no delivery guarantees needed |
|
|
394
|
+
| Sorted Set leaderboard | Ranked scoring, pagination |
|
|
395
|
+
| HyperLogLog | Approximate unique count at low memory |
|
|
396
|
+
|
|
397
|
+
## Related
|
|
398
|
+
|
|
399
|
+
- Skill: `postgres-patterns` — relational data patterns
|
|
400
|
+
- Skill: `backend-patterns` — API and service layer patterns
|
|
401
|
+
- Skill: `database-migrations` — schema versioning
|
|
402
|
+
- Skill: `django-patterns` — Django cache framework integration
|
|
403
|
+
- Agent: `database-reviewer` — full database review workflow
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: regex-vs-llm-structured-text
|
|
3
|
+
description: [ECC] Decision framework for choosing between regex and LLM when parsing structured text — start with regex, add LLM only for low-confidence edge cases.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Regex vs LLM for Structured Text Parsing
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## When to Activate
|
|
12
|
+
|
|
13
|
+
- Parsing structured text with repeating patterns (questions, forms, tables)
|
|
14
|
+
- Deciding between regex and LLM for text extraction
|
|
15
|
+
- Building hybrid pipelines that combine both approaches
|
|
16
|
+
- Optimizing cost/accuracy tradeoffs in text processing
|
|
17
|
+
|
|
18
|
+
## Decision Framework
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Is the text format consistent and repeating?
|
|
22
|
+
├── Yes (>90% follows a pattern) → Start with Regex
|
|
23
|
+
│ ├── Regex handles 95%+ → Done, no LLM needed
|
|
24
|
+
│ └── Regex handles <95% → Add LLM for edge cases only
|
|
25
|
+
└── No (free-form, highly variable) → Use LLM directly
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Architecture Pattern
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Source Text
|
|
32
|
+
│
|
|
33
|
+
▼
|
|
34
|
+
[Regex Parser] ─── Extracts structure (95-98% accuracy)
|
|
35
|
+
│
|
|
36
|
+
▼
|
|
37
|
+
[Text Cleaner] ─── Removes noise (markers, page numbers, artifacts)
|
|
38
|
+
│
|
|
39
|
+
▼
|
|
40
|
+
[Confidence Scorer] ─── Flags low-confidence extractions
|
|
41
|
+
│
|
|
42
|
+
├── High confidence (≥0.95) → Direct output
|
|
43
|
+
│
|
|
44
|
+
└── Low confidence (<0.95) → [LLM Validator] → Output
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Implementation
|
|
48
|
+
|
|
49
|
+
### 1. Regex Parser (Handles the Majority)
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import re
|
|
53
|
+
from dataclasses import dataclass
|
|
54
|
+
|
|
55
|
+
@dataclass(frozen=True)
|
|
56
|
+
class ParsedItem:
|
|
57
|
+
id: str
|
|
58
|
+
text: str
|
|
59
|
+
choices: tuple[str, ...]
|
|
60
|
+
answer: str
|
|
61
|
+
confidence: float = 1.0
|
|
62
|
+
|
|
63
|
+
def parse_structured_text(content: str) -> list[ParsedItem]:
|
|
64
|
+
"""Parse structured text using regex patterns."""
|
|
65
|
+
pattern = re.compile(
|
|
66
|
+
r"(?P<id>\d+)\.\s*(?P<text>.+?)\n"
|
|
67
|
+
r"(?P<choices>(?:[A-D]\..+?\n)+)"
|
|
68
|
+
r"Answer:\s*(?P<answer>[A-D])",
|
|
69
|
+
re.MULTILINE | re.DOTALL,
|
|
70
|
+
)
|
|
71
|
+
items = []
|
|
72
|
+
for match in pattern.finditer(content):
|
|
73
|
+
choices = tuple(
|
|
74
|
+
c.strip() for c in re.findall(r"[A-D]\.\s*(.+)", match.group("choices"))
|
|
75
|
+
)
|
|
76
|
+
items.append(ParsedItem(
|
|
77
|
+
id=match.group("id"),
|
|
78
|
+
text=match.group("text").strip(),
|
|
79
|
+
choices=choices,
|
|
80
|
+
answer=match.group("answer"),
|
|
81
|
+
))
|
|
82
|
+
return items
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 2. Confidence Scoring
|
|
86
|
+
|
|
87
|
+
Flag items that may need LLM review:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
@dataclass(frozen=True)
|
|
91
|
+
class ConfidenceFlag:
|
|
92
|
+
item_id: str
|
|
93
|
+
score: float
|
|
94
|
+
reasons: tuple[str, ...]
|
|
95
|
+
|
|
96
|
+
def score_confidence(item: ParsedItem) -> ConfidenceFlag:
|
|
97
|
+
"""Score extraction confidence and flag issues."""
|
|
98
|
+
reasons = []
|
|
99
|
+
score = 1.0
|
|
100
|
+
|
|
101
|
+
if len(item.choices) < 3:
|
|
102
|
+
reasons.append("few_choices")
|
|
103
|
+
score -= 0.3
|
|
104
|
+
|
|
105
|
+
if not item.answer:
|
|
106
|
+
reasons.append("missing_answer")
|
|
107
|
+
score -= 0.5
|
|
108
|
+
|
|
109
|
+
if len(item.text) < 10:
|
|
110
|
+
reasons.append("short_text")
|
|
111
|
+
score -= 0.2
|
|
112
|
+
|
|
113
|
+
return ConfidenceFlag(
|
|
114
|
+
item_id=item.id,
|
|
115
|
+
score=max(0.0, score),
|
|
116
|
+
reasons=tuple(reasons),
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def identify_low_confidence(
|
|
120
|
+
items: list[ParsedItem],
|
|
121
|
+
threshold: float = 0.95,
|
|
122
|
+
) -> list[ConfidenceFlag]:
|
|
123
|
+
"""Return items below confidence threshold."""
|
|
124
|
+
flags = [score_confidence(item) for item in items]
|
|
125
|
+
return [f for f in flags if f.score < threshold]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 3. LLM Validator (Edge Cases Only)
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
def validate_with_llm(
|
|
132
|
+
item: ParsedItem,
|
|
133
|
+
original_text: str,
|
|
134
|
+
client,
|
|
135
|
+
) -> ParsedItem:
|
|
136
|
+
"""Use LLM to fix low-confidence extractions."""
|
|
137
|
+
response = client.messages.create(
|
|
138
|
+
model="claude-haiku-4-5-20251001", # Cheapest model for validation
|
|
139
|
+
max_tokens=500,
|
|
140
|
+
messages=[{
|
|
141
|
+
"role": "user",
|
|
142
|
+
"content": (
|
|
143
|
+
f"Extract the question, choices, and answer from this text.\n\n"
|
|
144
|
+
f"Text: {original_text}\n\n"
|
|
145
|
+
f"Current extraction: {item}\n\n"
|
|
146
|
+
f"Return corrected JSON if needed, or 'CORRECT' if accurate."
|
|
147
|
+
),
|
|
148
|
+
}],
|
|
149
|
+
)
|
|
150
|
+
# Parse LLM response and return corrected item...
|
|
151
|
+
return corrected_item
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 4. Hybrid Pipeline
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
def process_document(
|
|
158
|
+
content: str,
|
|
159
|
+
*,
|
|
160
|
+
llm_client=None,
|
|
161
|
+
confidence_threshold: float = 0.95,
|
|
162
|
+
) -> list[ParsedItem]:
|
|
163
|
+
"""Full pipeline: regex -> confidence check -> LLM for edge cases."""
|
|
164
|
+
# Step 1: Regex extraction (handles 95-98%)
|
|
165
|
+
items = parse_structured_text(content)
|
|
166
|
+
|
|
167
|
+
# Step 2: Confidence scoring
|
|
168
|
+
low_confidence = identify_low_confidence(items, confidence_threshold)
|
|
169
|
+
|
|
170
|
+
if not low_confidence or llm_client is None:
|
|
171
|
+
return items
|
|
172
|
+
|
|
173
|
+
# Step 3: LLM validation (only for flagged items)
|
|
174
|
+
low_conf_ids = {f.item_id for f in low_confidence}
|
|
175
|
+
result = []
|
|
176
|
+
for item in items:
|
|
177
|
+
if item.id in low_conf_ids:
|
|
178
|
+
result.append(validate_with_llm(item, content, llm_client))
|
|
179
|
+
else:
|
|
180
|
+
result.append(item)
|
|
181
|
+
|
|
182
|
+
return result
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Real-World Metrics
|
|
186
|
+
|
|
187
|
+
From a production quiz parsing pipeline (410 items):
|
|
188
|
+
|
|
189
|
+
| Metric | Value |
|
|
190
|
+
|--------|-------|
|
|
191
|
+
| Regex success rate | 98.0% |
|
|
192
|
+
| Low confidence items | 8 (2.0%) |
|
|
193
|
+
| LLM calls needed | ~5 |
|
|
194
|
+
| Cost savings vs all-LLM | ~95% |
|
|
195
|
+
| Test coverage | 93% |
|
|
196
|
+
|
|
197
|
+
## Best Practices
|
|
198
|
+
|
|
199
|
+
- **Start with regex** — even imperfect regex gives you a baseline to improve
|
|
200
|
+
- **Use confidence scoring** to programmatically identify what needs LLM help
|
|
201
|
+
- **Use the cheapest LLM** for validation (Haiku-class models are sufficient)
|
|
202
|
+
- **Never mutate** parsed items — return new instances from cleaning/validation steps
|
|
203
|
+
- **TDD works well** for parsers — write tests for known patterns first, then edge cases
|
|
204
|
+
- **Log metrics** (regex success rate, LLM call count) to track pipeline health
|
|
205
|
+
|
|
206
|
+
## Anti-Patterns to Avoid
|
|
207
|
+
|
|
208
|
+
- Sending all text to an LLM when regex handles 95%+ of cases (expensive and slow)
|
|
209
|
+
- Using regex for free-form, highly variable text (LLM is better here)
|
|
210
|
+
- Skipping confidence scoring and hoping regex "just works"
|
|
211
|
+
- Mutating parsed objects during cleaning/validation steps
|
|
212
|
+
- Not testing edge cases (malformed input, missing fields, encoding issues)
|
|
213
|
+
|
|
214
|
+
## When to Use
|
|
215
|
+
|
|
216
|
+
- Quiz/exam question parsing
|
|
217
|
+
- Form data extraction
|
|
218
|
+
- Invoice/receipt processing
|
|
219
|
+
- Document structure parsing (headers, sections, tables)
|
|
220
|
+
- Any structured text with repeating patterns where cost matters
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: repo-scan
|
|
3
|
+
description: [ECC] Cross-stack source code asset audit — classifies every file, detects embedded third-party libraries, and delivers actionable four-level verdicts per module with interactive HTML reports.
|
|
4
|
+
origin: community
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# repo-scan
|
|
8
|
+
|
|
9
|
+
> Every ecosystem has its own dependency manager, but no tool looks across C++, Android, iOS, and Web to tell you: how much code is actually yours, what's third-party, and what's dead weight.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
- Taking over a large legacy codebase and need a structural overview
|
|
14
|
+
- Before major refactoring — identify what's core, what's duplicate, what's dead
|
|
15
|
+
- Auditing third-party dependencies embedded directly in source (not declared in package managers)
|
|
16
|
+
- Preparing architecture decision records for monorepo reorganization
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Fetch only the pinned commit for reproducibility
|
|
22
|
+
mkdir -p ~/.claude/skills/repo-scan
|
|
23
|
+
git init repo-scan
|
|
24
|
+
cd repo-scan
|
|
25
|
+
git remote add origin https://github.com/haibindev/repo-scan.git
|
|
26
|
+
git fetch --depth 1 origin 2742664
|
|
27
|
+
git checkout --detach FETCH_HEAD
|
|
28
|
+
cp -r . ~/.claude/skills/repo-scan
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> Review the source before installing any agent skill.
|
|
32
|
+
|
|
33
|
+
## Core Capabilities
|
|
34
|
+
|
|
35
|
+
| Capability | Description |
|
|
36
|
+
|---|---|
|
|
37
|
+
| **Cross-stack scanning** | C/C++, Java/Android, iOS (OC/Swift), Web (TS/JS/Vue) in one pass |
|
|
38
|
+
| **File classification** | Every file tagged as project code, third-party, or build artifact |
|
|
39
|
+
| **Library detection** | 50+ known libraries (FFmpeg, Boost, OpenSSL…) with version extraction |
|
|
40
|
+
| **Four-level verdicts** | Core Asset / Extract & Merge / Rebuild / Deprecate |
|
|
41
|
+
| **HTML reports** | Interactive dark-theme pages with drill-down navigation |
|
|
42
|
+
| **Monorepo support** | Hierarchical scanning with summary + sub-project reports |
|
|
43
|
+
|
|
44
|
+
## Analysis Depth Levels
|
|
45
|
+
|
|
46
|
+
| Level | Files Read | Use Case |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `fast` | 1-2 per module | Quick inventory of huge directories |
|
|
49
|
+
| `standard` | 2-5 per module | Default audit with full dependency + architecture checks |
|
|
50
|
+
| `deep` | 5-10 per module | Adds thread safety, memory management, API consistency |
|
|
51
|
+
| `full` | All files | Pre-merge comprehensive review |
|
|
52
|
+
|
|
53
|
+
## How It Works
|
|
54
|
+
|
|
55
|
+
1. **Classify the repo surface**: enumerate files, then tag each as project code, embedded third-party code, or build artifact.
|
|
56
|
+
2. **Detect embedded libraries**: inspect directory names, headers, license files, and version markers to identify bundled dependencies and likely versions.
|
|
57
|
+
3. **Score each module**: group files by module or subsystem, then assign one of the four verdicts based on ownership, duplication, and maintenance cost.
|
|
58
|
+
4. **Highlight structural risks**: call out dead-weight artifacts, duplicated wrappers, outdated vendored code, and modules that should be extracted, rebuilt, or deprecated.
|
|
59
|
+
5. **Produce the report**: return a concise summary plus the interactive HTML output with per-module drill-down so the audit can be reviewed asynchronously.
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
On a 50,000-file C++ monorepo:
|
|
64
|
+
- Found FFmpeg 2.x (2015 vintage) still in production
|
|
65
|
+
- Discovered the same SDK wrapper duplicated 3 times
|
|
66
|
+
- Identified 636 MB of committed Debug/ipch/obj build artifacts
|
|
67
|
+
- Classified: 3 MB project code vs 596 MB third-party
|
|
68
|
+
|
|
69
|
+
## Best Practices
|
|
70
|
+
|
|
71
|
+
- Start with `standard` depth for first-time audits
|
|
72
|
+
- Use `fast` for monorepos with 100+ modules to get a quick inventory
|
|
73
|
+
- Run `deep` incrementally on modules flagged for refactoring
|
|
74
|
+
- Review the cross-module analysis for duplicate detection across sub-projects
|
|
75
|
+
|
|
76
|
+
## Links
|
|
77
|
+
|
|
78
|
+
- [GitHub Repository](https://github.com/haibindev/repo-scan)
|