agentleFS
hoanghaohahoanghaoha/survy-agent-skills/skills/questionnaire-reading/SKILL.md

questionnaire-reading

Skill2 starsChanged 8 months agoMITView on GitHub

Use this skill whenever the user wants to read, parse, or understand a questionnaire design document (Word .docx, Excel .xlsx, PDF .pdf, or plain text). Triggers include: "read my questionnaire", "parse questionnaire design", "extract questions from this file", "understand survey structure", "show me the questionnaire layout", "create questionnaire-design.md". This skill produces a standardised `questionnaire-design.md` that captures every question's ID, label/text, answer options, and routing/skip logic — structured so an AI agent can later use it to build or update survy metadata accurately.

  • Installs packages

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 4 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always inspect the raw content first before deciding on a parsing strategy.

    line 33
  2. Very specific:

    When logic is ambiguous, capture the raw wording in a Note: line beneath.

    line 69
  3. Very specific:

    Always write the output as a .md file named questionnaire-design.md (or the name the user specifies).

    line 75
  4. Very specific:

    Add Note: only when the original wording is ambiguous or non-standard.

    line 130
  5. Very specific:

    Use doc.tables first; if empty, fall back to doc.paragraphs.

    line 153
  6. Distinctive:

    Look for a header row containing keywords like "Question", "Code", "Label", "Logic", "Routing".

    line 158
  7. Distinctive:

    If rows alternate between question and option levels, detect the pattern by column indentation or a "Type" column value.

    line 160
  8. Distinctive:

    If the format is unclear, print the first 20 lines/rows and ask the user to confirm the layout before proceeding.

    line 169
  9. Very specific:

    Read the Question IDs and map them to survey["Q1"] variable IDs.

    line 184
  10. Very specific:

    Use Label / Text to populate v.label via survey.update(...).

    line 185
  11. Very specific:

    Use Options to build correct value_indices dicts.

    line 186
  12. Very specific:

    Use Logic to understand which respondents answered each question, and apply survey.filter(...) correctly in analysis.

    line 187
  13. Very specific:

    Use -> Terminate respondent flags to identify and exclude screened-out rows.

    line 189

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Questionnaire Reading Skill

This skill converts a raw questionnaire design document into a structured questionnaire-design.md file. The output becomes the authoritative reference for survey structure, routing logic, and metadata — enabling an AI agent to understand the data before writing any survy code.


1. Input Formats

Accept any of the following:

FormatHow to read
.docxUse python-docx (pip install python-docx) to extract paragraphs and tables
.xlsx / .xlsUse openpyxl (pip install openpyxl) or polars.read_excel() to iterate rows
.pdfUse pdfplumber (pip install pdfplumber) to extract text page by page
.txt / .mdRead directly — plain text, no library needed

Always inspect the raw content first before deciding on a parsing strategy. Questionnaire documents vary widely; read several rows/paragraphs to detect the layout pattern before extracting.


2. Concepts to Extract

For each question, extract:

FieldDescription
Question IDShort code used in data (e.g. Q1, S2, D3). If not present, assign sequentially.
Label / TextThe full question wording shown to respondents.
TypeSingle (one answer), Multi (multiple answers), Open (free text), Number, Grid.
OptionsAnswer choices with their codes/numbers. Capture exactly as designed.
LogicRouting instruction — who sees this question. See Section 3.
TerminateFlag if any option ends the interview (-> Terminate respondent).

3. Logic / Routing Rules

Questionnaire logic is the most important thing to capture accurately. Common patterns and how to write them in the output:

Design wordingOutput phrasing
"Ask all" / "All respondents"Logic: All respondents
"Ask if Q2 = Yes" / "If Q2 = 1"Logic: Ask if Q2 == 1 (Yes)
"Ask if Q3 = 1 or 2"Logic: Ask if Q3 == 1 (Cat) OR Q3 == 2 (Dog)
"Skip to Q5 if Q4 = No"Logic: Ask if Q4 != 2 (No)
"Ask for all non-terminated"Logic: Ask for all respondents (who are not terminated)
"Ask if Q1 is answered"Logic: Ask if Q1 is not empty
Grid sub-questionsLogic: Same as parent grid question

When logic is ambiguous, capture the raw wording in a Note: line beneath.


4. Output Format

Always write the output as a .md file named questionnaire-design.md (or the name the user specifies). Use this exact structure:

# QUESTIONNAIRE DESIGN

---
Question: Q1
Type: Single
Label / Text: Please indicate your gender
Options:
1. Male
2. Female
Logic: All respondents

---
Question: Q2
Type: Single
Label / Text: Do you nurture a pet?
Options:
1. Yes
2. No
Logic: All respondents

---
Question: Q3
Type: Multi
Label / Text: Which type of pet do you nurture?
Options:
1. Cat
2. Dog
3. Other -> Terminate respondent
Logic: Ask if Q2 == 1 (Yes)

---
Question: Q4
Type: Single
Label / Text: Which brand do you choose for pet food?
Options:
1. Brand 1
2. Brand 2
3. Brand 3
Logic: Ask for all respondents (who are not terminated)

Rules for the output:

  • One --- separator before every question block (including the first).
  • Question: — use the ID exactly as it appears in the data file (or the questionnaire code).
  • Type: — one of Single, Multi, Open, Number, Grid.
  • Label / Text: — full question wording; do NOT truncate.
  • Options: — list every answer choice with its numeric code.
    • Append -> Terminate respondent for terminating options.
    • Append -> Skip to Q{n} for options that jump forward.
  • Logic: — concise routing rule using the patterns in Section 3.
  • Add Note: only when the original wording is ambiguous or non-standard.
  • Omit empty fields (e.g. Options: block for Open/Number questions unless codes exist).

5. Step-by-Step Process

  1. Receive the file path from the user.
  2. Read the raw content using the appropriate library (see Section 1).
  3. Identify the layout: Is it a table? Numbered list? Free-form paragraphs?
  4. Extract each question in order, filling in every field from Section 2.
  5. Resolve logic: Map routing instructions to the standard phrasing from Section 3.
  6. Write questionnaire-design.md to the same directory as the input file (or to a path the user specifies).
  7. Print a short summary: total questions found, any questions where logic was unclear (flagged with Note:).

6. Parsing Tips by Format

Word (.docx)

  • Questions are usually in tables (one row per question) or numbered paragraphs.
  • Use doc.tables first; if empty, fall back to doc.paragraphs.
  • Bold text often marks question IDs or labels.
  • Italics or parenthetical text often marks routing instructions.

Excel (.xlsx)

  • Look for a header row containing keywords like "Question", "Code", "Label", "Logic", "Routing".
  • Each subsequent row is typically one question or one answer option.
  • If rows alternate between question and option levels, detect the pattern by column indentation or a "Type" column value.

PDF (.pdf)

  • Extract text page by page with pdfplumber.
  • Questionnaires in PDF often use numbering (Q1, Q2, …) as anchors — split on these.
  • Tables in PDF may be detected via page.extract_tables().
  • Watch for headers/footers repeating on every page — strip them.

Mixed / Unknown

  • If the format is unclear, print the first 20 lines/rows and ask the user to confirm the layout before proceeding.

7. Example Script

See scripts/parse_questionnaire.py for a ready-to-run parser that handles .docx, .xlsx, .pdf, and .txt inputs and writes questionnaire-design.md.


8. Integration with survy

Once questionnaire-design.md exists, an AI agent can:

  • Read the Question IDs and map them to survey["Q1"] variable IDs.
  • Use Label / Text to populate v.label via survey.update(...).
  • Use Options to build correct value_indices dicts.
  • Use Logic to understand which respondents answered each question, and apply survey.filter(...) correctly in analysis.
  • Use -> Terminate respondent flags to identify and exclude screened-out rows.

9. Reference Files

  • scripts/parse_questionnaire.py — ready-to-run parser for docx/xlsx/pdf/txt
  • assets/sample_questionnaire.docx — example Word questionnaire design
  • assets/sample_questionnaire_design.md — expected output for the sample

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.