engsys 1.0.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/LICENSE +21 -0
- package/README.md +202 -0
- package/core/agents/aaron.md +152 -0
- package/core/agents/bert.md +115 -0
- package/core/agents/isabelle.md +136 -0
- package/core/agents/jody.md +150 -0
- package/core/agents/leith.md +111 -0
- package/core/agents/marcelo.md +282 -0
- package/core/agents/melvin.md +101 -0
- package/core/agents/nyx.md +152 -0
- package/core/agents/otto.md +168 -0
- package/core/agents/patricia.md +283 -0
- package/core/commands/design-audit-local.md +155 -0
- package/core/commands/design-audit.md +235 -0
- package/core/commands/design-critique.md +96 -0
- package/core/commands/file-issue.md +22 -0
- package/core/commands/generate-project.md +45 -0
- package/core/commands/implement-issue.md +37 -0
- package/core/commands/implement-project.md +40 -0
- package/core/commands/naturalize.md +61 -0
- package/core/commands/pre-push.md +29 -0
- package/core/commands/prep-review-collect.md +130 -0
- package/core/commands/prep-review-finalize.md +121 -0
- package/core/commands/prep-review-publish.md +113 -0
- package/core/commands/prep-review.md +65 -0
- package/core/commands/project-closeout.md +25 -0
- package/core/skills/agentic-eval/SKILL.md +195 -0
- package/core/skills/chrome-devtools/SKILL.md +97 -0
- package/core/skills/code-review/SKILL.md +26 -0
- package/core/skills/gh-cli/SKILL.md +2202 -0
- package/core/skills/git-commit/SKILL.md +124 -0
- package/core/skills/git-workflow-agents/SKILL.md +462 -0
- package/core/skills/git-workflow-agents/reference.md +220 -0
- package/core/skills/github-actions/SKILL.md +190 -0
- package/core/skills/github-issues/SKILL.md +154 -0
- package/core/skills/llm-structured-outputs/SKILL.md +323 -0
- package/core/skills/llm-structured-outputs/references/provider-details.md +392 -0
- package/core/skills/pre-push/SKILL.md +115 -0
- package/core/skills/refactor/SKILL.md +645 -0
- package/core/skills/web-design-reviewer/SKILL.md +371 -0
- package/core/skills/webapp-testing/SKILL.md +127 -0
- package/core/skills/webapp-testing/test-helper.js +56 -0
- package/core/templates/CLAUDE.md.tmpl +98 -0
- package/core/templates/adr-template.md +67 -0
- package/core/templates/gh-issue-templates/bug.md +39 -0
- package/core/templates/gh-issue-templates/content.md +42 -0
- package/core/templates/gh-issue-templates/enhancement.md +36 -0
- package/core/templates/gh-issue-templates/feature.md +39 -0
- package/core/templates/gh-issue-templates/infrastructure.md +41 -0
- package/core/templates/post-edit-reminders.sh.tmpl +19 -0
- package/core/templates/settings.json.tmpl +90 -0
- package/core/templates/settings.local.json.tmpl +3 -0
- package/core/workflows/agent-implementation-workflow.md +346 -0
- package/core/workflows/generate-project.md +258 -0
- package/core/workflows/implement-project-workflow.md +190 -0
- package/core/workflows/issue-tracking.md +89 -0
- package/core/workflows/project-closeout-ceremony.md +77 -0
- package/core/workflows/review-workflow.md +266 -0
- package/engsys.config.example.yaml +46 -0
- package/install +202 -0
- package/lessons-library/README.md +80 -0
- package/lessons-library/async-callbacks-verify-liveness.md +15 -0
- package/lessons-library/change-isnt-done-until-every-surface-updated.md +15 -0
- package/lessons-library/claim-then-act-for-irreversible-ops.md +16 -0
- package/lessons-library/co-commit-entangled-work.md +15 -0
- package/lessons-library/dependabot-triage-playbook.md +17 -0
- package/lessons-library/deploy-by-digest-and-verify-the-running-revision.md +15 -0
- package/lessons-library/enforce-your-guarantee-at-your-boundary.md +16 -0
- package/lessons-library/gate-changes-on-measurement-not-vibes.md +15 -0
- package/lessons-library/iac-first-no-console-changes.md +15 -0
- package/lessons-library/independent-objective-review-gate.md +15 -0
- package/lessons-library/keep-an-immutable-source-of-truth.md +15 -0
- package/lessons-library/long-agent-runs-checkpoint-not-poll.md +15 -0
- package/lessons-library/model-identity-with-stable-ids-and-provenance.md +15 -0
- package/lessons-library/operator-choices-are-first-class.md +15 -0
- package/lessons-library/prefer-tool-enforced-structured-output.md +15 -0
- package/lessons-library/prove-causation-before-acting.md +15 -0
- package/lessons-library/re-read-state-before-acting.md +14 -0
- package/lessons-library/read-layer-tolerates-unbackfilled-rows.md +15 -0
- package/lessons-library/shell-safety-pipefail-and-validate-before-teardown.md +14 -0
- package/lessons-library/shift-correctness-left-and-distrust-false-greens.md +15 -0
- package/lessons-library/stray-control-bytes-hide-changes.md +14 -0
- package/lessons-library/tests-can-assert-the-bug.md +15 -0
- package/lessons-library/verify-ground-truth-not-reports.md +15 -0
- package/lessons-library/worktrees-need-bootstrap-from-origin-main.md +15 -0
- package/lib/commands.js +356 -0
- package/lib/generate-team-avatars.mjs +251 -0
- package/lib/manifest.js +155 -0
- package/lib/render.js +135 -0
- package/lib/selftest.js +90 -0
- package/lib/util.js +89 -0
- package/lib/yaml.js +156 -0
- package/optional-agents/gary.md +86 -0
- package/optional-agents/jos.md +136 -0
- package/optional-agents/sandy.md +101 -0
- package/optional-agents/steve.md +161 -0
- package/package.json +43 -0
- package/stacks/cloud/aws/claude.fragment.md +17 -0
- package/stacks/cloud/aws/settings.fragment.json +39 -0
- package/stacks/cloud/aws/skills/aws-deployment-preflight/SKILL.md +165 -0
- package/stacks/cloud/aws/skills/cloud-architecture-aws/SKILL.md +265 -0
- package/stacks/cloud/azure/claude.fragment.md +17 -0
- package/stacks/cloud/azure/settings.fragment.json +45 -0
- package/stacks/cloud/azure/skills/azure-deployment-preflight/SKILL.md +175 -0
- package/stacks/cloud/azure/skills/cloud-architecture-azure/SKILL.md +211 -0
- package/stacks/cloud/cloudflare/claude.fragment.md +21 -0
- package/stacks/cloud/cloudflare/settings.fragment.json +31 -0
- package/stacks/cloud/cloudflare/skills/cloud-architecture-cloudflare/SKILL.md +294 -0
- package/stacks/cloud/cloudflare/skills/cloudflare-deployment-preflight/SKILL.md +175 -0
- package/stacks/cloud/gcp/claude.fragment.md +17 -0
- package/stacks/cloud/gcp/settings.fragment.json +40 -0
- package/stacks/cloud/gcp/skills/cloud-architecture-gcp/SKILL.md +208 -0
- package/stacks/cloud/gcp/skills/gcp-deployment-preflight/SKILL.md +137 -0
- package/stacks/db/mongo/skills/mongo-conventions/SKILL.md +96 -0
- package/stacks/db/prisma/claude.fragment.md +49 -0
- package/stacks/db/prisma/skills/docker-database-package-copy/SKILL.md +44 -0
- package/stacks/db/prisma/skills/prisma-conventions/SKILL.md +37 -0
- package/stacks/domain/mobile-growth/skills/apple-ads/SKILL.md +184 -0
- package/stacks/domain/mobile-growth/skills/apple-ads/references/benchmark-notes.md +47 -0
- package/stacks/domain/mobile-growth/skills/apple-ads/references/official-links.md +53 -0
- package/stacks/domain/mobile-growth/skills/google-play-growth/SKILL.md +197 -0
- package/stacks/domain/mobile-growth/skills/google-play-growth/references/benchmark-notes.md +47 -0
- package/stacks/domain/mobile-growth/skills/google-play-growth/references/official-links.md +45 -0
- package/stacks/iac/bicep/claude.fragment.md +14 -0
- package/stacks/iac/bicep/settings.fragment.json +20 -0
- package/stacks/iac/bicep/skills/iac-bicep/SKILL.md +113 -0
- package/stacks/iac/cdk/claude.fragment.md +14 -0
- package/stacks/iac/cdk/settings.fragment.json +23 -0
- package/stacks/iac/cdk/skills/iac-cdk/SKILL.md +104 -0
- package/stacks/iac/terraform/claude.fragment.md +13 -0
- package/stacks/iac/terraform/settings.fragment.json +25 -0
- package/stacks/iac/terraform/skills/iac-terraform/SKILL.md +93 -0
- package/stacks/iac/terraform/skills/terraform-conventions/SKILL.md +87 -0
- package/stacks/lang/kotlin/skills/android-testing/SKILL.md +263 -0
- package/stacks/lang/kotlin/skills/jetpack-compose/SKILL.md +264 -0
- package/stacks/lang/kotlin/skills/kotlin-coroutines/SKILL.md +329 -0
- package/stacks/lang/python/skills/python-conventions/SKILL.md +61 -0
- package/stacks/lang/shell/skills/shell-scripting/SKILL.md +110 -0
- package/stacks/lang/swift/skills/swift-concurrency/SKILL.md +423 -0
- package/stacks/lang/swift/skills/swift-concurrency/references/approachable-concurrency.md +80 -0
- package/stacks/lang/swift/skills/swift-concurrency/references/concurrency-patterns.md +233 -0
- package/stacks/lang/swift/skills/swift-concurrency/references/swiftui-concurrency.md +187 -0
- package/stacks/lang/swift/skills/swift-concurrency/references/synchronization-primitives.md +341 -0
- package/stacks/lang/swift/skills/swift-testing/SKILL.md +497 -0
- package/stacks/lang/swift/skills/swift-testing/references/testing-advanced.md +106 -0
- package/stacks/lang/swift/skills/swift-testing/references/testing-patterns.md +504 -0
- package/stacks/lang/swift/skills/swiftdata/SKILL.md +334 -0
- package/stacks/lang/swift/skills/swiftdata/references/core-data-coexistence.md +504 -0
- package/stacks/lang/swift/skills/swiftdata/references/swiftdata-advanced.md +975 -0
- package/stacks/lang/swift/skills/swiftdata/references/swiftdata-queries.md +675 -0
- package/stacks/lang/swift/skills/swiftui-patterns/SKILL.md +371 -0
- package/stacks/lang/swift/skills/swiftui-patterns/references/architecture-patterns.md +486 -0
- package/stacks/lang/swift/skills/swiftui-patterns/references/deprecated-migration.md +1097 -0
- package/stacks/lang/swift/skills/swiftui-patterns/references/design-polish.md +780 -0
- package/stacks/lang/swift/skills/swiftui-patterns/references/platform-and-sharing.md +696 -0
- package/stacks/lang/typescript/skills/typescript-conventions/SKILL.md +91 -0
- package/stacks/platform/android/claude.fragment.md +40 -0
- package/stacks/platform/android/hooks/pre-push-gradle.sh +70 -0
- package/stacks/platform/android/settings.fragment.json +13 -0
- package/stacks/platform/android/skills/android-build-conventions/SKILL.md +247 -0
- package/stacks/platform/ios/claude.fragment.md +24 -0
- package/stacks/platform/ios/hooks/pre-push-xcodebuild.sh +82 -0
- package/stacks/platform/ios/settings.fragment.json +21 -0
- package/stacks/platform/ios/skills/xcodebuildmcp-simulator-logs/SKILL.md +76 -0
- package/stacks/platform/web/skills/frontend-testing/SKILL.md +246 -0
- package/stacks/platform/web/skills/react-conventions/SKILL.md +261 -0
- package/stacks/platform/web/skills/web-platform-conventions/SKILL.md +55 -0
- package/stacks/tooling/issue-tracker-github/claude.fragment.md +10 -0
- package/stacks/tooling/issue-tracker-github/settings.fragment.json +24 -0
- package/stacks/tooling/issue-tracker-github/skills/issue-tracker-github/SKILL.md +278 -0
- package/stacks/tooling/issue-tracker-linear/claude.fragment.md +17 -0
- package/stacks/tooling/issue-tracker-linear/settings.fragment.json +9 -0
- package/stacks/tooling/issue-tracker-linear/skills/issue-tracker-linear/SKILL.md +183 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# LLM Structured Outputs — Provider Details
|
|
2
|
+
|
|
3
|
+
> Detailed per-provider reference. See [SKILL.md](../SKILL.md) for the quick-start guide.
|
|
4
|
+
> Last updated: February 23, 2026.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Anthropic Claude Opus 4.6 / Sonnet 4.6
|
|
9
|
+
|
|
10
|
+
**Model IDs:** `claude-opus-4-6` · `claude-sonnet-4-6`
|
|
11
|
+
**Context window:** 200K tokens (1M available in beta with header `context-1m-2025-08-07`)
|
|
12
|
+
**Max output tokens:** 128K (Opus 4.6), 64K (Sonnet 4.6)
|
|
13
|
+
**Structured outputs status:** Generally available (GA) — no beta header required
|
|
14
|
+
|
|
15
|
+
### API parameter: `output_config.format`
|
|
16
|
+
|
|
17
|
+
Structured outputs graduated from beta to GA on February 4, 2026. The API parameter is `output_config.format` (replacing the deprecated `output_format` from the beta period).
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// TypeScript — direct API call
|
|
21
|
+
const response = await anthropic.messages.create({
|
|
22
|
+
model: "claude-opus-4-6", // or 'claude-sonnet-4-6'
|
|
23
|
+
max_tokens: 4096,
|
|
24
|
+
messages: [{ role: "user", content: prompt }],
|
|
25
|
+
output_config: {
|
|
26
|
+
format: {
|
|
27
|
+
type: "json_schema",
|
|
28
|
+
schema: jsonSchema, // JSON Schema object
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const parsed = JSON.parse(response.content[0].text);
|
|
33
|
+
|
|
34
|
+
// TypeScript — using SDK .parse() helper
|
|
35
|
+
const response = await anthropic.messages.parse({
|
|
36
|
+
model: "claude-opus-4-6",
|
|
37
|
+
max_tokens: 4096,
|
|
38
|
+
messages: [{ role: "user", content: prompt }],
|
|
39
|
+
output_format: MySchema, // SDK converts to JSON Schema automatically
|
|
40
|
+
});
|
|
41
|
+
const result = response.parsed_output; // Already validated
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Strict tool use
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
tools: [
|
|
48
|
+
{
|
|
49
|
+
name: "extract_data",
|
|
50
|
+
description: "Extract structured data",
|
|
51
|
+
strict: true, // Constrained decoding for tool args
|
|
52
|
+
input_schema: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
/* ... */
|
|
56
|
+
},
|
|
57
|
+
required: [
|
|
58
|
+
/* ... */
|
|
59
|
+
],
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Supported JSON Schema subset
|
|
67
|
+
|
|
68
|
+
**Supported:** `type`, `properties`, `required`, `additionalProperties`, `enum`, `const`, `items`, nested objects, arrays, `string`, `number`, `integer`, `boolean`, `null`, `$ref` (internal definitions only).
|
|
69
|
+
|
|
70
|
+
**NOT supported:** `anyOf`, `oneOf`, `allOf` (top-level), `pattern`, `minimum`/`maximum`, `minLength`/`maxLength`, `minItems`/`maxItems`, `prefixItems`, `$dynamicRef`, recursive schemas.
|
|
71
|
+
|
|
72
|
+
**Complexity limits (per request):**
|
|
73
|
+
|
|
74
|
+
- Max 20 strict tools
|
|
75
|
+
- Max 24 optional parameters (across all strict schemas)
|
|
76
|
+
- Max 16 parameters with union types (e.g., `"type": ["string", "null"]`)
|
|
77
|
+
|
|
78
|
+
Optional fields are emulated via `"type": ["string", "null"]` unions (counts toward the union type limit).
|
|
79
|
+
|
|
80
|
+
### Breaking changes from Claude 4.5
|
|
81
|
+
|
|
82
|
+
1. **Parameter renamed:** `output_format` → `output_config.format` (old name still works during transition)
|
|
83
|
+
2. **Beta header removed:** `anthropic-beta: structured-outputs-2025-11-13` is no longer needed
|
|
84
|
+
3. **Assistant prefilling removed:** Starting assistant messages with `{"role": "assistant"}` now returns 400. Use structured outputs or system prompts instead.
|
|
85
|
+
4. **Adaptive thinking:** `thinking.type: "adaptive"` replaces `thinking.type: "enabled"` with `budget_tokens`
|
|
86
|
+
|
|
87
|
+
### Edge cases
|
|
88
|
+
|
|
89
|
+
- **Refusals:** Check `stop_reason` field — model may refuse for safety reasons
|
|
90
|
+
- **Truncation:** `stop_reason: "max_tokens"` means JSON may be incomplete
|
|
91
|
+
- **Cache invalidation:** Changing `output_config.format` invalidates prompt cache for that conversation
|
|
92
|
+
|
|
93
|
+
**Docs:** https://platform.claude.com/docs/en/build-with-claude/structured-outputs
|
|
94
|
+
**Models:** https://platform.claude.com/docs/en/about-claude/models/overview
|
|
95
|
+
**Release notes:** https://www.anthropic.com/news/claude-opus-4-6
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## OpenAI GPT-5.3
|
|
100
|
+
|
|
101
|
+
**Model IDs:** `gpt-5.3` (primary) · `gpt-5.3-pro` (premium) · `gpt-5.3-chat-latest` (conversational — ⚠️ **no** `json_schema` support)
|
|
102
|
+
**Structured outputs status:** GA via both Responses API and Chat Completions API
|
|
103
|
+
|
|
104
|
+
### Two API surfaces
|
|
105
|
+
|
|
106
|
+
**Responses API** (recommended for new code):
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const response = await openai.responses.create({
|
|
110
|
+
model: "gpt-5.3",
|
|
111
|
+
input: prompt,
|
|
112
|
+
text: {
|
|
113
|
+
format: {
|
|
114
|
+
type: "json_schema",
|
|
115
|
+
json_schema: {
|
|
116
|
+
name: "artifacts",
|
|
117
|
+
strict: true,
|
|
118
|
+
schema: jsonSchema,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
reasoning: { effort: "high" }, // none | low | medium | high | xhigh
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Chat Completions API** (legacy, still supported):
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
const response = await openai.chat.completions.create({
|
|
130
|
+
model: "gpt-5.3",
|
|
131
|
+
messages: [{ role: "user", content: prompt }],
|
|
132
|
+
response_format: {
|
|
133
|
+
type: "json_schema",
|
|
134
|
+
json_schema: {
|
|
135
|
+
name: "artifacts",
|
|
136
|
+
strict: true,
|
|
137
|
+
schema: jsonSchema,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Structured Outputs vs JSON mode
|
|
144
|
+
|
|
145
|
+
| Feature | Structured Outputs | JSON Mode |
|
|
146
|
+
| --------------------- | --------------------- | ----------------------------- |
|
|
147
|
+
| API field | `type: "json_schema"` | `type: "json_object"` |
|
|
148
|
+
| Schema enforcement | Constrained decoding | None — only valid JSON syntax |
|
|
149
|
+
| Field/type guarantees | Schema-compliant | No guarantees |
|
|
150
|
+
| Recommendation | **Use this** | Legacy fallback only |
|
|
151
|
+
|
|
152
|
+
### Supported JSON Schema subset
|
|
153
|
+
|
|
154
|
+
**Supported:** `string`, `number`, `integer`, `boolean`, `object`, `array`, `enum`, `anyOf`, `pattern`, `format`, range constraints (`minimum`, `maximum`), `additionalProperties: false` (required).
|
|
155
|
+
|
|
156
|
+
**NOT supported:** `oneOf`, `allOf`, complex conditional schemas, recursive schemas.
|
|
157
|
+
|
|
158
|
+
**Requirements:** Root schema must be `type: "object"`. All fields must be `required` or unioned with `null`. `additionalProperties: false` mandatory.
|
|
159
|
+
|
|
160
|
+
### SDK helpers
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { zodTextFormat } from "openai/helpers/zod";
|
|
164
|
+
|
|
165
|
+
const response = await openai.responses.create({
|
|
166
|
+
model: "gpt-5.3",
|
|
167
|
+
input: prompt,
|
|
168
|
+
text: { format: zodTextFormat(MyZodSchema, "artifacts") },
|
|
169
|
+
});
|
|
170
|
+
// Response is auto-parsed via Zod
|
|
171
|
+
|
|
172
|
+
import { zodResponseFormat } from "openai/helpers/zod";
|
|
173
|
+
response_format: zodResponseFormat(MyZodSchema, "artifacts");
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Notable GPT-5.3 features
|
|
177
|
+
|
|
178
|
+
- **~40% faster inference** than GPT-5.1 (Feb 2026 optimization)
|
|
179
|
+
- **Reasoning effort levels:** `none`, `low`, `medium`, `high`, `xhigh`
|
|
180
|
+
- **Context compaction:** Automatic context management for long-context extraction
|
|
181
|
+
- **Chain of thought:** Responses API preserves reasoning chains across turns
|
|
182
|
+
|
|
183
|
+
**Docs:** https://developers.openai.com/api/docs/guides/structured-outputs/
|
|
184
|
+
**Migration to Responses API:** https://developers.openai.com/api/docs/guides/migrate-to-responses/
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Google Gemini 3.1 Pro
|
|
189
|
+
|
|
190
|
+
**Model ID:** `gemini-3.1-pro-preview`
|
|
191
|
+
**Context window:** 1M tokens input · 64K tokens output
|
|
192
|
+
**Structured outputs status:** GA with constrained decoding
|
|
193
|
+
|
|
194
|
+
### API parameter: `generationConfig`
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// TypeScript — Google AI SDK (@google/genai)
|
|
198
|
+
import { GoogleGenAI } from "@google/genai";
|
|
199
|
+
|
|
200
|
+
const ai = new GoogleGenAI({ apiKey: GEMINI_API_KEY });
|
|
201
|
+
|
|
202
|
+
const response = await ai.models.generateContent({
|
|
203
|
+
model: "gemini-3.1-pro-preview",
|
|
204
|
+
contents: prompt,
|
|
205
|
+
config: {
|
|
206
|
+
responseMimeType: "application/json",
|
|
207
|
+
responseJsonSchema: jsonSchema,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
const parsed = JSON.parse(response.text);
|
|
211
|
+
|
|
212
|
+
// TypeScript — REST API (camelCase required)
|
|
213
|
+
body: JSON.stringify({
|
|
214
|
+
contents: [{ role: "user", parts: [{ text: prompt }] }],
|
|
215
|
+
generationConfig: {
|
|
216
|
+
responseMimeType: "application/json",
|
|
217
|
+
responseJsonSchema: jsonSchema,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
> **SDK naming:** Python SDK uses `response_mime_type` / `response_json_schema` (snake_case, auto-converted). TypeScript SDK uses camelCase directly.
|
|
223
|
+
|
|
224
|
+
### Supported JSON Schema subset
|
|
225
|
+
|
|
226
|
+
Gemini 3.1 Pro has the **broadest** JSON Schema support of all four providers:
|
|
227
|
+
|
|
228
|
+
**Supported:** `type`, `properties`, `required`, `enum`, `items`, `additionalProperties`, `anyOf`, `$ref` (recursive schemas), `prefixItems` (tuples), `minimum`/`maximum`, `minItems`/`maxItems`, `pattern` (regex), `type: 'null'`.
|
|
229
|
+
|
|
230
|
+
**NOT supported:** `allOf`, `oneOf`, `not`, `patternProperties`, `if`/`then`/`else`, `const` (limited).
|
|
231
|
+
|
|
232
|
+
**New in Gemini 3.1 Pro** (vs Gemini 3 Pro): `anyOf`, `$ref`, `minimum`/`maximum`, `additionalProperties`, `prefixItems`, implicit property ordering (output keys match schema declaration order).
|
|
233
|
+
|
|
234
|
+
### Enum responses
|
|
235
|
+
|
|
236
|
+
For classification:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
config: {
|
|
240
|
+
responseMimeType: 'text/x.enum',
|
|
241
|
+
responseJsonSchema: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
enum: ['positive', 'negative', 'neutral']
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// Response is exactly one of the enum values
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Function calling
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
tools: [
|
|
253
|
+
{
|
|
254
|
+
functionDeclarations: [
|
|
255
|
+
{
|
|
256
|
+
name: "search_database",
|
|
257
|
+
description: "Search the product database",
|
|
258
|
+
parameters: {
|
|
259
|
+
type: "object",
|
|
260
|
+
properties: {
|
|
261
|
+
query: { type: "string" },
|
|
262
|
+
limit: { type: "integer" },
|
|
263
|
+
},
|
|
264
|
+
required: ["query"],
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
];
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Thinking levels
|
|
273
|
+
|
|
274
|
+
Gemini 3.1 Pro supports `LOW`, `MEDIUM`, `HIGH` thinking levels, combinable with structured outputs.
|
|
275
|
+
|
|
276
|
+
**Docs:** https://ai.google.dev/gemini-api/docs/structured-output
|
|
277
|
+
**Function calling:** https://ai.google.dev/gemini-api/docs/function-calling
|
|
278
|
+
**Vertex AI:** https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## xAI Grok 4
|
|
283
|
+
|
|
284
|
+
**Model IDs:** `grok-4` / `grok-4-0709` (standard) · `grok-4-1-fast-reasoning` / `grok-4-1-fast-non-reasoning` (recommended)
|
|
285
|
+
**Context window:** 256K tokens (Grok 4) · 2M tokens (Grok 4.1 Fast)
|
|
286
|
+
**OpenAI-compatible API:** Yes — base URL `https://api.x.ai/v1`
|
|
287
|
+
|
|
288
|
+
### API: OpenAI-compatible `response_format`
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import OpenAI from "openai";
|
|
292
|
+
|
|
293
|
+
const client = new OpenAI({
|
|
294
|
+
apiKey: process.env.XAI_API_KEY,
|
|
295
|
+
baseURL: "https://api.x.ai/v1",
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
const response = await client.chat.completions.create({
|
|
299
|
+
model: "grok-4-1-fast-reasoning",
|
|
300
|
+
messages: [{ role: "user", content: prompt }],
|
|
301
|
+
response_format: {
|
|
302
|
+
type: "json_schema",
|
|
303
|
+
json_schema: {
|
|
304
|
+
name: "artifacts",
|
|
305
|
+
strict: true,
|
|
306
|
+
schema: jsonSchema,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
const parsed = JSON.parse(response.choices[0].message.content);
|
|
311
|
+
|
|
312
|
+
// zodResponseFormat also works directly
|
|
313
|
+
import { zodResponseFormat } from "openai/helpers/zod";
|
|
314
|
+
response_format: zodResponseFormat(MyZodSchema, "artifacts");
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Supported JSON Schema subset
|
|
318
|
+
|
|
319
|
+
**Supported:** `string`, `number`, `integer`, `float`, `object`, `array`, `boolean`, `enum`, `anyOf`, `required`, `additionalProperties`, `description`.
|
|
320
|
+
|
|
321
|
+
**NOT supported / unreliable:** `minLength`, `maxLength`, `minItems`, `maxItems`, `allOf`, `pattern`, `minimum`/`maximum`. Enforce these in downstream Zod validation instead.
|
|
322
|
+
|
|
323
|
+
### Model variant selection
|
|
324
|
+
|
|
325
|
+
| Variant | Use Case | Structured Output |
|
|
326
|
+
| ----------------------------- | -------------------------------- | :--------------------------------: |
|
|
327
|
+
| `grok-4` / `grok-4-latest` | General-purpose | Full |
|
|
328
|
+
| `grok-4-1-fast-reasoning` | Deep analysis + chain-of-thought | Full ✅ |
|
|
329
|
+
| `grok-4-1-fast-non-reasoning` | Low-latency, high-throughput | Full |
|
|
330
|
+
| `grok-4-0709` | Legacy | ⚠️ Bug with complex strict schemas |
|
|
331
|
+
|
|
332
|
+
### Strict mode caveats
|
|
333
|
+
|
|
334
|
+
- `strict: true` provides constrained decoding for supported schema types
|
|
335
|
+
- `grok-4-0709` has known empty-response bug with complex `strict: true` schemas — prefer `grok-4-1-fast-*`
|
|
336
|
+
- Complex `anyOf`/`oneOf` reduces compliance even in strict mode
|
|
337
|
+
- Keep schemas flat and explicit
|
|
338
|
+
|
|
339
|
+
### Rate limits & pricing
|
|
340
|
+
|
|
341
|
+
- 480 req/min, 2M tokens/min (Grok 4)
|
|
342
|
+
- Cached token pricing: ~75% of regular input pricing
|
|
343
|
+
|
|
344
|
+
**Docs:** https://docs.x.ai/docs/guides/structured-outputs
|
|
345
|
+
**Models:** https://docs.x.ai/docs/models/grok-4-0709
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Zod 4 Native JSON Schema
|
|
350
|
+
|
|
351
|
+
`zod-to-json-schema` was deprecated November 2025. Zod 4 includes native `z.toJSONSchema()`.
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
import { z } from "zod";
|
|
355
|
+
|
|
356
|
+
const MySchema = z
|
|
357
|
+
.object({
|
|
358
|
+
title: z.string(),
|
|
359
|
+
score: z.number(),
|
|
360
|
+
status: z.enum(["active", "archived"]),
|
|
361
|
+
tags: z.array(z.string()),
|
|
362
|
+
})
|
|
363
|
+
.strict();
|
|
364
|
+
|
|
365
|
+
const jsonSchema = z.toJSONSchema(MySchema);
|
|
366
|
+
// => { type: 'object', properties: {...}, required: [...], additionalProperties: false }
|
|
367
|
+
|
|
368
|
+
// With options
|
|
369
|
+
z.toJSONSchema(MySchema, { target: "draft-07" });
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### `toJSONSchema` options
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
interface ToJSONSchemaParams {
|
|
376
|
+
target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0";
|
|
377
|
+
unrepresentable?: "throw" | "any";
|
|
378
|
+
cycles?: "ref" | "throw";
|
|
379
|
+
reused?: "ref" | "inline";
|
|
380
|
+
uri?: (id: string) => string;
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**Upgrade:** install `zod@^4` then replace all `zod-to-json-schema` imports with `z.toJSONSchema()`.
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Additional Resources
|
|
389
|
+
|
|
390
|
+
- [Azure OpenAI Structured Outputs](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/structured-outputs)
|
|
391
|
+
- [AWS Bedrock Structured Outputs](https://docs.aws.amazon.com/bedrock/latest/userguide/structured-output.html)
|
|
392
|
+
- [Anthropic Agent SDK — Structured Outputs](https://platform.claude.com/docs/en/agent-sdk/structured-outputs)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pre-push
|
|
3
|
+
description: Run the project's diff-aware pre-push gate before pushing — builds, lints, and tests only what changed. Use when the user says "run precheck", "pre-push check", or "validate before push".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pre-push Gate
|
|
7
|
+
|
|
8
|
+
Trigger: user says "run precheck", "pre-push check", "validate before push", or equivalent.
|
|
9
|
+
|
|
10
|
+
## The Contract
|
|
11
|
+
|
|
12
|
+
Run the project's pre-push gate from the repo root before every `git push`. The gate is a
|
|
13
|
+
**diff-aware contract**: it inspects `git diff origin/main...HEAD`, then runs only the checks
|
|
14
|
+
relevant to the files that changed. It should be enforced by a `pre-push` git hook so it runs
|
|
15
|
+
automatically on `git push`. Run it manually if you want early feedback before committing.
|
|
16
|
+
|
|
17
|
+
The gate is invoked through whatever the project defines — a script (`scripts/precheck.sh`), a
|
|
18
|
+
package-manager task (`npm/pnpm/yarn run precheck`, `make precheck`, `just precheck`,
|
|
19
|
+
`cargo`/`go`/`mvn` equivalents), or a Taskfile target. The name and runner are project-specific;
|
|
20
|
+
the contract is not.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
<precheck-command> # standard — diff-driven, runs relevant gates only
|
|
24
|
+
<precheck-command> --full # force the full suite even if the diff didn't trigger it
|
|
25
|
+
PUSH_OVERRIDE=1 git push ... # emergency bypass — no local gates run, CI is sole safety net
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## What It Does (diff-aware gate selection)
|
|
29
|
+
|
|
30
|
+
The gate maps changed paths to checks. Always run **build + lint**; layer on the rest based on
|
|
31
|
+
what the diff touched. Each project defines its own table — the shape is always
|
|
32
|
+
`changed files → gates triggered`:
|
|
33
|
+
|
|
34
|
+
| Changed files | Gates triggered |
|
|
35
|
+
| -------------------------------------- | ------------------------------------------------------ |
|
|
36
|
+
| Any | build + lint (always) |
|
|
37
|
+
| Source files | + unit tests |
|
|
38
|
+
| Data/schema/migration files | + codegen + dependent-package builds |
|
|
39
|
+
| End-to-end / integration spec files | + e2e for the changed specs only |
|
|
40
|
+
| Test-harness / matrix config | + full e2e suite (harness change can affect all specs) |
|
|
41
|
+
| UI / frontend source | + browser/e2e suite |
|
|
42
|
+
| Infrastructure-as-code files | + IaC syntax/validate check |
|
|
43
|
+
| Container/build files (`Dockerfile*`) | + container build smoke (if the engine is available) |
|
|
44
|
+
| Docs / markdown | + doc lint |
|
|
45
|
+
| CI workflow files | warn — validate manually |
|
|
46
|
+
|
|
47
|
+
The first column is the project's actual path globs; the second is the project's actual commands.
|
|
48
|
+
This skill defines the **discipline** (diff-aware, fast, gracefully degrading), not the specific
|
|
49
|
+
tooling.
|
|
50
|
+
|
|
51
|
+
## Design Constraints
|
|
52
|
+
|
|
53
|
+
- Target: fast enough to run on every push (aim for under ~10 min for a single changed spec).
|
|
54
|
+
- Run only the spec/test files affected by the diff, not the full matrix, in the standard path.
|
|
55
|
+
- Gates for optional tooling (container engine, IaC CLI, cloud CLI) skip gracefully when the
|
|
56
|
+
tool is not installed — a missing optional tool must not fail the push.
|
|
57
|
+
|
|
58
|
+
## Full Suite Locally
|
|
59
|
+
|
|
60
|
+
When the test harness itself changes, or when you want to run the full suite regardless of the
|
|
61
|
+
diff, force it:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 1. Bring up any infra the full suite needs (db, services, browsers)
|
|
65
|
+
<bring-up-infra-command>
|
|
66
|
+
|
|
67
|
+
# 2. Force the full suite
|
|
68
|
+
<precheck-command> --full
|
|
69
|
+
|
|
70
|
+
# 3. Or run a specific spec manually
|
|
71
|
+
<run-single-spec-command>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Review before push (local code review)
|
|
75
|
+
|
|
76
|
+
Review is local — run a local code review with the built-in `/code-review` skill **before** you
|
|
77
|
+
push so the PR opens already-reviewed and CI minutes aren't spent on a post-push review loop.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git fetch origin # local main is often stale — compare against the remote
|
|
81
|
+
# then run a local code review with the built-in /code-review skill against origin/main:
|
|
82
|
+
# structured findings; fix Critical + Warning, then re-run once
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
This is **not** part of the pre-push gate (a multi-minute review shouldn't block every push).
|
|
86
|
+
Invoke it deliberately before the push that opens/updates the PR. After opening the PR, persist
|
|
87
|
+
the local review findings as a PR comment for the closeout ceremony to mine. Full contract:
|
|
88
|
+
[`../code-review/SKILL.md`](../code-review/SKILL.md) and the root CLAUDE.md § Code review.
|
|
89
|
+
|
|
90
|
+
## Draft-First PR Convention
|
|
91
|
+
|
|
92
|
+
Draft PRs should skip the expensive full matrices (browser/e2e, a11y, flake audits) in CI; keep
|
|
93
|
+
those for Ready-for-review. If your CI opens PRs as ready by default, add a workflow that demotes
|
|
94
|
+
opened-as-ready PRs to draft automatically.
|
|
95
|
+
|
|
96
|
+
Workflow:
|
|
97
|
+
|
|
98
|
+
1. Run a local code review with the built-in `/code-review` skill → fix Critical + Warning → re-run clean
|
|
99
|
+
2. The pre-push gate runs on your diff → push branch
|
|
100
|
+
3. `gh pr create --draft` → cheap CI (build/lint/test only) → persist the local review findings as a PR comment
|
|
101
|
+
4. Mark **Ready for review** → full matrices fire
|
|
102
|
+
5. Matrices pass → human merges
|
|
103
|
+
|
|
104
|
+
Mark Ready for review only once the local review is resolved and the pre-push gate is green.
|
|
105
|
+
|
|
106
|
+
## Git Hook
|
|
107
|
+
|
|
108
|
+
The project's `pre-push` hook (e.g. under `.husky/` or `.git/hooks/`) calls the gate automatically
|
|
109
|
+
on every `git push`. To bypass:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
PUSH_OVERRIDE=1 git push origin agent/<branch>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Use the bypass only when optional local tooling is unavailable and you are confident CI will pass.
|