Add /gen-survey skill for SurveyJS JSON authoring#67
Open
countercheck wants to merge 1 commit into
Open
Conversation
Project-level Claude Code skill that turns a question list into a gate-valid SurveyJS JSON file. Grounded in patterns/ rather than inventing structure; stops to ask on the methodological judgments the design doc forbids defaulting (PII downgrade, branching, choice values, matrix row ids). Refuses types outside the gate-allowed surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Claude Code skill (/gen-survey) intended to help authors generate publish-gate-valid SurveyJS JSON from either loose question lists or structured YAML/JSON, by grounding output in the repo’s patterns/ fixtures and explicitly avoiding methodological “silent defaults” (PII downgrades, branching, etc.).
Changes:
- Introduces a new project-level skill definition at
.claude/skills/gen-survey/SKILL.md. - Documents an authoring workflow that copies gate-valid shapes from
patterns/, prompts on key methodological judgments, and performs local pre-write validation. - Defines a gate-allowed question type surface and refusal behavior for unsupported types.
|
|
||
| 1. **Read input.** Resolve `<arg>` per above. | ||
| 2. **Read the relevant pattern.** Pick the closest match from [patterns/](../../../patterns/) for each question type you'll emit, and copy its element shape. The pattern files are the source of truth for field names, choice format, and `pii_risk` handling. | ||
| 3. **Walk the question list.** For each item, build a SurveyJS element. Generate `name` as a stable kebab/snake-case slug from the prompt (e.g. "How many years…" → `years_gaming`). For choices, `value` is a stable key, `text` is the human label. |
Comment on lines
+81
to
+83
| | `matrix` | grid of single-selects | rows + columns required | | ||
| | `matrixdropdown` | grid of typed cells | option-typed cells only at top level | | ||
| | `paneldynamic` | repeating group | template elements per occurrence | |
Comment on lines
+93
to
+99
| - Every element has a unique `name` within the survey. | ||
| - Every `choices` entry on single/multi-select has a unique `value`. | ||
| - Every `matrix`/`matrixdropdown` has a non-empty `rows` and `columns` with unique ids. | ||
| - Every `text`/`comment` (free text, no numeric/date `inputType`) carries `pii_risk`. If `"low"`, it also carries `pii_risk_rationale`. | ||
| - No element references `parent_question_id` or `parent_question_rationale`. | ||
| - No `visibleIf` references a `name` that doesn't exist in the survey. | ||
| - The whole thing parses as JSON. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.claude/skills/gen-survey/SKILL.md. Invoked as/gen-survey <input>; turns a question list (loose markdown or structured YAML/JSON) into a gate-valid SurveyJS JSON file written to/tmp/<slug>.json.patterns/— the skill body directs the model to copy the nearest pattern's shape rather than invent structure. Restricted to the gate-allowed type surface frompatterns/README.md; refuses anything else.high, downgrade requires a user-supplied rationale),visibleIfbranching, choicevaluekeys, matrix row/col ids,paneldynamictemplate. Never writesparent_question_id/parent_question_rationale.visibleIfrefs, and forbidden parent-question fields.Scope
Authoring tool only. Does not publish, hash, or load into the API — the user runs the publish gate separately. No runtime, API, dbt, or schema changes.
Test plan
/gen-surveyappears in the skill list./gen-surveyagainst a loose markdown question list and verify it stops to ask on PII downgrade, choice values, and any branching cues./gen-surveyagainst a structured YAML/JSON input and verify 1:1 translation without extra prompts.validate_definition(publish gate).imagepicker) with a clear explanation and an alternative.Notes
Portability caveat is documented at the bottom of
SKILL.md: the gate-specific sections (narrow type surface,pii_riskrouting, noparent_question_id) are survey-engine invariants and would need extraction if this is ever lifted to a generic SurveyJS skill for other repos.🤖 Generated with Claude Code