Clinical Trial Search Skill
This skill converts natural language questions into structured API queries against a clinical trial database, then presents the results in a readable format.
Workflow
- Parse user intent — Extract key entities from the user's question
- Build query parameters — Map entities to the query schema below
- Execute the query — Run
scripts/search.py
- Present results — Format and display trials to the user
Step 1: Extract Keywords
Identify the following entity types from the user's question:
| Field |
Type |
Description |
Example |
nctid |
List[str] |
NCT identifier(s) |
["NCT04280783"] |
acronym |
List[str] |
Trial acronym(s) |
["KEYNOTE-590"] |
company |
List[str] |
Sponsor company name(s) |
["Pfizer", "Roche"] |
indication |
List[str] |
Disease / indication |
["lung cancer", "NSCLC"] |
phase |
List[str] |
Trial phase(s) |
["Preclinical", "I", "II", "III", "IV", "Others"] |
target |
dict |
Biological target(s) |
{"logic": "or", "data": ["PD-1", "VEGF"]} |
drug_name |
dict |
Drug name(s) |
{"logic": "or", "data": ["pembrolizumab"]} |
drug_modality |
dict |
Drug modality |
{"logic": "or", "data": ["Vaccine", "mRNA"]} |
drug_feature |
dict |
Drug feature(s) |
{"logic": "or", "data": ["Biologic", "Non-NME"]} |
location |
dict |
Trial location(s) |
{"logic": "or", "data": ["China", "United States", "Japan"]} |
has_result_summary |
bool |
Only trials with result summaries |
true |
official_data |
bool |
Only official data sources |
false |
page_num |
int |
Page index (0-based) |
0 |
page_size |
int |
Results per page (1–200) |
10 |
Dict field format:
{"logic": "or", "data": ["value1", "value2"]}
logic controls how multiple values are combined: "or" (any match) or "and" (all must match). Default to "or" unless the user explicitly wants all terms to apply simultaneously.
data is the list of keyword strings to match.
Type rules:
indication, acronym, company, nctid, phase → plain List[str]
target, drug_name, drug_modality, drug_feature, location, route_of_administration → dict with logic and data
Default to page_num: 0, page_size: 10 unless the user specifies otherwise
Prefer English keywords (the database is indexed in English); translate non-English terms
drug_modality must use exact strings from this set:
[
"Steroids", "Vaccine", "Antisense RNA", "Antibody-Drug Conjugates, ADCs", "Unknown", "Protein Degrader",
"Monoclonal Antibodies", "mRNA", "Others", "Cell-based Therapies", "Imaging Agents", "Gene Therapy",
"miRNA", "Polypeptide", "Recombinant Proteins", "Small Molecule", "siRNA/RNAi", "Trispecific Antibodies",
"Polyclonal Antibodies", "Bi-specific Antibodies", "Glycoconjugates", "Radiopharmaceutical",
"Nucleic Acid-based", "Carbohydrates"
]
drug_feature must use exact strings from this set:
[
"505b2", "Bacterial Product", "Biologic", "Biosimilar", "Device", "Fixed-Dose Combination", "Immuno-Oncology",
"New Molecular Entity (NME)", "Non-NME", "Precision Medicine", "Reformulation", "Specialty Drug", "Viral"
]
Step 2: Execute the Query
python scripts/search.py --params '<JSON string>'
Or using a parameter file:
python scripts/search.py --params-file /tmp/query.json
Add --raw to receive the unformatted JSON response.
Step 3: Interpret Results
The response contains:
total_count — total number of matching trials
results — current page of results, each with NCT ID, title, phase, status, indication, drugs, sponsor, etc.
If results exceed 100, prompt the user to narrow the query. If no results are returned, apply the fallback strategies below before giving up.
Step 3: Review and Fallback Search Strategies
If no results are returned, apply the fallback strategies below before giving up.
When an initial query returns zero or poor results, try these strategies in order:
Strategy 1 — Drug Name Variant Expansion
Trial registries may store drug names inconsistently (INN vs brand name, with/without hyphens, partial codes). Expand drug_name.data to include multiple variants in a single or query.
{
"drug_name": {"logic": "or", "data": ["SHR-A1904", "SHR A1904", "A1904", "SHR1904"]},
"page_num": 0,
"page_size": 50
}
Also try substituting the trial acronym if known:
{
"acronym": ["KEYNOTE-590", "KEYNOTE590", "KN590"],
"page_num": 0,
"page_size": 10
}
Common variant patterns:
- Remove or replace hyphens:
SHR-A1904 → SHR A1904, SHRA1904
- Strip prefix:
9MW-2821 → MW-2821, 9MW2821
- Try both INN and internal code together in the same
data array
Strategy 2 — Sponsor-First with Application-Layer Filtering
When drug name matching is unreliable, anchor on the sponsor company and pull a broad result set, then filter locally by indication, phase, or modality.
{
"company": ["Roche", "Roche Inc"],
"page_num": 0,
"page_size": 200
}
After retrieval, apply local filters:
phase in ["II", "III"]
indication contains "breast cancer"
drug_name matches known code pattern
Use this strategy when the drug code is ambiguous or when searching for a company's full trial portfolio.
Strategy 3 — Broad Target/Indication Search with Post-Filtering
When neither drug name nor company yields results, search by biological target and indication, then narrow client-side by sponsor or drug name pattern.
{
"target": {"logic": "or", "data": ["CLDN18.2", "Nectin-4", "HER2"]},
"indication": ["gastric cancer", "breast cancer"],
"page_num": 0,
"page_size": 200
}
After retrieval, filter by:
- Sponsor name substring (e.g. contains
"Hengrui")
- Drug code prefix (e.g. starts with
SHR, 9MW, A166)
- Trial status (
Recruiting, Active, not recruiting)
Note: If the API supports regex, patterns like (SHR|9MW|A166) can be passed directly in drug_name.data to broaden matching in a single call.
Strategy 4 — Relax Filters Incrementally
If all strategies above still return no results, drop filters one at a time in this order:
- Drop
has_result_summary (many trials have no posted results)
- Drop
phase filter
- Drop
location filter
- Broaden
indication (e.g. "NSCLC" → "lung cancer" → "cancer")
- Remove
drug_modality or drug_feature constraints
Re-run after each relaxation and stop as soon as results appear.
Decision Tree
Initial query returns results?
├── Yes → present results
└── No → Strategy 1: expand drug_name / acronym variants
└── Still no → Strategy 2: sponsor anchor + local filter
└── Still no → Strategy 3: target/indication broad search
└── Still no → Strategy 4: relax filters incrementally
Any step hits HTTP 429?
└── Pause entire chain 15s → resume from current strategy
(sleep ≥5s between every request to avoid triggering 429)
Conversion Examples
User: "Find Phase 3 trials of PD-1 antibodies in lung cancer that have results"
{
"target": {"logic": "or", "data": ["PD-1"]},
"drug_modality": {"logic": "or", "data": ["Monoclonal Antibodies"]},
"indication": ["lung cancer"],
"phase": ["III"],
"has_result_summary": true,
"page_num": 0,
"page_size": 10
}
User: "Look up NCT04280783"
{
"nctid": ["NCT04280783"],
"page_num": 0,
"page_size": 1
}
User: "Roche bispecific antibody trials in China"
{
"company": ["Roche"],
"location": {"logic": "or", "data": ["China"]},
"drug_modality": {"logic": "or", "data": ["Bi-specific Antibodies"]},
"page_num": 0,
"page_size": 10
}
User: "Oral small molecule KRAS G12C inhibitors in colorectal cancer"
{
"target": {"logic": "or", "data": ["KRAS G12C"]},
"drug_modality": {"logic": "or", "data": ["Small Molecule"]},
"indication": ["colorectal cancer"],
"page_num": 0,
"page_size": 10
}
Dependencies
- Python 3.8+
requests library (pip install requests)
- Environment variable
NOAH_API_TOKEN — API authentication token (required)
- Register for a free account at noah.bio to obtain your API key.
Security & Packaging Notes
- This skill only calls NoahAI official HTTPS endpoints under
https://www.noah.bio/api/ and does not contact third-party services.
- It requires exactly one environment variable:
NOAH_API_TOKEN. Store it in the environment or a local .env file, and never place it inline in commands, chats, or packaged files.
- The token is scoped to read medical public details only and cannot access private user records.
- The skill does not intentionally persist request parameters locally. Any server-side retention is determined by the NoahAI API service and its operational logging policies.
- It does not request persistent or system-level privileges and does not modify system configuration.
- The skill is source-file based (Python scripts only) and does not require runtime installs, package downloads, or external bootstrap steps.
1---2name: clinical-trial-search3description: "Search clinical trial databases similar to ClinicalTrials.gov. Use this skill whenever the user asks about clinical trials, drug trials, indications, targets, drug names, trial phases, NCT IDs, enrollment, or recruitment. Automatically parses natural language questions into structured query parameters and calls the backend API to return matching trial records. Trigger words include: clinical trial, NCT, drug development, indication, target, phase, enrollment, recruitment, sponsor, cohort, arm, endpoint, efficacy, safety data."4metadata:5 source: https://skillmd.com/skills/zhangchunsheng/clinical-trial-search6 openclaw:7 emoji: 🔍︎8 requires:9 bins:10 - python311 env:12 - NOAH_API_TOKEN13 primaryEnv: NOAH_API_TOKEN14---1516# Clinical Trial Search Skill1718This skill converts natural language questions into structured API queries against a clinical trial database, then presents the results in a readable format.1920## Workflow21221. **Parse user intent** — Extract key entities from the user's question232. **Build query parameters** — Map entities to the query schema below243. **Execute the query** — Run `scripts/search.py`254. **Present results** — Format and display trials to the user2627## Step 1: Extract Keywords2829Identify the following entity types from the user's question:3031| Field | Type | Description | Example |32|-------|------|-----------------------------------|-----------------------------------------------------------|33| `nctid` | `List[str]` | NCT identifier(s) | `["NCT04280783"]` |34| `acronym` | `List[str]` | Trial acronym(s) | `["KEYNOTE-590"]` |35| `company` | `List[str]` | Sponsor company name(s) | `["Pfizer", "Roche"]` |36| `indication` | `List[str]` | Disease / indication | `["lung cancer", "NSCLC"]` |37| `phase` | `List[str]` | Trial phase(s) | `["Preclinical", "I", "II", "III", "IV", "Others"]` |38| `target` | `dict` | Biological target(s) | `{"logic": "or", "data": ["PD-1", "VEGF"]}` |39| `drug_name` | `dict` | Drug name(s) | `{"logic": "or", "data": ["pembrolizumab"]}` |40| `drug_modality` | `dict` | Drug modality | `{"logic": "or", "data": ["Vaccine", "mRNA"]}` |41| `drug_feature` | `dict` | Drug feature(s) | `{"logic": "or", "data": ["Biologic", "Non-NME"]}` |42| `location` | `dict` | Trial location(s) | `{"logic": "or", "data": ["China", "United States", "Japan"]}` |43| `has_result_summary` | `bool` | Only trials with result summaries | `true` |44| `official_data` | `bool` | Only official data sources | `false` |45| `page_num` | `int` | Page index (0-based) | `0` |46| `page_size` | `int` | Results per page (1–200) | `10` |4748**Dict field format:**49```json50{"logic": "or", "data": ["value1", "value2"]}51```5253- `logic` controls how multiple values are combined: `"or"` (any match) or `"and"` (all must match). Default to `"or"` unless the user explicitly wants all terms to apply simultaneously.54- `data` is the list of keyword strings to match.5556**Type rules:**57- `indication`, `acronym`, `company`, `nctid`, `phase` → plain `List[str]`58- `target`, `drug_name`, `drug_modality`, `drug_feature`, `location`, `route_of_administration` → `dict` with `logic` and `data`59- Default to `page_num: 0, page_size: 10` unless the user specifies otherwise60- Prefer English keywords (the database is indexed in English); translate non-English terms61- `drug_modality` must use exact strings from this set:6263 ```json64 [65 "Steroids", "Vaccine", "Antisense RNA", "Antibody-Drug Conjugates, ADCs", "Unknown", "Protein Degrader",66 "Monoclonal Antibodies", "mRNA", "Others", "Cell-based Therapies", "Imaging Agents", "Gene Therapy",67 "miRNA", "Polypeptide", "Recombinant Proteins", "Small Molecule", "siRNA/RNAi", "Trispecific Antibodies",68 "Polyclonal Antibodies", "Bi-specific Antibodies", "Glycoconjugates", "Radiopharmaceutical",69 "Nucleic Acid-based", "Carbohydrates"70 ]71 ```72- `drug_feature` must use exact strings from this set:7374 ```json75 [76 "505b2", "Bacterial Product", "Biologic", "Biosimilar", "Device", "Fixed-Dose Combination", "Immuno-Oncology",77 "New Molecular Entity (NME)", "Non-NME", "Precision Medicine", "Reformulation", "Specialty Drug", "Viral"78 ]79 ```8081## Step 2: Execute the Query8283```bash84python scripts/search.py --params '<JSON string>'85```8687Or using a parameter file:8889```bash90python scripts/search.py --params-file /tmp/query.json91```9293Add `--raw` to receive the unformatted JSON response.9495## Step 3: Interpret Results9697The response contains:98- `total_count` — total number of matching trials99- `results` — current page of results, each with NCT ID, title, phase, status, indication, drugs, sponsor, etc.100101If results exceed 100, prompt the user to narrow the query. If no results are returned, apply the fallback strategies below before giving up.102103## Step 3: Review and Fallback Search Strategies104If no results are returned, apply the fallback strategies below before giving up.105When an initial query returns zero or poor results, try these strategies **in order**:106107### Strategy 1 — Drug Name Variant Expansion108109Trial registries may store drug names inconsistently (INN vs brand name, with/without hyphens, partial codes). Expand `drug_name.data` to include multiple variants in a single `or` query.110111```json112{113 "drug_name": {"logic": "or", "data": ["SHR-A1904", "SHR A1904", "A1904", "SHR1904"]},114 "page_num": 0,115 "page_size": 50116}117```118119Also try substituting the trial acronym if known:120```json121{122 "acronym": ["KEYNOTE-590", "KEYNOTE590", "KN590"],123 "page_num": 0,124 "page_size": 10125}126```127128**Common variant patterns:**129- Remove or replace hyphens: `SHR-A1904` → `SHR A1904`, `SHRA1904`130- Strip prefix: `9MW-2821` → `MW-2821`, `9MW2821`131- Try both INN and internal code together in the same `data` array132133---134135### Strategy 2 — Sponsor-First with Application-Layer Filtering136137When drug name matching is unreliable, anchor on the sponsor company and pull a broad result set, then filter locally by indication, phase, or modality.138139```json140{141 "company": ["Roche", "Roche Inc"],142 "page_num": 0,143 "page_size": 200144}145```146147After retrieval, apply local filters:148- `phase in ["II", "III"]`149- `indication contains "breast cancer"`150- `drug_name matches known code pattern`151152Use this strategy when the drug code is ambiguous or when searching for a company's full trial portfolio.153154---155156### Strategy 3 — Broad Target/Indication Search with Post-Filtering157158When neither drug name nor company yields results, search by biological target and indication, then narrow client-side by sponsor or drug name pattern.159160```json161{162 "target": {"logic": "or", "data": ["CLDN18.2", "Nectin-4", "HER2"]},163 "indication": ["gastric cancer", "breast cancer"],164 "page_num": 0,165 "page_size": 200166}167```168169After retrieval, filter by:170- Sponsor name substring (e.g. contains `"Hengrui"`)171- Drug code prefix (e.g. starts with `SHR`, `9MW`, `A166`)172- Trial status (`Recruiting`, `Active, not recruiting`)173174> **Note:** If the API supports regex, patterns like `(SHR|9MW|A166)` can be passed directly in `drug_name.data` to broaden matching in a single call.175176---177178### Strategy 4 — Relax Filters Incrementally179180If all strategies above still return no results, drop filters one at a time in this order:1811821. Drop `has_result_summary` (many trials have no posted results)1832. Drop `phase` filter1843. Drop `location` filter1854. Broaden `indication` (e.g. `"NSCLC"` → `"lung cancer"` → `"cancer"`)1865. Remove `drug_modality` or `drug_feature` constraints187188Re-run after each relaxation and stop as soon as results appear.189190---191192## Decision Tree193194```195Initial query returns results?196├── Yes → present results197└── No → Strategy 1: expand drug_name / acronym variants198 └── Still no → Strategy 2: sponsor anchor + local filter199 └── Still no → Strategy 3: target/indication broad search200 └── Still no → Strategy 4: relax filters incrementally201Any step hits HTTP 429?202└── Pause entire chain 15s → resume from current strategy203 (sleep ≥5s between every request to avoid triggering 429)204```205206---207208## Conversion Examples209210**User:** "Find Phase 3 trials of PD-1 antibodies in lung cancer that have results"211212```json213{214 "target": {"logic": "or", "data": ["PD-1"]},215 "drug_modality": {"logic": "or", "data": ["Monoclonal Antibodies"]},216 "indication": ["lung cancer"],217 "phase": ["III"],218 "has_result_summary": true,219 "page_num": 0,220 "page_size": 10221}222```223224---225226**User:** "Look up NCT04280783"227228```json229{230 "nctid": ["NCT04280783"],231 "page_num": 0,232 "page_size": 1233}234```235236---237238**User:** "Roche bispecific antibody trials in China"239240```json241{242 "company": ["Roche"],243 "location": {"logic": "or", "data": ["China"]},244 "drug_modality": {"logic": "or", "data": ["Bi-specific Antibodies"]},245 "page_num": 0,246 "page_size": 10247}248```249250---251252**User:** "Oral small molecule KRAS G12C inhibitors in colorectal cancer"253254```json255{256 "target": {"logic": "or", "data": ["KRAS G12C"]},257 "drug_modality": {"logic": "or", "data": ["Small Molecule"]},258 "indication": ["colorectal cancer"],259 "page_num": 0,260 "page_size": 10261}262```263264---265266## Dependencies267268- Python 3.8+269- `requests` library (`pip install requests`)270- Environment variable `NOAH_API_TOKEN` — API authentication token (required)271 - Register for a free account at [noah.bio](https://noah.bio) to obtain your API key.272273---274275## Security & Packaging Notes276277- This skill only calls NoahAI official HTTPS endpoints under `https://www.noah.bio/api/` and does not contact third-party services.278- It requires exactly one environment variable: `NOAH_API_TOKEN`. Store it in the environment or a local `.env` file, and never place it inline in commands, chats, or packaged files.279- The token is scoped to read medical public details only and cannot access private user records.280- The skill does not intentionally persist request parameters locally. Any server-side retention is determined by the NoahAI API service and its operational logging policies.281- It does not request persistent or system-level privileges and does not modify system configuration.282- The skill is source-file based (Python scripts only) and does not require runtime installs, package downloads, or external bootstrap steps.