ultimate-pi 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/harness-debate-plan/SKILL.md +1 -1
- package/.agents/skills/harness-decisions/SKILL.md +1 -2
- package/.agents/skills/harness-governor/SKILL.md +6 -5
- package/.pi/PACKAGING.md +4 -4
- package/.pi/SYSTEM.md +54 -120
- package/.pi/agents/harness/incident-recorder.md +0 -1
- package/.pi/agents/harness/planning/decompose.md +0 -2
- package/.pi/agents/harness/planning/execution-plan-author.md +0 -2
- package/.pi/agents/harness/planning/hypothesis-validator.md +0 -2
- package/.pi/agents/harness/planning/hypothesis.md +0 -2
- package/.pi/agents/harness/planning/implementation-researcher.md +0 -2
- package/.pi/agents/harness/planning/plan-adversary.md +0 -2
- package/.pi/agents/harness/planning/plan-evaluator.md +1 -3
- package/.pi/agents/harness/planning/planning-context.md +0 -2
- package/.pi/agents/harness/planning/review-integrator.md +0 -2
- package/.pi/agents/harness/planning/sprint-contract-auditor.md +0 -2
- package/.pi/agents/harness/planning/stack-researcher.md +0 -2
- package/.pi/agents/harness/reviewing/adversary.md +0 -2
- package/.pi/agents/harness/reviewing/evaluator.md +0 -2
- package/.pi/agents/harness/reviewing/tie-breaker.md +0 -2
- package/.pi/agents/harness/running/executor.md +0 -2
- package/.pi/agents/harness/sentrux-bootstrap.md +0 -1
- package/.pi/agents/harness/sentrux-steward.md +0 -2
- package/.pi/agents/harness/trace-librarian.md +0 -1
- package/.pi/extensions/00-posthog-network-bootstrap.ts +1 -1
- package/.pi/extensions/agt-kill-switch.ts +57 -0
- package/.pi/extensions/agt-prompt-guard.ts +32 -0
- package/.pi/extensions/custom-footer.ts +46 -145
- package/.pi/extensions/custom-header.ts +1 -1
- package/.pi/extensions/custom-system-prompt.ts +1 -1
- package/.pi/extensions/debate-orchestrator.ts +6 -6
- package/.pi/extensions/harness-ask-user.ts +7 -7
- package/.pi/extensions/harness-debate-tools.ts +26 -42
- package/.pi/extensions/harness-lens.ts +94 -0
- package/.pi/extensions/harness-plan-approval.ts +11 -11
- package/.pi/extensions/harness-run-context.ts +1070 -876
- package/.pi/extensions/harness-subagent-governance.ts +8 -0
- package/.pi/extensions/harness-subagent-submit.ts +34 -163
- package/.pi/extensions/harness-subagents.ts +3 -3
- package/.pi/extensions/harness-telemetry.ts +2 -2
- package/.pi/extensions/harness-web-tools.ts +2 -2
- package/.pi/extensions/policy-gate.ts +25 -5
- package/.pi/extensions/sentrux-rules-sync.ts +1 -1
- package/.pi/extensions/subagent-governance.ts +92 -0
- package/.pi/extensions/trace-recorder.ts +1 -1
- package/.pi/extensions/{ultimate-pi-vcc.ts → vcc-compaction.ts} +1 -1
- package/.pi/harness/README.md +6 -2
- package/.pi/harness/agents.manifest.json +22 -25
- package/.pi/harness/agents.policy.yaml +275 -0
- package/.pi/harness/docs/adrs/0030-inhouse-vcc-compaction.md +1 -1
- package/.pi/harness/docs/adrs/0035-plan-phase-review-gate.md +1 -1
- package/.pi/harness/docs/adrs/0045-harness-lens-minimal-contract.md +49 -0
- package/.pi/harness/docs/adrs/0046-agt-policy-engine.md +51 -0
- package/.pi/harness/docs/adrs/0047-agt-layered-security.md +39 -0
- package/.pi/harness/docs/adrs/0048-tool-call-hook-order.md +25 -0
- package/.pi/harness/docs/adrs/0049-agents-policy-manifest.md +36 -0
- package/.pi/harness/docs/adrs/README.md +5 -0
- package/.pi/harness/evolution/README.md +1 -2
- package/.pi/harness/examples/agents.policy.project.yaml +19 -0
- package/.pi/harness/examples/policies/custom-deny-bash.yaml +9 -0
- package/.pi/harness/policies/bash-denylists.yaml +5 -0
- package/.pi/harness/policies/defaults.yaml +51 -0
- package/.pi/harness/policies/orchestrator.yaml +18 -0
- package/.pi/harness/policies/phases.yaml +10 -0
- package/.pi/harness/policies/roles.yaml +5 -0
- package/.pi/harness/policies/web-guard.yaml +5 -0
- package/.pi/harness/policies/workflow-sequences.yaml +9 -0
- package/.pi/harness/sentrux/architecture.manifest.json +26 -4
- package/.pi/harness/specs/observation.schema.json +2 -1
- package/.pi/lib/agents-policy.d.mts +70 -0
- package/.pi/lib/agents-policy.mjs +325 -0
- package/.pi/lib/agents-policy.ts +19 -0
- package/.pi/lib/agt/audit-run-sink.ts +52 -0
- package/.pi/lib/agt/build-evaluation-context.ts +285 -0
- package/.pi/lib/agt/config.ts +28 -0
- package/.pi/lib/agt/delegation.ts +69 -0
- package/.pi/lib/agt/evaluate-policy.ts +56 -0
- package/.pi/lib/agt/identity-registry.ts +41 -0
- package/.pi/lib/agt/index.ts +55 -0
- package/.pi/lib/agt/kill-switch-state.ts +11 -0
- package/.pi/lib/agt/legacy-evaluate.ts +101 -0
- package/.pi/lib/agt/policy-engine.ts +154 -0
- package/.pi/lib/agt/rings.ts +21 -0
- package/.pi/lib/agt/sre-hooks.ts +45 -0
- package/.pi/lib/agt/trust-run-store.ts +26 -0
- package/.pi/lib/agt/workflow-history.ts +29 -0
- package/.pi/lib/agt-governance-active.ts +14 -0
- package/.pi/lib/agt-tool-guard.ts +78 -0
- package/.pi/lib/ask-user/dialog.ts +314 -0
- package/.pi/{extensions/lib → lib}/debate-bus-core.ts +10 -10
- package/.pi/{extensions/lib → lib}/debate-bus-state.ts +1 -1
- package/.pi/{extensions/lib → lib}/extension-load-guard.ts +13 -2
- package/.pi/lib/harness-agt-tool-guard.ts +5 -0
- package/.pi/{extensions/lib → lib}/harness-artifact-gate.ts +1 -1
- package/.pi/lib/harness-debate-core-deps.ts +14 -0
- package/.pi/lib/harness-debate-workflow-deps.ts +43 -0
- package/.pi/lib/harness-lens/.gitattributes +1 -0
- package/.pi/lib/harness-lens/clients/edit-autopatch.ts +88 -0
- package/.pi/lib/harness-lens/clients/file-kinds.ts +380 -0
- package/.pi/lib/harness-lens/clients/file-time.ts +215 -0
- package/.pi/lib/harness-lens/clients/file-utils.ts +484 -0
- package/.pi/lib/harness-lens/clients/format-service.ts +276 -0
- package/.pi/lib/harness-lens/clients/formatters.ts +1000 -0
- package/.pi/lib/harness-lens/clients/git-guard.ts +31 -0
- package/.pi/lib/harness-lens/clients/indent-retarget.ts +90 -0
- package/.pi/lib/harness-lens/clients/installer/index.ts +2368 -0
- package/.pi/lib/harness-lens/clients/latency-logger.ts +80 -0
- package/.pi/lib/harness-lens/clients/lens-config.ts +43 -0
- package/.pi/lib/harness-lens/clients/lens-events.ts +164 -0
- package/.pi/lib/harness-lens/clients/lsp/aggregation.ts +91 -0
- package/.pi/lib/harness-lens/clients/lsp/client.ts +1466 -0
- package/.pi/lib/harness-lens/clients/lsp/config.ts +216 -0
- package/.pi/lib/harness-lens/clients/lsp/edits.ts +297 -0
- package/.pi/lib/harness-lens/clients/lsp/index.ts +1355 -0
- package/.pi/lib/harness-lens/clients/lsp/interactive-install.ts +424 -0
- package/.pi/lib/harness-lens/clients/lsp/language.ts +223 -0
- package/.pi/lib/harness-lens/clients/lsp/launch.ts +939 -0
- package/.pi/lib/harness-lens/clients/lsp/lsp-index.ts +11 -0
- package/.pi/lib/harness-lens/clients/lsp/path-utils.ts +12 -0
- package/.pi/lib/harness-lens/clients/lsp/server-strategies.ts +81 -0
- package/.pi/lib/harness-lens/clients/lsp/server.ts +1971 -0
- package/.pi/lib/harness-lens/clients/path-utils.ts +182 -0
- package/.pi/lib/harness-lens/clients/pipeline.ts +360 -0
- package/.pi/lib/harness-lens/clients/project-profile.ts +117 -0
- package/.pi/lib/harness-lens/clients/runtime-agent-end.ts +112 -0
- package/.pi/lib/harness-lens/clients/runtime-config.ts +33 -0
- package/.pi/lib/harness-lens/clients/runtime-coordinator.ts +186 -0
- package/.pi/lib/harness-lens/clients/runtime-tool-result.ts +171 -0
- package/.pi/lib/harness-lens/clients/safe-spawn.ts +339 -0
- package/.pi/lib/harness-lens/clients/secrets-scanner.ts +214 -0
- package/.pi/lib/harness-lens/clients/tool-policy.ts +2072 -0
- package/.pi/lib/harness-lens/clients/types.ts +59 -0
- package/.pi/lib/harness-lens/clients/widget-state.ts +283 -0
- package/.pi/lib/harness-lens/index.ts +532 -0
- package/.pi/lib/harness-lens/tools/lsp-diagnostics.ts +706 -0
- package/.pi/lib/harness-lens/tools/lsp-navigation.ts +1246 -0
- package/.pi/{extensions/lib → lib}/harness-posthog.ts +3 -0
- package/.pi/lib/harness-run-context-responses.ts +9 -0
- package/.pi/lib/harness-run-context.ts +0 -2
- package/.pi/{extensions/lib/spawn-policy.ts → lib/harness-spawn-policy.ts} +1 -0
- package/.pi/{extensions/lib → lib}/harness-spawn-topology.ts +1 -1
- package/.pi/lib/harness-subagent-auth.ts +51 -0
- package/.pi/{extensions/lib → lib}/harness-subagent-precheck.ts +10 -7
- package/.pi/{extensions/lib → lib}/harness-subagent-submit-pipeline.ts +3 -3
- package/.pi/lib/harness-subagent-submit-register.ts +163 -0
- package/.pi/{extensions/lib → lib}/harness-subagent-submit-registry.ts +1 -37
- package/.pi/{extensions/lib → lib}/harness-subagents-bridge.ts +53 -14
- package/.pi/{extensions/lib → lib}/harness-subprocess-bootstrap.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-approval/create-plan.ts +2 -2
- package/.pi/{extensions/lib → lib}/plan-approval/format-plan.ts +2 -2
- package/.pi/{extensions/lib → lib}/plan-approval/plan-review.ts +162 -201
- package/.pi/{extensions/lib → lib}/plan-approval/render.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-approval/resolve-disk.ts +2 -2
- package/.pi/{extensions/lib → lib}/plan-approval/types.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-approval/validate.ts +3 -3
- package/.pi/{extensions/lib → lib}/plan-debate-envelope.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-debate-gate.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-debate-lane.ts +1 -4
- package/.pi/{extensions/lib → lib}/plan-messenger.ts +1 -1
- package/.pi/prompts/harness-plan.md +1 -1
- package/.pi/prompts/harness-setup.md +37 -64
- package/.pi/scripts/README.md +2 -5
- package/.pi/scripts/generate-agents-policy-yaml.mjs +148 -0
- package/.pi/scripts/harness-agents-manifest.mjs +60 -3
- package/.pi/scripts/harness-agt-doctor.ts +36 -0
- package/.pi/scripts/harness-cli-verify.sh +9 -2
- package/.pi/scripts/harness-verify.mjs +113 -39
- package/.pi/scripts/harness-web-policy-guard.mjs +2 -2
- package/.pi/scripts/validate-plan-dag.mjs +65 -74
- package/.pi/scripts/vendor-pi-vcc-settings.stub.ts +2 -2
- package/.pi/scripts/vendor-sync-pi-vcc.sh +1 -1
- package/.pi/skills/architecture/broker-domain/SKILL.md +65 -0
- package/.pi/skills/architecture/cqrs/SKILL.md +63 -0
- package/.pi/skills/architecture/event-driven/SKILL.md +60 -0
- package/.pi/skills/architecture/hexagonal-ports-adapters/SKILL.md +66 -0
- package/.pi/skills/architecture/layered/SKILL.md +68 -0
- package/.pi/skills/architecture/microkernel/SKILL.md +62 -0
- package/.pi/skills/architecture/microservices/SKILL.md +64 -0
- package/.pi/skills/architecture/modular-monolith/SKILL.md +65 -0
- package/.pi/skills/architecture/orchestration-driven-soa/SKILL.md +61 -0
- package/.pi/skills/architecture/pipeline/SKILL.md +63 -0
- package/.pi/skills/architecture/service-based/SKILL.md +64 -0
- package/.pi/skills/architecture/service-mesh/SKILL.md +60 -0
- package/.pi/skills/architecture/space-based/SKILL.md +60 -0
- package/.pi/skills/ast-grep/SKILL.md +40 -321
- package/.pi/skills/delivery/debugging-discipline/SKILL.md +36 -0
- package/.pi/skills/delivery/documentation-update/SKILL.md +33 -0
- package/.pi/skills/delivery/requirements-to-implementation/SKILL.md +34 -0
- package/.pi/skills/delivery/risk-based-verification/SKILL.md +43 -0
- package/.pi/skills/delivery/tradeoff-analysis/SKILL.md +34 -0
- package/.pi/skills/engineering/api-contract-design/SKILL.md +38 -0
- package/.pi/skills/engineering/cohesion-coupling/SKILL.md +43 -0
- package/.pi/skills/engineering/complexity-control/SKILL.md +31 -0
- package/.pi/skills/engineering/defensive-programming/SKILL.md +38 -0
- package/.pi/skills/engineering/dependency-management/SKILL.md +29 -0
- package/.pi/skills/engineering/domain-modeling/SKILL.md +32 -0
- package/.pi/skills/engineering/error-handling/SKILL.md +37 -0
- package/.pi/skills/engineering/legacy-code-seams/SKILL.md +35 -0
- package/.pi/skills/engineering/naming-and-intent/SKILL.md +29 -0
- package/.pi/skills/engineering/refactoring-safe-evolution/SKILL.md +35 -0
- package/.pi/skills/engineering/routine-function-design/SKILL.md +34 -0
- package/.pi/skills/engineering/small-change-discipline/SKILL.md +35 -0
- package/.pi/skills/lsp-navigation/SKILL.md +89 -0
- package/.pi/skills/quality/code-review-self-check/SKILL.md +35 -0
- package/.pi/skills/quality/privacy-data-handling/SKILL.md +26 -0
- package/.pi/skills/quality/security-review/SKILL.md +34 -0
- package/.pi/skills/quality/test-strategy/SKILL.md +33 -0
- package/.pi/skills/quality/testability-design/SKILL.md +33 -0
- package/.pi/skills/systems/concurrency-safety/SKILL.md +32 -0
- package/.pi/skills/systems/data-modeling-migrations/SKILL.md +31 -0
- package/.pi/skills/systems/observability-instrumentation/SKILL.md +32 -0
- package/.pi/skills/systems/performance-measurement/SKILL.md +35 -0
- package/.pi/skills/systems/reliability-design/SKILL.md +32 -0
- package/.sentrux/rules.toml +20 -4
- package/AGENTS.md +5 -0
- package/CHANGELOG.md +14 -0
- package/README.md +3 -12
- package/THIRD_PARTY_NOTICES.md +12 -21
- package/package.json +15 -7
- package/vendor/pi-subagents/src/agents.ts +45 -1
- package/vendor/pi-subagents/src/subagents.ts +866 -811
- package/vendor/pi-vcc/src/core/brief.ts +68 -99
- package/vendor/pi-vcc/src/core/settings.ts +2 -2
- package/.agents/skills/caveman/SKILL.md +0 -67
- package/.pi/agents/harness/meta-optimizer.md +0 -36
- package/.pi/extensions/lib/ask-user/dialog.ts +0 -260
- package/.pi/extensions/lib/harness-subagent-auth.ts +0 -207
- package/.pi/extensions/lib/harness-subagent-policy.ts +0 -236
- package/.pi/extensions/pi-model-router-harness.ts +0 -42
- package/.pi/harness/evolution/meta-optimizer.mjs +0 -99
- package/.pi/harness/specs/router-tuning-proposal.schema.json +0 -114
- package/.pi/model-router.example.json +0 -36
- package/.pi/prompts/harness-critic.md +0 -10
- package/.pi/prompts/harness-eval.md +0 -10
- package/.pi/prompts/harness-router-tune.md +0 -52
- package/.pi/scripts/harness-generate-model-router.mjs +0 -327
- package/.pi/scripts/harness-model-router-routing.test.mjs +0 -97
- package/.pi/scripts/harness-sync-model-router.mjs +0 -97
- package/.pi/scripts/vendor-sync-pi-model-router.sh +0 -47
- package/vendor/pi-model-router/.prettierignore +0 -4
- package/vendor/pi-model-router/.prettierrc +0 -5
- package/vendor/pi-model-router/AGENTS.md +0 -39
- package/vendor/pi-model-router/LICENSE +0 -21
- package/vendor/pi-model-router/README.md +0 -99
- package/vendor/pi-model-router/UPSTREAM_PIN.md +0 -10
- package/vendor/pi-model-router/docs/ARCHITECTURE.md +0 -54
- package/vendor/pi-model-router/extensions/commands.ts +0 -720
- package/vendor/pi-model-router/extensions/config.ts +0 -348
- package/vendor/pi-model-router/extensions/constants.ts +0 -1
- package/vendor/pi-model-router/extensions/index.ts +0 -478
- package/vendor/pi-model-router/extensions/provider.ts +0 -580
- package/vendor/pi-model-router/extensions/routing.ts +0 -564
- package/vendor/pi-model-router/extensions/state.ts +0 -52
- package/vendor/pi-model-router/extensions/types.ts +0 -95
- package/vendor/pi-model-router/extensions/ui.ts +0 -144
- package/vendor/pi-model-router/model-router.example.json +0 -48
- package/vendor/pi-model-router/package.json +0 -48
- package/vendor/pi-model-router/tsconfig.json +0 -16
- /package/.pi/{prompts → harness/docs}/planning-rubrics.md +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/fallback.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/render.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/schema.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/types.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/validate-core.mjs +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/validate.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-cocoindex-refresh.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-paths.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-spawn-budget.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-vcc-settings.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-web/run-cli.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-approval/dialog.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-approval/schema.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-approval-readiness.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-eligibility.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-focus.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-id.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-lanes.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-round-status.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-write-guard.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-review-gate.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-review-integrator-rules.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-scope-guard.ts +0 -0
- /package/.pi/{extensions/lib → lib}/posthog-client.ts +0 -0
- /package/.pi/{extensions/lib → lib}/posthog-node.d.ts +0 -0
|
@@ -1,354 +1,73 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ast-grep
|
|
3
|
-
description: "Structural code search
|
|
3
|
+
description: "Structural code search and replacement using the sg CLI. Use for function calls, imports, class/method definitions, call sites, and codemods. Prefer LSP for definitions/references/types; use sg for structural patterns; reserve grep for exact literals, comments, URLs, or non-code files."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- Bash(sg *)
|
|
6
6
|
- Bash(npm install -g @ast-grep/cli)
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# ast-grep: Structural Code Search
|
|
9
|
+
# ast-grep: Structural Code Search (sg CLI)
|
|
10
10
|
|
|
11
|
-
Search code by structure, not text.
|
|
11
|
+
Search code by structure, not text. ast-grep parses code into ASTs and matches code shape.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**Harness policy:** use the **`sg` shell CLI only**. harness-lens does not expose `ast_grep_search` / `ast_grep_replace` pi tools.
|
|
14
|
+
|
|
15
|
+
## Install CLI
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
18
|
npm install -g @ast-grep/cli
|
|
19
|
+
sg --version
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
`/harness-setup` installs global `sg` on the machine. That is a harness dev tool — it does not imply every target repo uses ast-grep rules.
|
|
20
23
|
|
|
21
24
|
## When to Use
|
|
22
25
|
|
|
23
26
|
| Task | Tool | Why |
|
|
24
27
|
|------|------|-----|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
| Find
|
|
28
|
-
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## Pattern Syntax
|
|
33
|
-
|
|
34
|
-
Patterns match code structure. Write code like you'd write it — `sg` parses it as AST.
|
|
35
|
-
|
|
36
|
-
### Metavariables
|
|
37
|
-
|
|
38
|
-
Prefix with `$` to match any expression, type, or identifier:
|
|
39
|
-
|
|
40
|
-
| Pattern | Matches |
|
|
41
|
-
|---------|---------|
|
|
42
|
-
| `$X` | Any single expression, identifier, or type |
|
|
43
|
-
| `$NAME` | Captures and names the match (use in rewrites) |
|
|
44
|
-
| `...` | Matches zero or more of anything (statements, args, etc.) |
|
|
45
|
-
| `$$...ARGS` | Captures multiple items as a list |
|
|
28
|
+
| Definitions, references, hover/types, symbol navigation | LSP (`lsp_navigation`) | Language server code intelligence |
|
|
29
|
+
| Type/error checks | LSP (`lsp_diagnostics`) | Active diagnostics |
|
|
30
|
+
| Find code by structure/pattern | `sg -p 'pattern'` | AST-aware matching |
|
|
31
|
+
| Safe structural replacement/codemod | `sg --rewrite` | Shape-preserving rewrites |
|
|
32
|
+
| Find code by concept/meaning | graphify / `ccc search` | Architecture vs implementation chunks |
|
|
33
|
+
| Architecture gate at review | Sentrux | Ship/promotion quality |
|
|
34
|
+
| Find exact literal string | `grep` | Non-code, comments, logs, generated text |
|
|
46
35
|
|
|
47
|
-
|
|
36
|
+
## Golden Rules
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function handle($PARAMS) { ... }
|
|
55
|
-
|
|
56
|
-
# Any import from `react`
|
|
57
|
-
import $X from 'react'
|
|
58
|
-
|
|
59
|
-
# Any method call on `console`
|
|
60
|
-
console.$METHOD($ARGS)
|
|
61
|
-
|
|
62
|
-
# Any try-catch block
|
|
63
|
-
try { ... } catch ($ERR) { ... }
|
|
64
|
-
|
|
65
|
-
# Any class extending something
|
|
66
|
-
class $NAME extends $BASE { ... }
|
|
67
|
-
```
|
|
38
|
+
1. **Be specific** — `fetchMetrics($ARGS)` or `fetchMetrics($$$ARGS)`, not bare `fetchMetrics`.
|
|
39
|
+
2. **Scope it** — pass a directory or file to `sg` whenever possible.
|
|
40
|
+
3. **Retry once on zero matches** — simplify the pattern; then grep only if still empty.
|
|
41
|
+
4. **Dry-run replacements** — use `--dry-run` before applying rewrites.
|
|
42
|
+
5. **Valid code patterns** — `function $NAME($$$ARGS) { $$$BODY }`, not incomplete fragments.
|
|
68
43
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`sg` auto-detects language from file extensions. Override explicitly:
|
|
44
|
+
## CLI Quick Reference
|
|
72
45
|
|
|
73
46
|
```bash
|
|
74
|
-
sg -p '
|
|
75
|
-
sg -p '
|
|
76
|
-
sg -p 'pattern'
|
|
77
|
-
sg
|
|
78
|
-
sg -p 'pattern' -l java # Java
|
|
79
|
-
sg -p 'pattern' -l cpp # C++
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
Supported languages: TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, C#, Ruby, Swift, Kotlin, Scala, PHP, HTML, CSS, JSON, YAML, and more (full tree-sitter grammar set).
|
|
83
|
-
|
|
84
|
-
## Quick Reference
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Search by pattern (auto-detects language)
|
|
88
|
-
sg -p 'pattern'
|
|
89
|
-
|
|
90
|
-
# Search with language explicit
|
|
91
|
-
sg -p 'pattern' -l ts
|
|
92
|
-
|
|
93
|
-
# Search specific directory
|
|
94
|
-
sg -p 'pattern' src/
|
|
95
|
-
|
|
96
|
-
# Search with glob filter
|
|
97
|
-
sg -p 'pattern' --include '*.ts'
|
|
98
|
-
|
|
99
|
-
# Show context lines
|
|
100
|
-
sg -p 'pattern' -A 3 # 3 lines after
|
|
101
|
-
sg -p 'pattern' -B 3 # 3 lines before
|
|
102
|
-
sg -p 'pattern' -C 3 # 3 lines before and after
|
|
103
|
-
|
|
104
|
-
# List matching files only
|
|
105
|
-
sg -p 'pattern' --json | jq -r '.[].file' | sort -u
|
|
106
|
-
|
|
107
|
-
# Count matches
|
|
108
|
-
sg -p 'pattern' | wc -l
|
|
109
|
-
|
|
110
|
-
# Interactive selection (fuzzy picker)
|
|
111
|
-
sg -p 'pattern' --interactive
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Common Patterns
|
|
115
|
-
|
|
116
|
-
### Find all call sites of a function
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
# Who calls `processPayment`?
|
|
120
|
-
sg -p 'processPayment($ARGS)'
|
|
121
|
-
|
|
122
|
-
# Who calls `console.log`?
|
|
123
|
-
sg -p 'console.log($ARGS)'
|
|
124
|
-
|
|
125
|
-
# Who calls any method on `db`?
|
|
126
|
-
sg -p 'db.$METHOD($ARGS)'
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Find function/method definitions
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
# All async function definitions
|
|
133
|
-
sg -p 'async function $NAME($PARAMS) { ... }'
|
|
134
|
-
|
|
135
|
-
# All method definitions in a class (TS)
|
|
136
|
-
sg -p '$VISIBILITY $NAME($PARAMS) { ... }' -l ts
|
|
137
|
-
|
|
138
|
-
# All arrow functions assigned to const
|
|
139
|
-
sg -p 'const $NAME = ($PARAMS) => $BODY'
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Find imports
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
# Default import from specific module
|
|
146
|
-
sg -p 'import $X from "lodash"'
|
|
147
|
-
|
|
148
|
-
# Named imports
|
|
149
|
-
sg -p 'import { $NAMES } from "react"'
|
|
150
|
-
|
|
151
|
-
# Any import from a module
|
|
152
|
-
sg -p 'import * from "axios"'
|
|
153
|
-
|
|
154
|
-
# Dynamic imports
|
|
155
|
-
sg -p 'import($MODULE)'
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Find class definitions
|
|
159
|
-
|
|
160
|
-
```bash
|
|
161
|
-
# All class definitions
|
|
162
|
-
sg -p 'class $NAME { ... }'
|
|
163
|
-
|
|
164
|
-
# Classes extending a specific base
|
|
165
|
-
sg -p 'class $NAME extends Error { ... }'
|
|
166
|
-
|
|
167
|
-
# Classes with specific decorator
|
|
168
|
-
sg -p '@$DECORATOR(...) class $NAME { ... }'
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Find specific patterns
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
# All try-catch blocks
|
|
175
|
-
sg -p 'try { ... } catch ($E) { ... }'
|
|
176
|
-
|
|
177
|
-
# All useEffect calls (React)
|
|
178
|
-
sg -p 'useEffect(() => { ... }, [$DEPS])'
|
|
179
|
-
|
|
180
|
-
# All await expressions
|
|
181
|
-
sg -p 'await $EXPR'
|
|
182
|
-
|
|
183
|
-
# All error throws
|
|
184
|
-
sg -p 'throw new $ERR($ARGS)'
|
|
185
|
-
|
|
186
|
-
# All object destructuring
|
|
187
|
-
sg -p 'const { $PROPS } = $OBJ'
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Find and replace (codemods)
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
# Preview rewrite (dry run)
|
|
194
|
-
sg -p 'oldPattern($X)' --rewrite 'newPattern($X)' --dry-run
|
|
195
|
-
|
|
196
|
-
# Execute rewrite
|
|
197
|
-
sg -p 'oldPattern($X)' --rewrite 'newPattern($X)'
|
|
198
|
-
|
|
199
|
-
# Rewrite with language explicit
|
|
200
|
-
sg -p 'console.log($MSG)' --rewrite 'logger.info($MSG)' -l ts
|
|
201
|
-
|
|
202
|
-
# Rewrite across project using rules (see sgconfig.yml below)
|
|
203
|
-
sg scan
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
## Project Rules with sgconfig.yml
|
|
207
|
-
|
|
208
|
-
For project-wide pattern enforcement, create `sgconfig.yml` at project root:
|
|
209
|
-
|
|
210
|
-
```yaml
|
|
211
|
-
# sgconfig.yml
|
|
212
|
-
ruleDirs:
|
|
213
|
-
- .sg/rules
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
Then create rule files in `.sg/rules/`:
|
|
217
|
-
|
|
218
|
-
```yaml
|
|
219
|
-
# .sg/rules/no-console-log.yml
|
|
220
|
-
id: no-console-log
|
|
221
|
-
language: TypeScript
|
|
222
|
-
severity: warning
|
|
223
|
-
rule:
|
|
224
|
-
pattern: console.log($ARGS)
|
|
225
|
-
fix: logger.debug($ARGS)
|
|
226
|
-
message: "Use logger.debug instead of console.log"
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
```yaml
|
|
230
|
-
# .sg/rules/require-await.yml
|
|
231
|
-
id: no-floating-promises
|
|
232
|
-
language: TypeScript
|
|
233
|
-
severity: error
|
|
234
|
-
rule:
|
|
235
|
-
pattern: $FUNC($ARGS)
|
|
236
|
-
not:
|
|
237
|
-
pattern: await $FUNC($ARGS)
|
|
238
|
-
inside:
|
|
239
|
-
kind: function_declaration
|
|
240
|
-
stopBy: end
|
|
241
|
-
message: "Promise returned by $FUNC is not awaited"
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
```yaml
|
|
245
|
-
# .sg/rules/no-any.yml
|
|
246
|
-
id: no-explicit-any
|
|
247
|
-
language: TypeScript
|
|
248
|
-
severity: warning
|
|
249
|
-
rule:
|
|
250
|
-
pattern: any
|
|
251
|
-
message: "Avoid using 'any' type — use unknown or a specific type"
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Run rules:
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
# Scan all rules in sgconfig.yml
|
|
258
|
-
sg scan
|
|
259
|
-
|
|
260
|
-
# Scan specific rule
|
|
261
|
-
sg scan --rule .sg/rules/no-console-log.yml
|
|
262
|
-
|
|
263
|
-
# Scan specific directory
|
|
264
|
-
sg scan src/
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### Rule Structure
|
|
268
|
-
|
|
269
|
-
Every rule file is YAML with these fields:
|
|
270
|
-
|
|
271
|
-
| Field | Required | Purpose |
|
|
272
|
-
|-------|----------|---------|
|
|
273
|
-
| `id` | Yes | Unique rule identifier (kebab-case) |
|
|
274
|
-
| `language` | Yes | Language to match (TypeScript, Python, Go, etc.) |
|
|
275
|
-
| `severity` | Yes | `error`, `warning`, `hint`, `info` |
|
|
276
|
-
| `rule` | Yes | The pattern to match (supports `pattern`, `not`, `inside`, `has`, `follows`, `all`, `any`) |
|
|
277
|
-
| `message` | Yes | Human-readable explanation |
|
|
278
|
-
| `fix` | No | Rewrite template (uses same metavariables) |
|
|
279
|
-
|
|
280
|
-
### Composite Rule Matchers
|
|
281
|
-
|
|
282
|
-
```yaml
|
|
283
|
-
# Match ALL conditions
|
|
284
|
-
rule:
|
|
285
|
-
all:
|
|
286
|
-
- pattern: console.log($X)
|
|
287
|
-
- inside:
|
|
288
|
-
kind: function_declaration
|
|
289
|
-
|
|
290
|
-
# Match ANY condition
|
|
291
|
-
rule:
|
|
292
|
-
any:
|
|
293
|
-
- pattern: console.log($X)
|
|
294
|
-
- pattern: console.warn($X)
|
|
295
|
-
|
|
296
|
-
# Exclude matches
|
|
297
|
-
rule:
|
|
298
|
-
pattern: fetch($URL)
|
|
299
|
-
not:
|
|
300
|
-
pattern: fetch($URL, { init: $INIT })
|
|
301
|
-
|
|
302
|
-
# Must be inside specific AST node
|
|
303
|
-
rule:
|
|
304
|
-
pattern: $CALL($ARGS)
|
|
305
|
-
inside:
|
|
306
|
-
kind: try_statement
|
|
307
|
-
|
|
308
|
-
# Must follow another pattern
|
|
309
|
-
rule:
|
|
310
|
-
pattern: $X.close()
|
|
311
|
-
follows:
|
|
312
|
-
pattern: $X.open()
|
|
47
|
+
sg -p 'console.log($$$ARGS)' -l ts src/
|
|
48
|
+
sg -p 'import { $NAMES } from $PATH' -l go
|
|
49
|
+
sg -p 'pattern' --rewrite 'replacement' --dry-run
|
|
50
|
+
sg scan # only when the target repo defines sg rules (not a harness default)
|
|
313
51
|
```
|
|
314
52
|
|
|
315
53
|
## Search Decision Flow
|
|
316
54
|
|
|
317
|
-
```
|
|
55
|
+
```text
|
|
318
56
|
Need to find code
|
|
319
|
-
├─
|
|
320
|
-
├─
|
|
321
|
-
├─
|
|
322
|
-
├─
|
|
323
|
-
├─
|
|
324
|
-
|
|
57
|
+
├─ Definition, references, type, symbol? → lsp_navigation
|
|
58
|
+
├─ Diagnostics? → lsp_diagnostics
|
|
59
|
+
├─ Structural pattern? → sg -p 'pattern'
|
|
60
|
+
├─ Rewrite/codemod? → sg --rewrite
|
|
61
|
+
├─ Conceptual search? → graphify query or ccc search
|
|
62
|
+
├─ Architecture gate? → Sentrux
|
|
63
|
+
└─ Exact literal in logs/text? → grep
|
|
325
64
|
```
|
|
326
65
|
|
|
327
|
-
## Output Formats
|
|
328
|
-
|
|
329
|
-
```bash
|
|
330
|
-
# Default (grep-compatible): file:line:column: match
|
|
331
|
-
sg -p 'pattern'
|
|
332
|
-
|
|
333
|
-
# JSON (for piping/automation)
|
|
334
|
-
sg -p 'pattern' --json
|
|
335
|
-
|
|
336
|
-
# Only file paths (deduplicated)
|
|
337
|
-
sg -p 'pattern' --json | jq -r '.[].file' | sort -u
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
## Tips
|
|
341
|
-
|
|
342
|
-
- **Metavariables are greedy by default.** `$X` matches the smallest valid AST node. Use `$$$X` to match multiple nodes.
|
|
343
|
-
- **`...` matches zero or more.** Inside function body `{ ... }` matches any statements. In call args `fn(...)` matches any number of arguments.
|
|
344
|
-
- **Pattern must be valid code for the target language.** `sg` parses the pattern itself as AST.
|
|
345
|
-
- **Use `--json` for automation.** Parse results programmatically instead of grepping output.
|
|
346
|
-
- **Combine with find for scoped searches.** `find src/ -name '*.ts' -exec sg -p 'pattern' {} +`
|
|
347
|
-
- **Rules compose.** Multiple rules in `sgconfig.yml` run together with `sg scan`.
|
|
348
|
-
|
|
349
66
|
## Integration with Pi Workflow
|
|
350
67
|
|
|
351
|
-
1. **
|
|
352
|
-
2. **
|
|
353
|
-
3. **
|
|
354
|
-
4. **
|
|
68
|
+
1. **Graph before grep** — graphify for architecture first.
|
|
69
|
+
2. **LSP before sg for code intelligence** — definitions, references, types.
|
|
70
|
+
3. **sg before grep on code** — structural patterns use AST matching.
|
|
71
|
+
4. **Project rules live in the target repo** — do not assume `.sg/rules/` from harness setup; Sentrux + project linters own gates.
|
|
72
|
+
|
|
73
|
+
Debug patterns: https://ast-grep.github.io/playground.html
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: debugging-discipline
|
|
3
|
+
description: Debug systematically instead of guessing. Use when fixing bugs, failing tests, flaky behavior, runtime errors, regressions, or unexpected output. Guides reproduction, isolation, hypotheses, evidence, one-variable changes, root cause, and regression tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging Discipline
|
|
7
|
+
|
|
8
|
+
Use this skill for bug-fix tasks and failing verification.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Reproduce or precisely describe the failure.
|
|
13
|
+
2. Capture the expected behavior and actual behavior.
|
|
14
|
+
3. Identify the smallest failing path or input.
|
|
15
|
+
4. Form one hypothesis from evidence.
|
|
16
|
+
5. Inspect code/data/logs that can confirm or reject the hypothesis.
|
|
17
|
+
6. Change one variable at a time.
|
|
18
|
+
7. Fix root cause, not just the visible symptom.
|
|
19
|
+
8. Add a regression test or equivalent guard.
|
|
20
|
+
9. Re-run the failing check and relevant adjacent checks.
|
|
21
|
+
|
|
22
|
+
## Evidence to collect
|
|
23
|
+
|
|
24
|
+
- failing assertion or error
|
|
25
|
+
- inputs and state
|
|
26
|
+
- recent changes
|
|
27
|
+
- boundary/edge conditions
|
|
28
|
+
- logs with sensitive data redacted
|
|
29
|
+
- dependency/environment differences
|
|
30
|
+
|
|
31
|
+
## Avoid
|
|
32
|
+
|
|
33
|
+
- Random edits before reproduction.
|
|
34
|
+
- Explaining away failures without evidence.
|
|
35
|
+
- Masking errors by broad catch/ignore logic.
|
|
36
|
+
- Declaring fixed without rerunning the failing path.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-update
|
|
3
|
+
description: Update documentation only where it helps future work. Use when behavior, setup, contracts, commands, architecture decisions, operational procedures, or user-facing workflows change. Avoids redundant comments while capturing decisions, invariants, examples, and caveats near the relevant surface.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Documentation Update
|
|
7
|
+
|
|
8
|
+
Use this skill when code changes affect how people or agents should use, operate, or maintain the system.
|
|
9
|
+
|
|
10
|
+
## What to document
|
|
11
|
+
|
|
12
|
+
- public contracts and compatibility notes
|
|
13
|
+
- behavior changes and examples
|
|
14
|
+
- setup/configuration changes
|
|
15
|
+
- operational caveats and failure modes
|
|
16
|
+
- invariants not obvious from code
|
|
17
|
+
- design decisions and rejected alternatives
|
|
18
|
+
- migration or rollback procedures
|
|
19
|
+
|
|
20
|
+
## Workflow
|
|
21
|
+
|
|
22
|
+
1. Identify who needs the documentation: user, maintainer, operator, integrator, or future agent.
|
|
23
|
+
2. Update the nearest authoritative doc rather than creating duplicates.
|
|
24
|
+
3. Keep examples current and minimal.
|
|
25
|
+
4. Remove or correct stale docs when behavior changes.
|
|
26
|
+
5. Prefer comments for local non-obvious why; prefer docs for broader usage or process.
|
|
27
|
+
6. Verify links, commands, and paths when practical.
|
|
28
|
+
|
|
29
|
+
## Avoid
|
|
30
|
+
|
|
31
|
+
- Comments that merely restate obvious code.
|
|
32
|
+
- New docs that duplicate existing sources of truth.
|
|
33
|
+
- Documentation promises not enforced by tests or code.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: requirements-to-implementation
|
|
3
|
+
description: Translate vague or high-level requests into safe implementation steps. Use before coding features, bug fixes, refactors, or ambiguous tasks. Extracts requirements, constraints, done criteria, non-goals, risk, and the smallest viable implementation path.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Requirements to Implementation
|
|
7
|
+
|
|
8
|
+
Use this skill to prevent solving the wrong problem.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Restate the user objective in concrete behavior terms.
|
|
13
|
+
2. Separate explicit requirements from assumptions.
|
|
14
|
+
3. Inspect repo conventions and relevant existing behavior before choosing an approach.
|
|
15
|
+
4. Identify constraints: compatibility, data, security, performance, architecture, tests, and delivery risk.
|
|
16
|
+
5. Define done criteria and non-goals.
|
|
17
|
+
6. Pick the smallest implementation path that satisfies the request.
|
|
18
|
+
7. Ask the user when scope, risk, destructive action, or irreversible behavior is ambiguous.
|
|
19
|
+
|
|
20
|
+
## Implementation prompt
|
|
21
|
+
|
|
22
|
+
Before editing, answer:
|
|
23
|
+
|
|
24
|
+
- What behavior changes?
|
|
25
|
+
- What behavior must not change?
|
|
26
|
+
- Which files/contracts are likely affected?
|
|
27
|
+
- What verification proves completion?
|
|
28
|
+
- What would be overreach?
|
|
29
|
+
|
|
30
|
+
## Avoid
|
|
31
|
+
|
|
32
|
+
- Treating examples as exhaustive requirements without checking.
|
|
33
|
+
- Inventing product behavior not requested or present in code.
|
|
34
|
+
- Starting with a broad redesign when a local change suffices.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: risk-based-verification
|
|
3
|
+
description: Match verification depth to change risk. Use after code, test, config, dependency, data, or docs changes. Helps agents choose targeted checks for low risk, broader checks for medium/high risk, and report unverified residual risk clearly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Risk-Based Verification
|
|
7
|
+
|
|
8
|
+
Use this skill to verify enough without wasting effort or claiming false confidence.
|
|
9
|
+
|
|
10
|
+
## Risk levels
|
|
11
|
+
|
|
12
|
+
Low risk:
|
|
13
|
+
- small local change
|
|
14
|
+
- no public contract or data change
|
|
15
|
+
- existing tests cover area
|
|
16
|
+
- reversible
|
|
17
|
+
|
|
18
|
+
Medium risk:
|
|
19
|
+
- multiple files or boundaries
|
|
20
|
+
- new branch/error path
|
|
21
|
+
- test coverage uncertain
|
|
22
|
+
- behavior visible to users or other modules
|
|
23
|
+
|
|
24
|
+
High risk:
|
|
25
|
+
- data migration or destructive operation
|
|
26
|
+
- security/privacy/auth change
|
|
27
|
+
- dependency/runtime upgrade
|
|
28
|
+
- concurrency/distributed behavior
|
|
29
|
+
- public contract or compatibility change
|
|
30
|
+
|
|
31
|
+
## Verification choices
|
|
32
|
+
|
|
33
|
+
- Low: targeted unit test, focused lint/type/build check, or direct script/example.
|
|
34
|
+
- Medium: affected test suite, integration/contract check, diff review, edge-case tests.
|
|
35
|
+
- High: broad test suite, migration/rollback validation, security review, performance check, manual approval when needed.
|
|
36
|
+
|
|
37
|
+
## Final report
|
|
38
|
+
|
|
39
|
+
Always state:
|
|
40
|
+
|
|
41
|
+
- checks run
|
|
42
|
+
- checks not run
|
|
43
|
+
- why verification is sufficient or what risk remains
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tradeoff-analysis
|
|
3
|
+
description: Make engineering tradeoffs explicit before choosing an implementation. Use when multiple viable approaches exist or when simplicity, maintainability, performance, reliability, compatibility, security, and delivery speed conflict. Chooses the least-worst option with rationale.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tradeoff Analysis
|
|
7
|
+
|
|
8
|
+
Use this skill when there is no single obviously best approach.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. State the decision to make.
|
|
13
|
+
2. List forces: correctness, simplicity, maintainability, performance, reliability, scalability, security, compatibility, cost, delivery speed, and operability.
|
|
14
|
+
3. Identify two or three realistic options.
|
|
15
|
+
4. Compare each option against the forces and project constraints.
|
|
16
|
+
5. Choose the least-worst option for the current context.
|
|
17
|
+
6. Record why rejected options were not chosen when the decision matters.
|
|
18
|
+
7. Keep the implementation aligned with the chosen tradeoff.
|
|
19
|
+
|
|
20
|
+
## Output shape
|
|
21
|
+
|
|
22
|
+
- Decision:
|
|
23
|
+
- Constraints:
|
|
24
|
+
- Options:
|
|
25
|
+
- Chosen approach:
|
|
26
|
+
- Why:
|
|
27
|
+
- Risks:
|
|
28
|
+
- Verification:
|
|
29
|
+
|
|
30
|
+
## Avoid
|
|
31
|
+
|
|
32
|
+
- Generic best-practice claims without project context.
|
|
33
|
+
- Optimizing for future scale without evidence.
|
|
34
|
+
- Choosing complexity because it feels more professional.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-contract-design
|
|
3
|
+
description: Design stable contracts for modules, services, commands, events, plugins, CLIs, and public interfaces. Use when adding or changing any boundary that other code or people depend on. Focuses on minimal contracts, compatibility, versioning, errors, idempotency, and documentation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API and Contract Design
|
|
7
|
+
|
|
8
|
+
Use this skill for any boundary with callers or consumers.
|
|
9
|
+
|
|
10
|
+
## Contract elements
|
|
11
|
+
|
|
12
|
+
Define:
|
|
13
|
+
|
|
14
|
+
- purpose and owner
|
|
15
|
+
- inputs and validation rules
|
|
16
|
+
- outputs and guarantees
|
|
17
|
+
- error cases
|
|
18
|
+
- idempotency and ordering expectations
|
|
19
|
+
- compatibility/versioning expectations
|
|
20
|
+
- security and privacy constraints
|
|
21
|
+
- observability expectations
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
1. Identify consumers and their real needs.
|
|
26
|
+
2. Keep the contract smaller than the implementation model.
|
|
27
|
+
3. Separate public contract from internal representation.
|
|
28
|
+
4. Make defaults and optional fields explicit.
|
|
29
|
+
5. Preserve backward compatibility unless a breaking change is approved.
|
|
30
|
+
6. Add contract tests or examples for important cases.
|
|
31
|
+
7. Document semantics near the contract surface.
|
|
32
|
+
|
|
33
|
+
## Review questions
|
|
34
|
+
|
|
35
|
+
- Can the implementation change without breaking consumers?
|
|
36
|
+
- Are failure modes part of the contract?
|
|
37
|
+
- Is the contract stable enough to test?
|
|
38
|
+
- Are names domain-specific and unambiguous?
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cohesion-coupling
|
|
3
|
+
description: Improve code-level modularity by increasing cohesion and reducing accidental coupling. Use when splitting files/components, moving logic, introducing boundaries, or reviewing dependency direction. Focuses on reason-to-change, dependency minimization, and cognitive load.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cohesion and Coupling
|
|
7
|
+
|
|
8
|
+
Use this skill to make code easier to understand and change.
|
|
9
|
+
|
|
10
|
+
## Cohesion checks
|
|
11
|
+
|
|
12
|
+
Keep together code that:
|
|
13
|
+
|
|
14
|
+
- changes for the same reason
|
|
15
|
+
- enforces the same invariant
|
|
16
|
+
- uses the same domain language
|
|
17
|
+
- participates in the same workflow step
|
|
18
|
+
- shares a stable lifecycle
|
|
19
|
+
|
|
20
|
+
## Coupling checks
|
|
21
|
+
|
|
22
|
+
Reduce dependencies that are:
|
|
23
|
+
|
|
24
|
+
- unnecessary for the caller's purpose
|
|
25
|
+
- pointed from stable code to volatile code
|
|
26
|
+
- created only for convenience
|
|
27
|
+
- transitive through broad utility modules
|
|
28
|
+
- hidden through globals or ambient context
|
|
29
|
+
|
|
30
|
+
## Workflow
|
|
31
|
+
|
|
32
|
+
1. Identify the responsibility being changed.
|
|
33
|
+
2. List current dependencies and call direction.
|
|
34
|
+
3. Move behavior toward the concept that owns the rule.
|
|
35
|
+
4. Expose a narrow facade instead of leaking internals.
|
|
36
|
+
5. Remove dependency cycles or document why they cannot be removed now.
|
|
37
|
+
6. Verify call sites still read clearly.
|
|
38
|
+
|
|
39
|
+
## Avoid
|
|
40
|
+
|
|
41
|
+
- Splitting code by technical layer when the change is domain-local.
|
|
42
|
+
- Central helper modules that collect unrelated behavior.
|
|
43
|
+
- Abstractions that reduce lines but increase conceptual coupling.
|