Ingest course content from markdown files or a content directory into the database — parsing, validating, and upserting weeks, lessons, reflection questions, discussion prompts, and exercises. Use when loading or re-loading course content into the platform database.
Extract per-lesson: id (from heading), title, type (from **Type:** line), body content
Convert markdown body to HTML using the same approach as existing scripts
Handle special blocks:
Blockquotes with > ... followed by — [reference] → scripture blocks
Numbered lists → exercise steps
Reflection questions marked with **Question N:** or numbered items under reflection headings
Child Item Extraction
From lesson content, extract structured child items:
Reflection questions: Look for numbered questions in reflection-type sections. Create reflection_questions rows with question text, question_type, block_order.
Discussion prompts: Look for prompts in discussion/cohort sections. Map to prompt_type (conceptual, application, integration, general) based on E/E/E/J structure.
Exercises: Look for exercise blocks with title, instructions, purpose, estimated time. Create exercises rows.
Validation (Pre-Insert)
Before writing to the database, validate:
All manifest lesson IDs exist in the markdown files
No empty lesson bodies (flag but allow override)
No placeholder text ("[Content TBD]", "[TODO]", "Lorem ipsum")
All lesson types are valid SECTION_TYPES
8 weeks present (numbered 1-8, no Week 0)
Reflection sections have 6-8 questions each (warn if outside range)
Report validation results and ask for confirmation before proceeding.
Suggest running /course-validate [slug] for Charter compliance
Output Format
## Course Ingestion Report: [title] ([slug])
### Source: [path]
### Validation: PASS / FAIL (with details)
### Ingested:
- Course: [title] (id: [id])
- Weeks: 8
- Sections: N total
- Week 1: X sections
- Week 2: X sections
- ...
- Reflection questions: N
- Discussion prompts: N
- Exercises: N
### Warnings:
- [any non-blocking issues]
### Next Steps:
- Run `/course-validate [slug]` to check Charter compliance
- Review draft sections in the learn view at /content/courses/[slug]/learn
Rules
8 weeks, numbered 1-8. No Week 0.
Always upsert (idempotent) — running twice should not create duplicates
Set ingested content to status: "draft" unless the user says otherwise
Never delete existing data — only insert or update
Preserve existing content if a lesson already has non-empty content (warn and skip)
Use the project's existing Drizzle patterns — check {{SERVICES_DIR}}/courses.service.ts for query conventions
1---2name: ingest-content3description: Ingest course content from markdown files or a content directory into the database — parsing, validating, and upserting weeks, lessons, reflection questions, discussion prompts, and exercises. Use when loading or re-loading course content into the platform database.4metadata:5 source: https://skillmd.com/skills/joshuashepherd/ingest-content6---78Ingest course content: $ARGUMENTS910$ARGUMENTS should be a course slug or path to the content directory. If empty, ask the user.1112## Before Starting13141. Read any existing ingestion scripts in `{{SCRIPTS_DIR}}/` to understand patterns (e.g., `{{SCRIPTS_DIR}}/ingest-{{course-slug}}-course.ts`)152. Read `{{SCHEMA_PATH}}` for table definitions (courses, courseWeeks, courseLessons, reflectionQuestions, discussionPrompts, exercises)163. Read `{{SCHEMAS_DIR}}/course-learn.ts` for SECTION_TYPES174. Read `src/lib/config/lesson-types.ts` for type mapping1819## Locate Content Source2021Search for content in these locations (in order):22231. `content-library/courses/[slug]/` — project content library242. `{{PROJECT_ROOT}}/docs/` — standalone course repo (for {{course-slug}})253. A path provided directly by the user2627Look for:28- `course-manifest.json` — lesson order, types, week structure29- `module-*.md` or `week-*.md` — lesson body content30- Any structured markdown with `## Lesson` or `## M.N.X` headings3132## Content Parsing3334### Manifest Format (expected)3536```json37{38 "courseTitle": "The {{COURSE_NAME}}",39 "weeks": [40 {41 "id": 1,42 "title": "Introduction & Orientation",43 "outcomes": ["..."],44 "lessons": [45 { "id": "lesson-01", "title": "Course Overview", "type": "welcome", "sidebarLabel": "Welcome" }46 ]47 }48 ]49}50```5152### Markdown Parsing5354For each `module-*.md` or `week-*.md` file:551. Split on `## Lesson` or `## M` headings562. Extract per-lesson: id (from heading), title, type (from `**Type:**` line), body content573. Convert markdown body to HTML using the same approach as existing scripts584. Handle special blocks:59 - Blockquotes with `> ...` followed by `— [reference]` → scripture blocks60 - Numbered lists → exercise steps61 - Reflection questions marked with `**Question N:**` or numbered items under reflection headings6263### Child Item Extraction6465From lesson content, extract structured child items:6667- **Reflection questions**: Look for numbered questions in reflection-type sections. Create `reflection_questions` rows with question text, question_type, block_order.68- **Discussion prompts**: Look for prompts in discussion/cohort sections. Map to prompt_type (conceptual, application, integration, general) based on E/E/E/J structure.69- **Exercises**: Look for exercise blocks with title, instructions, purpose, estimated time. Create `exercises` rows.7071## Validation (Pre-Insert)7273Before writing to the database, validate:74751. [ ] All manifest lesson IDs exist in the markdown files762. [ ] No empty lesson bodies (flag but allow override)773. [ ] No placeholder text ("[Content TBD]", "[TODO]", "Lorem ipsum")784. [ ] All lesson types are valid SECTION_TYPES795. [ ] 8 weeks present (numbered 1-8, no Week 0)806. [ ] Reflection sections have 6-8 questions each (warn if outside range)8182Report validation results and ask for confirmation before proceeding.8384## Database Operations8586### Create or update the ingestion script8788Create/update `{{SCRIPTS_DIR}}/ingest-[slug]-course.ts` that:89901. Connects via project Drizzle setup (`src/lib/database/`)912. Uses `getOrgId()` for organization scoping923. Upserts in this order:93 - `courses` row (find by slug, update if exists, insert if not)94 - `courseWeeks` rows (find by course_id + week_number, upsert)95 - `courseLessons` rows (find by course_id + slug or section_order, upsert)96 - `reflectionQuestions` rows (find by lesson_id + block_order, upsert)97 - `discussionPrompts` rows (find by lesson_id + block_order, upsert)98 - `exercises` rows (find by lesson_id + block_order, upsert)994. Reports: rows created, rows updated, rows skipped100101### Run the script102103Execute with: `pnpm tsx {{SCRIPTS_DIR}}/ingest-[slug]-course.ts`104105## Post-Ingest Verification106107After ingestion:1081. Query the course to verify section count matches manifest1092. Verify child items (reflection questions, discussion prompts, exercises) are linked correctly1103. Suggest running `/course-validate [slug]` for Charter compliance111112## Output Format113114```115## Course Ingestion Report: [title] ([slug])116117### Source: [path]118### Validation: PASS / FAIL (with details)119120### Ingested:121- Course: [title] (id: [id])122- Weeks: 8123- Sections: N total124 - Week 1: X sections125 - Week 2: X sections126 - ...127- Reflection questions: N128- Discussion prompts: N129- Exercises: N130131### Warnings:132- [any non-blocking issues]133134### Next Steps:135- Run `/course-validate [slug]` to check Charter compliance136- Review draft sections in the learn view at /content/courses/[slug]/learn137```138139## Rules140141- 8 weeks, numbered 1-8. No Week 0.142- Always upsert (idempotent) — running twice should not create duplicates143- Set ingested content to status: "draft" unless the user says otherwise144- Never delete existing data — only insert or update145- Preserve existing content if a lesson already has non-empty content (warn and skip)146- Use the project's existing Drizzle patterns — check `{{SERVICES_DIR}}/courses.service.ts` for query conventions
Run npx get-skill add joshuashepherd/ingest-content in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Ingest course content from markdown files or a content directory into the database — parsing, validating, and upserting weeks, lessons, reflection questions, discussion prompts, and exercises. Use when loading or re-loading course content into the platform database. It is listed under Docs & Writing on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
JoshuaShepherd (@joshuashepherd) published this skill. Their other Agent Skills are listed on their SkillMD profile.