Source: https://github.com/aipoch/medical-research-skills
Inclusion Criteria Generator
Generate and optimize clinical trial subject inclusion/exclusion criteria to balance scientific rigor with recruitment feasibility.
Quick Check
Use this command to verify that the packaged script entry point can be parsed before deeper execution.
python -m py_compile scripts/main.py
Audit-Ready Commands
Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
python -m py_compile scripts/main.py
python scripts/main.py --help
python scripts/main.py generate --help
When to Use
- Use this skill when the task is to Generate and optimize clinical trial subject inclusion/exclusion criteria to balance scientific rigor with recruitment feasibility.
- Use this skill for protocol design tasks that require explicit assumptions, bounded scope, and a reproducible output format.
- Use this skill when you need a documented fallback path for missing inputs, execution errors, or partial evidence.
Workflow
- Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.
- Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.
- Use the packaged script path or the documented reasoning path with only the inputs that are actually available.
- Return a structured result that separates assumptions, deliverables, risks, and unresolved items.
- If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.
Use Cases
- Protocol Design: Create initial eligibility criteria for new clinical trials
- Criteria Optimization: Refine existing criteria to improve enrollment without compromising safety/efficacy
- Competitive Analysis: Analyze eligibility patterns across similar trials
- Recruitment Strategy: Identify and mitigate barriers to enrollment
- Feasibility Assessment: Evaluate if proposed criteria are realistic for target population
Usage
CLI Usage
# Generate criteria from study design
python scripts/main.py generate \
--indication "Type 2 Diabetes" \
--phase "Phase 2" \
--population "adults" \
--duration "24 weeks" \
--output criteria.json
# Optimize existing criteria
python scripts/main.py optimize \
--input current_criteria.json \
--enrollment-target 200 \
--current-enrollment 120 \
--output optimized_criteria.json
# Analyze criteria complexity
python scripts/main.py analyze \
--input criteria.json \
--output analysis_report.json
# Compare with competitor trials
python scripts/main.py benchmark \
--input criteria.json \
--condition "Type 2 Diabetes" \
--output benchmark_report.json
Python API
from scripts.main import CriteriaGenerator, CriteriaOptimizer
# Generate new criteria
generator = CriteriaGenerator()
criteria = generator.generate(
indication="Type 2 Diabetes",
phase="Phase 2",
population="adults",
study_duration="24 weeks",
endpoints=["HbA1c reduction", "weight change"]
)
# Optimize existing criteria
optimizer = CriteriaOptimizer()
optimized = optimizer.optimize(
criteria=existing_criteria,
enrollment_target=200,
current_enrollment=120,
retention_rate=0.85
)
# Analyze criteria complexity
analysis = optimizer.analyze_complexity(criteria)
Input Format
Study Design Parameters
{
"indication": "Type 2 Diabetes Mellitus",
"phase": "Phase 2",
"population": "adults",
"age_range": {"min": 18, "max": 75},
"study_duration": "24 weeks",
"treatment_type": "oral",
"primary_endpoints": ["HbA1c change from baseline"],
"safety_considerations": ["cardiovascular risk"],
"concomitant_meds_allowed": ["metformin"]
}
Existing Criteria Format
{
"inclusion_criteria": [
{
"id": "I1",
"criterion": "Age 18-75 years",
"rationale": "Adult population per regulatory guidance",
"category": "demographics"
}
],
"exclusion_criteria": [
{
"id": "E1",
"criterion": "HbA1c < 7.0% or > 11.0%",
"rationale": "Ensure measurable treatment effect",
"category": "disease_severity"
}
]
}
Output Format
Generated/Optimized Criteria
{
"inclusion_criteria": [
{
"id": "I1",
"criterion": "Age 18-75 years, inclusive",
"category": "demographics",
"rationale": "Adult population; upper limit for safety",
"priority": "required",
"impact": "low"
}
],
"exclusion_criteria": [
{
"id": "E1",
"criterion": "HbA1c < 7.5% or > 10.5% at screening",
"category": "disease_severity",
"rationale": "Optimal range for detecting treatment effect",
"priority": "required",
"impact": "medium",
"flexibility": "widen by 0.5% if enrollment slow"
}
],
"optimization_notes": [
"Widened HbA1c range from 7.0-11.0% to 7.5-10.5% based on feasibility data"
],
"recruitment_metrics": {
"estimated_screen_success_rate": 0.35,
"estimated_enrollment_rate": 0.65,
"key_barriers": ["HbA1c upper limit", "concomitant medication restrictions"]
}
}
Criteria Categories
| Category |
Description |
Examples |
| demographics |
Age, sex, race, ethnicity |
Age 18-75, women of childbearing potential |
| disease_severity |
Disease stage, severity markers |
HbA1c range, tumor stage, NYHA class |
| medical_history |
Prior conditions, comorbidities |
No cardiovascular events within 6 months |
| concomitant_meds |
Allowed/prohibited medications |
Stable metformin dose allowed |
| laboratory |
Lab value requirements |
eGFR > 30 mL/min, normal liver function |
| lifestyle |
Diet, exercise, habits |
Non-smoker, willing to maintain diet |
| compliance |
Ability to participate |
Able to provide informed consent |
| safety |
Risk minimization criteria |
No history of severe hypoglycemia |
Optimization Strategies
Common Modifications
| Issue |
Strategy |
Example |
| Narrow age range |
Widen limits |
18-70 → 18-75 years |
| Restrictive lab values |
Adjust thresholds |
eGFR > 60 → eGFR > 30 mL/min |
| Comorbidity exclusions |
Add time limits |
Exclude "current" vs "history of" |
| Medication washouts |
Shorten periods |
4 weeks → 2 weeks |
| Geographic barriers |
Add telemedicine |
Include remote visits option |
Retention Considerations
- Minimize visit frequency when possible
- Allow window periods for visit timing
- Provide transportation assistance language
- Consider patient-reported outcome burden
Technical Details
- Difficulty: Medium
- Standards: ICH E6(R2) GCP, CDISC Protocol Representation Model
- Data Sources: ClinicalTrials.gov eligibility patterns, literature feasibility data
- Dependencies: None (pure Python)
References
references/criteria_templates.json - Templates by therapeutic area
references/optimization_guidelines.md - Best practices for criteria optimization
references/common_pitfalls.md - Frequent eligibility design mistakes
references/regulatory_guidance.md - FDA/EMA guidance on eligibility criteria
references/feasibility_data.json - Screen failure rates by criterion type
Security Checklist
Prerequisites
# Python dependencies
pip install -r requirements.txt
Parameters
| Parameter |
Type |
Default |
Description |
--indication |
str |
Required |
Therapeutic indication |
--phase |
str |
Required |
|
--population |
str |
"adults" |
Target population |
--duration |
str |
"" |
Study duration |
--output |
str |
Required |
Output file path |
--age-min |
int |
18 |
Minimum age |
--age-max |
int |
75 |
Maximum age |
--input |
str |
Required |
Input criteria JSON file |
--enrollment-target |
int |
Required |
Target enrollment |
--current-enrollment |
int |
Required |
Current enrollment |
--output |
str |
Required |
Output file path |
--input |
str |
Required |
Input criteria JSON file |
--output |
str |
Required |
Output file path |
--input |
str |
Required |
Input criteria JSON file |
--condition |
str |
Required |
Medical condition |
--output |
str |
Required |
Output file path |
Output Requirements
Every final response should make these items explicit when they are relevant:
- Objective or requested deliverable
- Inputs used and assumptions introduced
- Workflow or decision path
- Core result, recommendation, or artifact
- Constraints, risks, caveats, or validation needs
- Unresolved items and next-step checks
Error Handling
- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
- If
scripts/main.py fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
- Do not fabricate files, citations, data, search results, or execution outcomes.
Input Validation
This skill accepts requests that match the documented purpose of inclusion-criteria-gen and include enough context to complete the workflow safely.
Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
inclusion-criteria-gen only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
Response Template
Use the following fixed structure for non-trivial requests:
- Objective
- Inputs Received
- Assumptions
- Workflow
- Deliverable
- Risks and Limits
- Next Checks
If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.
When Not to Use
- Do not proceed when required input files, identifiers, parameters, or context are missing — ask the user to provide them first.
- Do not assume capabilities beyond this skill's declared scope when the user requests external operations or inferences.
- Do not proceed without user confirmation when overwriting existing results, executing high-cost batch operations, or expanding task scope.
Required Inputs
| Field |
Required |
Format/Source |
Example |
If Missing |
| User task description |
Yes |
Text |
Research question, writing goal, analysis objective |
Stop and ask user to provide |
| Primary input material |
Depends on task |
Text, file path, ID, table, or literature |
PMID, PDF, CSV, DOCX, keywords, etc. |
Specify which material type is missing |
| Output preference |
No |
Text |
Language, format, target journal, template |
Use skill default format |
Output Contract
- Primary output: Structured result or target file aligned with this skill's objective.
- Optional output: Intermediate check notes, issue list, supplementary suggestions, or generated file paths.
- Format requirement: Unless the user specifies otherwise, prefer stable, reviewable Markdown or JSON; if the skill's bundled script requires a fixed format, use that format.
- If partially complete: Must explicitly mark as PARTIAL and state which steps are completed and which remain.
Failure Handling
- Missing critical input: Explicitly state which fields, files, or identifiers are missing and pause.
- Script, template, or resource execution failure: Report the failing step, likely cause, and recovery suggestions — do not silently degrade.
- Partial completion only: Return the verified portion first, then list remaining blockers and suggested next steps.
User Checkpoints
- Before executing batch processing, overwriting files, long-running searches, or multi-stage generation, confirm scope and output format with the user.
- Before proceeding when a key judgment is ambiguous, evidence is insufficient, or the workflow is entering the next stage, confirm with the user.
Quick Validation
- Check that key scripts, templates, or reference file paths this skill depends on exist.
- Check that the final output contains the core fields, sections, or files specified for this task.
- Check that results clearly mark assumptions, limitations, and incomplete items.
1---2name: inclusion-criteria-gen3description: Generate and optimize clinical trial subject inclusion/exclusion criteria to balance scientific rigor with recruitment feasibility.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8# Inclusion Criteria Generator
9
10Generate and optimize clinical trial subject inclusion/exclusion criteria to balance scientific rigor with recruitment feasibility.
11
12## Quick Check
13
14Use this command to verify that the packaged script entry point can be parsed before deeper execution.
15
16```bash
17python -m py_compile scripts/main.py
18```
19
20## Audit-Ready Commands
21
22Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.
23
24```bash
25python -m py_compile scripts/main.py
26python scripts/main.py --help
27python scripts/main.py generate --help
28```
29
30## When to Use
31
32- Use this skill when the task is to Generate and optimize clinical trial subject inclusion/exclusion criteria to balance scientific rigor with recruitment feasibility.
33- Use this skill for protocol design tasks that require explicit assumptions, bounded scope, and a reproducible output format.
34- Use this skill when you need a documented fallback path for missing inputs, execution errors, or partial evidence.
35
36## Workflow
37
381. Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.
392. Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.
403. Use the packaged script path or the documented reasoning path with only the inputs that are actually available.
414. Return a structured result that separates assumptions, deliverables, risks, and unresolved items.
425. If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.
43
44## Use Cases
45
46- **Protocol Design**: Create initial eligibility criteria for new clinical trials
47- **Criteria Optimization**: Refine existing criteria to improve enrollment without compromising safety/efficacy
48- **Competitive Analysis**: Analyze eligibility patterns across similar trials
49- **Recruitment Strategy**: Identify and mitigate barriers to enrollment
50- **Feasibility Assessment**: Evaluate if proposed criteria are realistic for target population
51
52## Usage
53
54### CLI Usage
55
56```text
57# Generate criteria from study design
58python scripts/main.py generate \
59 --indication "Type 2 Diabetes" \
60 --phase "Phase 2" \
61 --population "adults" \
62 --duration "24 weeks" \
63 --output criteria.json
64
65# Optimize existing criteria
66python scripts/main.py optimize \
67 --input current_criteria.json \
68 --enrollment-target 200 \
69 --current-enrollment 120 \
70 --output optimized_criteria.json
71
72# Analyze criteria complexity
73python scripts/main.py analyze \
74 --input criteria.json \
75 --output analysis_report.json
76
77# Compare with competitor trials
78python scripts/main.py benchmark \
79 --input criteria.json \
80 --condition "Type 2 Diabetes" \
81 --output benchmark_report.json
82```
83
84### Python API
85
86```python
87from scripts.main import CriteriaGenerator, CriteriaOptimizer
88
89# Generate new criteria
90generator = CriteriaGenerator()
91criteria = generator.generate(
92 indication="Type 2 Diabetes",
93 phase="Phase 2",
94 population="adults",
95 study_duration="24 weeks",
96 endpoints=["HbA1c reduction", "weight change"]
97)
98
99# Optimize existing criteria
100optimizer = CriteriaOptimizer()
101optimized = optimizer.optimize(
102 criteria=existing_criteria,
103 enrollment_target=200,
104 current_enrollment=120,
105 retention_rate=0.85
106)
107
108# Analyze criteria complexity
109analysis = optimizer.analyze_complexity(criteria)
110```
111
112## Input Format
113
114### Study Design Parameters
115
116```json
117{
118 "indication": "Type 2 Diabetes Mellitus",
119 "phase": "Phase 2",
120 "population": "adults",
121 "age_range": {"min": 18, "max": 75},
122 "study_duration": "24 weeks",
123 "treatment_type": "oral",
124 "primary_endpoints": ["HbA1c change from baseline"],
125 "safety_considerations": ["cardiovascular risk"],
126 "concomitant_meds_allowed": ["metformin"]
127}
128```
129
130### Existing Criteria Format
131
132```json
133{
134 "inclusion_criteria": [
135 {
136 "id": "I1",
137 "criterion": "Age 18-75 years",
138 "rationale": "Adult population per regulatory guidance",
139 "category": "demographics"
140 }
141 ],
142 "exclusion_criteria": [
143 {
144 "id": "E1",
145 "criterion": "HbA1c < 7.0% or > 11.0%",
146 "rationale": "Ensure measurable treatment effect",
147 "category": "disease_severity"
148 }
149 ]
150}
151```
152
153## Output Format
154
155### Generated/Optimized Criteria
156
157```json
158{
159 "inclusion_criteria": [
160 {
161 "id": "I1",
162 "criterion": "Age 18-75 years, inclusive",
163 "category": "demographics",
164 "rationale": "Adult population; upper limit for safety",
165 "priority": "required",
166 "impact": "low"
167 }
168 ],
169 "exclusion_criteria": [
170 {
171 "id": "E1",
172 "criterion": "HbA1c < 7.5% or > 10.5% at screening",
173 "category": "disease_severity",
174 "rationale": "Optimal range for detecting treatment effect",
175 "priority": "required",
176 "impact": "medium",
177 "flexibility": "widen by 0.5% if enrollment slow"
178 }
179 ],
180 "optimization_notes": [
181 "Widened HbA1c range from 7.0-11.0% to 7.5-10.5% based on feasibility data"
182 ],
183 "recruitment_metrics": {
184 "estimated_screen_success_rate": 0.35,
185 "estimated_enrollment_rate": 0.65,
186 "key_barriers": ["HbA1c upper limit", "concomitant medication restrictions"]
187 }
188}
189```
190
191## Criteria Categories
192
193| Category | Description | Examples |
194|----------|-------------|----------|
195| demographics | Age, sex, race, ethnicity | Age 18-75, women of childbearing potential |
196| disease_severity | Disease stage, severity markers | HbA1c range, tumor stage, NYHA class |
197| medical_history | Prior conditions, comorbidities | No cardiovascular events within 6 months |
198| concomitant_meds | Allowed/prohibited medications | Stable metformin dose allowed |
199| laboratory | Lab value requirements | eGFR > 30 mL/min, normal liver function |
200| lifestyle | Diet, exercise, habits | Non-smoker, willing to maintain diet |
201| compliance | Ability to participate | Able to provide informed consent |
202| safety | Risk minimization criteria | No history of severe hypoglycemia |
203
204## Optimization Strategies
205
206### Common Modifications
207
208| Issue | Strategy | Example |
209|-------|----------|---------|
210| Narrow age range | Widen limits | 18-70 → 18-75 years |
211| Restrictive lab values | Adjust thresholds | eGFR > 60 → eGFR > 30 mL/min |
212| Comorbidity exclusions | Add time limits | Exclude "current" vs "history of" |
213| Medication washouts | Shorten periods | 4 weeks → 2 weeks |
214| Geographic barriers | Add telemedicine | Include remote visits option |
215
216### Retention Considerations
217
218- Minimize visit frequency when possible
219- Allow window periods for visit timing
220- Provide transportation assistance language
221- Consider patient-reported outcome burden
222
223## Technical Details
224
225- **Difficulty**: Medium
226- **Standards**: ICH E6(R2) GCP, CDISC Protocol Representation Model
227- **Data Sources**: ClinicalTrials.gov eligibility patterns, literature feasibility data
228- **Dependencies**: None (pure Python)
229
230## References
231
232- `references/criteria_templates.json` - Templates by therapeutic area
233- `references/optimization_guidelines.md` - Best practices for criteria optimization
234- `references/common_pitfalls.md` - Frequent eligibility design mistakes
235- `references/regulatory_guidance.md` - FDA/EMA guidance on eligibility criteria
236- `references/feasibility_data.json` - Screen failure rates by criterion type
237
238## Security Checklist
239
240- [ ] No hardcoded credentials or API keys
241- [ ] No unauthorized file system access (../)
242- [ ] Output does not expose sensitive information
243- [ ] Prompt injection protections in place
244- [ ] API requests use HTTPS only
245- [ ] Input validated against allowed patterns
246- [ ] API timeout and retry mechanisms implemented
247- [ ] Output directory restricted to workspace
248- [ ] Script execution in sandboxed environment
249- [ ] Error messages sanitized (no internal paths exposed)
250- [ ] Dependencies audited
251- [ ] No exposure of internal service architecture
252
253## Prerequisites
254
255```text
256# Python dependencies
257pip install -r requirements.txt
258```
259
260## Parameters
261
262| Parameter | Type | Default | Description |
263|-----------|------|---------|-------------|
264| `--indication` | str | Required | Therapeutic indication |
265| `--phase` | str | Required | |
266| `--population` | str | "adults" | Target population |
267| `--duration` | str | "" | Study duration |
268| `--output` | str | Required | Output file path |
269| `--age-min` | int | 18 | Minimum age |
270| `--age-max` | int | 75 | Maximum age |
271| `--input` | str | Required | Input criteria JSON file |
272| `--enrollment-target` | int | Required | Target enrollment |
273| `--current-enrollment` | int | Required | Current enrollment |
274| `--output` | str | Required | Output file path |
275| `--input` | str | Required | Input criteria JSON file |
276| `--output` | str | Required | Output file path |
277| `--input` | str | Required | Input criteria JSON file |
278| `--condition` | str | Required | Medical condition |
279| `--output` | str | Required | Output file path |
280
281## Output Requirements
282
283Every final response should make these items explicit when they are relevant:
284
285- Objective or requested deliverable
286- Inputs used and assumptions introduced
287- Workflow or decision path
288- Core result, recommendation, or artifact
289- Constraints, risks, caveats, or validation needs
290- Unresolved items and next-step checks
291
292## Error Handling
293
294- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
295- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
296- If `scripts/main.py` fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
297- Do not fabricate files, citations, data, search results, or execution outcomes.
298
299## Input Validation
300
301This skill accepts requests that match the documented purpose of `inclusion-criteria-gen` and include enough context to complete the workflow safely.
302
303Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
304
305> `inclusion-criteria-gen` only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
306
307## Response Template
308
309Use the following fixed structure for non-trivial requests:
310
3111. Objective
3122. Inputs Received
3133. Assumptions
3144. Workflow
3155. Deliverable
3166. Risks and Limits
3177. Next Checks
318
319If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.
320
321## When Not to Use
322
323- Do not proceed when required input files, identifiers, parameters, or context are missing — ask the user to provide them first.
324- Do not assume capabilities beyond this skill's declared scope when the user requests external operations or inferences.
325- Do not proceed without user confirmation when overwriting existing results, executing high-cost batch operations, or expanding task scope.
326
327## Required Inputs
328
329| Field | Required | Format/Source | Example | If Missing |
330|---|---|---|---|---|
331| User task description | Yes | Text | Research question, writing goal, analysis objective | Stop and ask user to provide |
332| Primary input material | Depends on task | Text, file path, ID, table, or literature | PMID, PDF, CSV, DOCX, keywords, etc. | Specify which material type is missing |
333| Output preference | No | Text | Language, format, target journal, template | Use skill default format |
334
335## Output Contract
336
337- Primary output: Structured result or target file aligned with this skill's objective.
338- Optional output: Intermediate check notes, issue list, supplementary suggestions, or generated file paths.
339- Format requirement: Unless the user specifies otherwise, prefer stable, reviewable Markdown or JSON; if the skill's bundled script requires a fixed format, use that format.
340- If partially complete: Must explicitly mark as PARTIAL and state which steps are completed and which remain.
341
342## Failure Handling
343
344- Missing critical input: Explicitly state which fields, files, or identifiers are missing and pause.
345- Script, template, or resource execution failure: Report the failing step, likely cause, and recovery suggestions — do not silently degrade.
346- Partial completion only: Return the verified portion first, then list remaining blockers and suggested next steps.
347
348## User Checkpoints
349
350- Before executing batch processing, overwriting files, long-running searches, or multi-stage generation, confirm scope and output format with the user.
351- Before proceeding when a key judgment is ambiguous, evidence is insufficient, or the workflow is entering the next stage, confirm with the user.
352
353## Quick Validation
354
355- Check that key scripts, templates, or reference file paths this skill depends on exist.
356- Check that the final output contains the core fields, sections, or files specified for this task.
357- Check that results clearly mark assumptions, limitations, and incomplete items.