Skip to content

Commit b7789b6

Browse files
Merge pull request #43 from MarkusNeusinger/claude/rules-markdown-prompts-016ovKdqsbHgByE45Gxd3uZS
refactor: replace rules/ with prompts/ system
2 parents 252b394 + e80c946 commit b7789b6

28 files changed

Lines changed: 1890 additions & 4619 deletions

.github/workflows/bot-validate-request.yml

Lines changed: 10 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -85,139 +85,23 @@ jobs:
8585
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
8686
claude_args: "--model opus"
8787
prompt: |
88-
## 🔍 Task: Validate Plot Request and Assign Spec ID
88+
## Task: Validate Plot Request and Assign Spec ID
8989
90-
A new plot request has been submitted. Your job is to:
91-
1. Analyze the request
92-
2. Check for duplicates/similar specs
93-
3. Assign a meaningful spec ID (or flag as duplicate)
90+
Read the rules from `prompts/spec-id-generator.md` and follow them.
9491
9592
### Issue Details
9693
- **Title:** ${{ github.event.issue.title }}
9794
- **Number:** #${{ github.event.issue.number }}
98-
99-
### Issue Body:
95+
- **Body:**
10096
```
10197
${{ github.event.issue.body }}
10298
```
10399
104-
### Instructions
105-
106-
#### Step 1: Read all existing specs
107-
- List all files in `specs/` directory (excluding .template.md and VERSIONING.md)
108-
- Read each spec file to understand what plots already exist
109-
- Pay attention to: Description, Tags, Use Cases
110-
111-
#### Step 2: Analyze the request
112-
- What type of plot is being requested? (scatter, bar, line, heatmap, etc.)
113-
- What variant/feature is being requested? (basic, grouped, stacked, 3d, etc.)
114-
- What makes it unique? (regression, animation, interactive, etc.)
115-
116-
#### Step 3: Check for duplicates
117-
Compare the request against existing specs:
118-
- **Exact duplicate**: Same plot type AND same features → Flag as duplicate
119-
- **Very similar** (>80% overlap): Same type, minor differences → Suggest existing spec
120-
- **Related but different**: Same type, different features → New spec OK
121-
- **Completely new**: New plot type → New spec OK
122-
123-
#### Step 4: Generate spec ID (if not duplicate)
124-
125-
**ID Format:** `{plot-type}-{variant}-{modifier}` (all lowercase, hyphens only)
126-
127-
**Rules:**
128-
- `plot-type`: The main visualization type (scatter, bar, line, heatmap, histogram, box, violin, pie, area, radar, etc.)
129-
- `variant`: The main characteristic (basic, grouped, stacked, horizontal, 3d, multi, etc.)
130-
- `modifier`: Optional - additional feature (regression, animated, interactive, annotated, etc.)
131-
132-
**Examples:**
133-
- Basic scatter plot → `scatter-basic`
134-
- Scatter with color mapping → `scatter-color-mapped`
135-
- Scatter with linear regression → `scatter-regression-linear`
136-
- 3D scatter with rotation → `scatter-3d-interactive`
137-
- Grouped bar chart → `bar-grouped`
138-
- Horizontal stacked bar → `bar-stacked-horizontal`
139-
- Correlation heatmap → `heatmap-correlation`
140-
- Annotated heatmap → `heatmap-annotated`
141-
- Multi-line time series → `line-timeseries-multi`
142-
- Box plot with outliers → `box-outliers-highlighted`
143-
144-
**ID must be:**
145-
- Unique (not already used)
146-
- Descriptive (someone can guess what it does)
147-
- Concise (2-3 parts, max 40 characters)
148-
- Lowercase with hyphens only
149-
150-
#### Step 5: Post comment with result
151-
152-
Use `gh issue comment` to post ONE of these responses:
153-
154-
**If DUPLICATE:**
155-
```markdown
156-
## 🔄 Duplicate Detected
157-
158-
This plot request appears to be a duplicate of an existing spec:
159-
160-
**Existing Spec:** `{existing-spec-id}`
161-
**File:** `specs/{existing-spec-id}.md`
162-
163-
**Similarity:** {brief explanation of why it's a duplicate}
164-
165-
Please review the existing spec. If you believe this is different, please update the issue with more details about what makes it unique.
166-
167-
---
168-
🤖 *Generated by [validate-plot-request workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*
169-
```
170-
171-
**If SIMILAR (suggest existing):**
172-
```markdown
173-
## ⚠️ Similar Spec Exists
174-
175-
This request is very similar to an existing spec:
176-
177-
**Existing Spec:** `{existing-spec-id}`
178-
**File:** `specs/{existing-spec-id}.md`
179-
180-
**Differences:** {brief explanation}
181-
182-
**Options:**
183-
1. Use the existing spec if it meets your needs
184-
2. Update this issue to clarify the unique requirements
185-
3. Consider this a variant of the existing spec
186-
187-
---
188-
🤖 *Generated by [validate-plot-request workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*
189-
```
190-
191-
**If NEW (assign ID):**
192-
```markdown
193-
## ✅ Spec ID Assigned
194-
195-
**Assigned ID:** `{new-spec-id}`
196-
197-
**Rationale:** {1-2 sentences explaining why this ID was chosen}
198-
199-
**Next Steps:**
200-
1. A maintainer will review this request
201-
2. Once approved (label: `approved`), code generation will begin automatically
202-
3. Implementations will be created for matplotlib and seaborn
203-
204-
**Spec will be created at:** `specs/{new-spec-id}.md`
205-
206-
---
207-
🤖 *Generated by [validate-plot-request workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*
208-
```
209-
210-
#### Step 6: Update issue title with spec ID (if NEW)
211-
212-
After posting the comment, update the issue title to include the spec ID in brackets:
213-
- Use: `gh issue edit ${{ github.event.issue.number }} --title "ORIGINAL_TITLE [{new-spec-id}]"`
214-
- Example: "Plot: Basic bar chart" → "Plot: Basic bar chart [bar-basic]"
215-
- This makes issues searchable by spec ID
100+
### Process
101+
1. Read `prompts/spec-id-generator.md` for full instructions
102+
2. List all existing specs in `specs/` directory
103+
3. Analyze the request and check for duplicates
104+
4. Post comment using `gh issue comment ${{ github.event.issue.number }} --body "..."`
105+
5. If NEW: Update title with `gh issue edit ${{ github.event.issue.number }} --title "..."`
216106
217-
### Important Notes
218-
- Do NOT create any files - only analyze and comment
219-
- Do NOT add or remove labels
220-
- Use `gh issue comment ${{ github.event.issue.number }} --body "..."` to post comment
221-
- Use `gh issue edit ${{ github.event.issue.number }} --title "..."` to update title (only for NEW specs)
222-
- Be helpful and constructive in feedback
223-
- If the request is unclear, ask for clarification in the comment
107+
Workflow URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

.github/workflows/gen-new-plot.yml

Lines changed: 27 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -121,89 +121,33 @@ jobs:
121121
uses: anthropics/claude-code-action@v1
122122
with:
123123
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
124-
claude_args: "--model opus" # Use Haiku model for testing Opus for production
124+
claude_args: "--model opus"
125125
additional_permissions: |
126126
actions: read
127127
prompt: |
128-
## 🎯 Task: Generate Plot Implementations for All 8 Libraries
129-
130-
This issue has been approved! Please generate implementations for **${{ steps.extract_spec.outputs.spec_id }}**.
131-
132-
### Instructions
133-
134-
1. **Read the specification**
135-
- File: `specs/${{ steps.extract_spec.outputs.spec_id }}.md`
136-
- If file doesn't exist, create it from the issue body
137-
138-
2. **Read generation rules**
139-
- `rules/generation/v1.0.0-draft/code-generation-rules.md`
140-
- `rules/generation/v1.0.0-draft/quality-criteria.md`
141-
- `rules/generation/v1.0.0-draft/self-review-checklist.md`
142-
143-
3. **Generate implementations for all 8 libraries** (in order of priority):
144-
145-
**3.1 matplotlib**
146-
- Determine the correct plot type folder from spec (e.g., histogram, scatter, bar, line, etc.)
147-
- Target: `plots/matplotlib/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
148-
- Follow generation rules exactly
149-
- Implement all spec requirements
150-
- Use type hints, docstrings, validation
151-
- Add standalone execution block (`if __name__ == '__main__':`)
152-
- Self-review: Max 3 attempts to pass quality criteria
153-
154-
**3.2 seaborn**
155-
- Determine the correct seaborn function folder (e.g., histplot, scatterplot, barplot, etc.)
156-
- Target: `plots/seaborn/{seaborn_function}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
157-
- Same requirements as matplotlib
158-
159-
**3.3 plotly**
160-
- Target: `plots/plotly/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
161-
- Use plotly.express or plotly.graph_objects as appropriate
162-
- Ensure interactive features work
163-
164-
**3.4 bokeh**
165-
- Target: `plots/bokeh/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
166-
- Use bokeh.plotting interface
167-
- Include output_file() for standalone HTML generation
168-
169-
**3.5 altair**
170-
- Target: `plots/altair/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
171-
- Use declarative Vega-Lite approach
172-
- Leverage altair's data transformations where appropriate
173-
174-
**3.6 plotnine**
175-
- Target: `plots/plotnine/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
176-
- Use ggplot2-style grammar of graphics
177-
- Follow plotnine idioms (aes, geom_*, etc.)
178-
179-
**3.7 pygal**
180-
- Target: `plots/pygal/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
181-
- Generate SVG output
182-
- Use pygal's chart classes
183-
184-
**3.8 highcharts**
185-
- Target: `plots/highcharts/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
186-
- Use highcharts-core library (from highcharts_core import Chart)
187-
- Generate interactive HTML output
188-
- Note: Requires license for commercial use
189-
190-
4. **Create Pull Request**
191-
- Branch: `auto/${{ steps.extract_spec.outputs.spec_id }}`
192-
- Title: `feat: implement ${{ steps.extract_spec.outputs.spec_id }}`
193-
- Include summary of generation results for ALL libraries
194-
- Link to this issue (#${{ github.event.issue.number }})
195-
196-
### Requirements
197-
- Each implementation must pass self-review before moving to next
198-
- Use deterministic sample data (fixed seeds or hardcoded data)
199-
- Code must work standalone (no external files)
200-
- Follow Python 3.10+ syntax
201-
- Commit with clear messages
202-
- If a library doesn't support the plot type well, note this in the PR but still try to create a reasonable approximation
203-
204-
### Expected Outcome
205-
- PR created with implementations for all 8 libraries
206-
- All pass self-review (score ≥ 85)
207-
- Tests will run automatically on PR
208-
209-
Please proceed with the generation!
128+
## Task: Generate Plot Implementations
129+
130+
Generate implementations for **${{ steps.extract_spec.outputs.spec_id }}** for all 8 libraries.
131+
132+
### Read these files first:
133+
1. `prompts/plot-generator.md` - Base generation rules
134+
2. `prompts/quality-criteria.md` - Quality requirements
135+
3. `specs/${{ steps.extract_spec.outputs.spec_id }}.md` - The specification (create from issue body if missing)
136+
137+
### For each library, also read:
138+
- `prompts/library/{library}.md` - Library-specific rules
139+
140+
### Generate implementations for:
141+
1. matplotlib → `plots/matplotlib/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
142+
2. seaborn → `plots/seaborn/{function}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
143+
3. plotly → `plots/plotly/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
144+
4. bokeh → `plots/bokeh/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
145+
5. altair → `plots/altair/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
146+
6. plotnine → `plots/plotnine/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
147+
7. pygal → `plots/pygal/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
148+
8. highcharts → `plots/highcharts/{plot_type}/${{ steps.extract_spec.outputs.spec_id }}/default.py`
149+
150+
### Create PR:
151+
- Branch: `auto/${{ steps.extract_spec.outputs.spec_id }}`
152+
- Title: `feat: implement ${{ steps.extract_spec.outputs.spec_id }}`
153+
- Link to issue #${{ github.event.issue.number }}

CLAUDE.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ The same spec ID links implementations across all 8 supported libraries.
124124
- **`core/`**: Shared business logic (database, repositories, config)
125125
- **`api/`**: FastAPI backend (routers, schemas, dependencies)
126126
- **`app/`**: Next.js frontend (React + TypeScript + Vite + MUI)
127-
- **`rules/`**: Versioned rules for AI code generation and quality evaluation
127+
- **`prompts/`**: AI agent prompts for code generation, quality evaluation, and tagging
128128
- **`tests/unit/`**: Unit tests mirroring source structure
129129
- **`docs/`**: Architecture and workflow documentation
130130

@@ -218,25 +218,49 @@ uv run alembic revision --autogenerate -m "description"
218218
uv run alembic upgrade head
219219
```
220220

221-
## Versioned Rules System
221+
## Prompts System
222222

223-
The `rules/` directory contains versioned rules for AI code generation and quality evaluation.
223+
The `prompts/` directory contains AI agent prompts for code generation, quality evaluation, and tagging.
224224

225-
### Working with Rules
225+
### Prompt Files
226+
227+
| File | Purpose |
228+
|------|---------|
229+
| `plot-generator.md` | Base rules for all plot implementations |
230+
| `library/*.md` | Library-specific rules (8 files) |
231+
| `quality-criteria.md` | Definition of code/visual quality |
232+
| `quality-evaluator.md` | Multi-LLM evaluation prompt |
233+
| `auto-tagger.md` | Automatic tagging across 5 dimensions |
234+
| `spec-validator.md` | Validates plot request issues |
235+
| `spec-id-generator.md` | Assigns unique spec IDs |
236+
237+
### Using Prompts
226238

227239
```bash
228-
# View current rules
229-
cat rules/versions.yaml
230-
cat rules/generation/v1.0.0-draft/code-generation-rules.md
240+
# View a prompt
241+
cat prompts/plot-generator.md
242+
cat prompts/library/matplotlib.md
231243

232-
# Create new version
233-
cp -r rules/generation/v1.0.0-draft rules/generation/v1.1.0-draft
234-
# Edit files, then update rules/versions.yaml
244+
# Edit a prompt
245+
vim prompts/quality-criteria.md
246+
git commit -m "prompts: improve quality criteria"
235247
```
236248

237-
**Rule States**: draft → active → deprecated → archived
249+
**No folder versioning** - Git history tracks all changes. View old versions with `git log -p prompts/*.md`.
250+
251+
### Workflow Integration
238252

239-
**Why Versioned?** Enables A/B testing of rule improvements, provides audit trail, allows rollback.
253+
Workflows reference prompts instead of embedding long instructions:
254+
255+
```yaml
256+
# Example usage in workflow
257+
prompt: |
258+
$(cat prompts/plot-generator.md)
259+
$(cat prompts/library/matplotlib.md)
260+
261+
## Spec
262+
$(cat specs/scatter-basic.md)
263+
```
240264
241265
## Implementation Guidelines
242266
@@ -416,7 +440,7 @@ pytest --pdb # Debug on failure
416440
- **docs/architecture/repository.md**: Directory structure
417441
- **docs/architecture/api.md**: API endpoints reference
418442
- **docs/architecture/database.md**: Database schema
419-
- **rules/README.md**: Rule versioning system
443+
- **prompts/README.md**: AI agent prompt system
420444

421445
## Project Philosophy
422446

0 commit comments

Comments
 (0)