Skip to content

Commit 4a85559

Browse files
committed
Add R refactoring skill and journal figure specifications documentation
- Created a new documentation file for the optional R refactoring skill, detailing the process to refactor R scripts into the lab format with clear organization and emoji section comments. - Introduced a new reference document outlining fictional journal figure specifications, including detailed requirements for figure formatting, accessibility, and behavior verification.
1 parent e7db881 commit 4a85559

51 files changed

Lines changed: 1031 additions & 973 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
# Practical GenAI Agentic Coding Guide
22

3-
**[Read the online guide](https://fritschelab.org/practical-genai-agentic-coding-guide/).** Choose [Python](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/paths/python/) or [R](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/paths/r/), then follow six lessons through one reporting change, verification, review, and a short handoff.
3+
**[Read the online guide](https://fritschelab.org/practical-genai-agentic-coding-guide/).** Choose [Python](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/paths/python/) or [R](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/paths/r/), then repair a plot with a coding agent in six lessons.
44

55
This is Part 2 of the [Practical GenAI series](https://fritschelab.org/practical-genai-coding-guide/), from [Lars G. Fritsche](https://medschool.umich.edu/profile/4980/lars-fritsche) and the [Fritsche Lab](https://fritschelab.org/) at the University of Michigan.
66

77
## Get the exercise
88

9-
The runnable Python/R pipeline, synthetic data, tests, and agent instructions are in the **[example repository](https://github.com/FritscheLab/practical-genai-agentic-coding-example)**. Download only that repository and follow along online. It also includes the language walkthroughs for offline use.
9+
Download the **[example repository](https://github.com/FritscheLab/practical-genai-agentic-coding-example)** for code, invented totals, tests, and offline lessons. Follow the website alongside it.
1010

1111
```bash
1212
git clone https://github.com/FritscheLab/practical-genai-agentic-coding-example.git
1313
cd practical-genai-agentic-coding-example
1414
```
1515

16-
Start with its README and your chosen language's setup. You should be comfortable running a Python or R script and using a terminal; the lessons explain the Git steps. The baseline uses synthetic data and needs no model API or credentials. Use an institution-approved coding assistant for the agent exercise.
16+
Start with its README and language setup. Bring basic Python/R and terminal skills; the lessons explain Git. Plotting needs no model API or credentials. Use an institution-approved coding assistant for the agent exercise.
17+
18+
Include accessibility in every figure: contrast, readable labels, and reviewed alternative text.
1719

1820
## Explore the guide
1921

2022
- [Agent setup](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/platforms/): configure your coding client and check its access.
23+
- [Optional R refactoring example](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/platforms/r-refactoring.html): reuse a lab formatting skill or named Codex agent, then verify that results stay the same.
2124
- [Repository practices](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/practices/): context, testing, logs, and handoffs.
2225
- [Teaching materials](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/lab_meeting/): a 45-minute workshop and slides.
2326
- [Lab data guidance](https://fritschelab.org/practical-genai-agentic-coding-guide/docs/reference/lab-data-policy.html): institutional requirements before adapting the workflow to study data.

‎_includes/path_choices.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div class="guide-path-grid" aria-label="Choose a language path">
22
<section class="guide-path-card" aria-labelledby="python-path-heading">
33
<h2 id="python-path-heading">Python</h2>
4-
<p>Use Python, pandas, and pytest. Start with a working package, then add and check the exclusion report.</p>
4+
<p>Use Python and Matplotlib. Repair a grouped plot, then check its image and tests.</p>
55
<p class="guide-path-runtime">Python 3.10–3.12</p>
66
<a class="btn btn-primary" href="{{ '/docs/paths/python/' | relative_url }}">Start the Python path <span aria-hidden="true">→</span></a>
77
</section>
88
<section class="guide-path-card" aria-labelledby="r-path-heading">
99
<h2 id="r-path-heading">R</h2>
10-
<p>Use base R and native R checks. Start with a working script, then add and check the exclusion report.</p>
10+
<p>Use base R and native R checks. Repair a grouped plot, then check its image and tests.</p>
1111
<p class="guide-path-runtime">R 4.1 or later</p>
1212
<a class="btn btn-primary" href="{{ '/docs/paths/r/' | relative_url }}">Start the R path <span aria-hidden="true">→</span></a>
1313
</section>

‎assets/images/plotting-before.png‎

24.3 KB
Loading

‎assets/images/plotting-target.png‎

70.1 KB
Loading

‎docs/lab_meeting/45min_runbook.md‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,45 @@ parent: Teaching
55
nav_order: 1
66
---
77

8-
# A small change, from request to handoff
8+
# Repair a plot, from request to handoff
99

1010
## Prepare
1111

12-
Have participants keep the guide open online and download the [example repository](https://github.com/FritscheLab/practical-genai-agentic-coding-example). Choose the [Python path](../paths/python/index.md) or [R path](../paths/r/index.md). Run its setup, tests, and six-row example before the presentation. Prepare an approved [coding client](../platforms/index.md). Use synthetic files throughout.
12+
Before the session, participants download the [example](https://github.com/FritscheLab/practical-genai-agentic-coding-example), complete [Python](../paths/python/index.md) or [R setup](../paths/r/index.md), and prepare an approved [coding client](../platforms/index.md). Run tests and save `runs/baseline/summary.png`.
1313

14-
Open the [six-row example and expected report](../lessons/02-specify.md). Find measurements d, e, and f in the input and `outputs/flagged_rows.tsv` so you can help participants check their counts.
14+
Open the [exercise and target](../lessons/02-specify.md): two invented groups overlap and long labels are clipped. The task repairs that layout for a fictional journal.
15+
16+
Keep study data and logs outside this teaching workspace.
1517

1618
## Follow along
1719

1820
| Minutes | Activity |
1921
| --- | --- |
20-
| 0–5 | Open the six input rows and baseline output. Find the three excluded measurements. |
21-
| 5–12 | Ask the agent to explain where cleaning and reporting happen. Check the files it names. |
22-
| 12–17 | Show the desired report: 3 of 6 excluded, missing height 2, missing weight 2. Explain the overlap. |
23-
| 17–30 | Use the chosen path's implementation prompt. Watch the change and ask about anything unclear. |
24-
| 30–40 | Run the example and existing tests. Read the summary and inspect the diff. |
22+
| 0–5 | Open the baseline plot. Identify overlapping groups and clipped labels. |
23+
| 5–12 | Ask the agent to explain the plotting functions, layout settings, and tests. Check the source files it names. |
24+
| 12–17 | Compare the baseline with the target. Read the fictional JUSF specifications: grouped bars, exact dimensions, typewriter text, purple/lime groups, legend, and value labels. |
25+
| 17–30 | Use the chosen path's implementation prompt. Watch the source change and ask about anything unclear. |
26+
| 30–40 | Render the repaired PNG, run both checks, review contrast and grayscale readability, and write/review `runs/with-fix/summary.alt.txt`. |
2527
| 40–45 | Write a short handoff: what changed, what was checked, and what remains. |
2628

2729
## The example
2830

29-
The [six-row table](../lessons/02-specify.md) fits on one screen. Measurements d/e/f are excluded; f lacks both height and weight. The task adds a readable summary of these existing decisions. Cleaning and record selection stay the same.
31+
The [exercise table](../lessons/02-specify.md) fixes the values; the [figure specifications](../reference/figure-specifications.md) fix the format. Point the agent there.
32+
3033

31-
Use the complete-data file next. Its report should show no exclusions. Different wording and code can produce the same useful result.
3234

3335
## During the change
3436

35-
Use the prompts in the participant's language path. Ask for an explanation before edits, a short plan if needed, and implementation once the request is clear. Check the client's actual file and command permissions separately.
37+
Use your language path's prompts. Ask about source and tests before edits; plan only if needed. Check actual file and command permissions.
38+
39+
Behavior tests should pass before and after; the strict figure checker should fail before and pass after. Open the image and diff too. If the agent cannot view images, a person performs that check.
3640

37-
Existing tests help catch regressions. Reading the report checks whether the improvement makes sense. Reviewing the diff checks whether the agent changed more than requested. These are complementary habits learners can reuse in their own repositories.
41+
Review contrast, grayscale readability, and `runs/with-fix/summary.alt.txt` against the figure specification. The plotting CLI does not create alt text.
3842

3943
## If time runs short
4044

41-
Save the current state and any failing command. Use the [expected report](../lessons/02-specify.md#describe-the-improvement) and the flagged rows to discuss what remains, and leave a short handoff so participants can continue at home.
45+
Save the source, latest image, commands, and unfinished work. Participants can continue from that handoff at home.
4246

4347
## Debrief
4448

45-
What did you check yourself? What did the agent help you find? What would a labmate need to continue this work tomorrow?
49+
What did the tests establish? What did opening the image reveal? Could a labmate reproduce the edited plot from the handoff?

‎docs/lab_meeting/demo_prompts.md‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,33 @@ nav_order: 2
77

88
# Prompts for the workshop
99

10-
Send participants to their language path at the start. Each lesson already supplies a copyable prompt with that language and its files filled in. Participants can keep using Next to follow the exercise.
10+
Use your language path's prompts; they already name the right source files and checks.
1111

1212
| Stage | Python prompt | R prompt |
1313
| --- | --- | --- |
1414
| Orient | [Python Lesson 1](../paths/python/01-orient.md) | [R Lesson 1](../paths/r/01-orient.md) |
1515
| Describe the change | [Python Lesson 2](../paths/python/02-specify.md) | [R Lesson 2](../paths/r/02-specify.md) |
1616
| Implement | [Python Lesson 3](../paths/python/03-implement.md) | [R Lesson 3](../paths/r/03-implement.md) |
17+
| Verify | [Python Lesson 4](../paths/python/04-verify.md) | [R Lesson 4](../paths/r/04-verify.md) |
1718
| Review | [Python Lesson 5](../paths/python/05-review.md) | [R Lesson 5](../paths/r/05-review.md) |
1819
| Hand off | [Python Lesson 6](../paths/python/06-handoff.md) | [R Lesson 6](../paths/r/06-handoff.md) |
1920

20-
Use planning while the group still has questions about the approach. Discuss the six-row example and the report, then switch to implementation. Keep the [shared example](../lessons/02-specify.md) available to the facilitator.
21+
Open the baseline and [figure specifications](../reference/figure-specifications.md). Plan only while the approach is unclear, then implement.
2122

22-
A handoff request can be shared across languages:
23+
Short prompts work because `AGENTS.md`, the skill, and the specification carry the reusable instructions. Point to those files instead of repeating their contents.
2324

24-
```markdown
25-
Leave a short handoff: what changed, the commands and results we checked,
26-
and anything unfinished. Include how to rerun the example.
25+
If alt text is still missing, ask:
26+
27+
```text
28+
Write runs/with-fix/summary.alt.txt following the journal specification.
29+
Check it against the image and report any accessibility checks you cannot do.
30+
```
31+
32+
Review the draft yourself. Alt text is a separate deliverable; rendering creates only the PNG.
33+
34+
For the handoff:
35+
36+
```text
37+
Write a short handoff with the changes, actual checks and results,
38+
image and alt-text paths, and anything unfinished or untested.
2739
```

‎docs/lab_meeting/index.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ has_children: true
66
has_toc: false
77
---
88

9-
# Work through a change together
9+
# Repair a plot together
1010

11-
The [45-minute runbook](45min_runbook.md) is a session you can lead with your group. Use the [six short steps](../lessons/index.md) to follow along or continue at home. Choose the Python or R path, install its dependencies, and run its baseline before the session; use the meeting for reasoning and review.
11+
The [45-minute runbook](45min_runbook.md) is a session you can lead with your group. Use the [six short steps](../lessons/index.md) to follow along or continue at home. Choose Python or R, install its dependencies, and render the baseline before the session; use the meeting for reasoning and review.
12+
13+
Participants and agents work with a plotting function, invented totals for two groups, rendered images, tests, and local [figure specifications](../reference/figure-specifications.md). The task separates overlapping bars and fixes clipped labels without changing the totals.
1214

1315
- [Runbook](45min_runbook.md): agenda, preparation, and checkpoints.
14-
- [Demo prompts](demo_prompts.md): concise requests for orientation, implementation, and review.
15-
- [Six-row example](../lessons/02-specify.md): inputs, expected report, and checks for either language.
16+
- [Demo prompts](demo_prompts.md): requests for orientation, implementation, and review.
17+
- [Plot-repair exercise](../lessons/02-specify.md): baseline, target, and checks for either language.
1618

1719
To present the [Quarto slides](https://github.com/FritscheLab/practical-genai-agentic-coding-guide/blob/main/docs/lab_meeting/slide_deck.qmd), run `quarto render docs/lab_meeting/slide_deck.qmd` from a local copy of the [guide repository](https://github.com/FritscheLab/practical-genai-agentic-coding-guide) and open the resulting HTML file. Participants only need the example repository; the guide source is for presenting or editing the slides.
1820

19-
Participants should leave with a reporting change they understand, test results, and a short handoff they can use to continue at home.
21+
Participants should leave with a readable plot, reviewed alternative text, a source change they understand, test results, and a short handoff. Accessibility is part of the task and review from the start.

0 commit comments

Comments
 (0)