Skip to content

Commit 0dc65dc

Browse files
committed
initial draft ai.style guide
1 parent 8f872ee commit 0dc65dc

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

AI.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# chmsflow style guide for AI assistants
2+
3+
**Purpose**: Coding conventions for the chmsflow package. Reference for both human developers and AI assistants.
4+
5+
**Status**: DRAFT - Under development
6+
7+
**Foundation**: [Tidyverse style guide](https://style.tidyverse.org/) with extensions for recodeflow ecosystem.
8+
9+
---
10+
11+
## Variable naming
12+
13+
**Use `snake_case` for all variables**
14+
15+
**Pattern**: `[category]_[specifics]_[type]`
16+
17+
```r
18+
# Medication variables
19+
any_htn_med # Any anti-hypertension medication
20+
ace_med # ACE inhibitor medication
21+
diab_med # Diabetes medication
22+
23+
# Health outcomes
24+
htn_status # Hypertension status
25+
bmi_category # BMI category
26+
```
27+
28+
**Type suffixes**: `_med`, `_status`, `_category`, `_score`, `_date`
29+
30+
**DISCUSSION**: Some existing variables need renaming:
31+
32+
```r
33+
anymedany_htn_med
34+
acemedace_med
35+
diab_drugdiab_med
36+
```
37+
38+
---
39+
40+
## Function naming
41+
42+
**Use `snake_case` and start with a verb**
43+
44+
**Proposed verb taxonomy** (simplified):
45+
46+
| Verb | Purpose | Example |
47+
| ---------------- | ------------------------- | ------------------------------------------------------- |
48+
| `calculate_`  | Mathematical computation | `calculate_gfr(creatinine, age)`<br />calculate_bmi() |
49+
| `categorize_` | Continuous → categorical | `categorize_bmi(bmi)` |
50+
51+
**DISCUSSION**:
52+
53+
- Map existing verbs: `determine_*`, `find_*`, `adjust_*`, `is_*`, `cycles1to2_*`
54+
- Should parameters be lowercase (tidyverse) or UPPERCASE (CHMS traceability)?
55+
56+
---
57+
58+
## Architecture patterns
59+
60+
**Principles**:
61+
62+
- Hide complexity from users where possible
63+
- Automate workflows - minimize manual steps
64+
- Handle data structure differences internally when feasible
65+
66+
**DISCUSSION**:
67+
68+
- Document current architecture patterns (separate task)
69+
- Evaluate approaches for multi-cycle variables
70+
- Decide on intermediate variable handling
71+
72+
---
73+
74+
## Documentation
75+
76+
**Vignette structure** (user-first):
77+
78+
1. What's available
79+
2. When to use them
80+
3. Quick start
81+
4. How it works
82+
5. Advanced topics
83+
84+
**Function documentation** (roxygen2):
85+
86+
- Document all parameters
87+
- Provide examples
88+
- Include references for derivation methods
89+
90+
---
91+
92+
## Working with AI assistants
93+
94+
**Critical review required**
95+
96+
**DO**:
97+
98+
- ✓ Use AI for drafts and exploration
99+
-**Critically review all AI output**
100+
- ✓ Ask AI to explain reasoning
101+
- ✓ Test thoroughly
102+
103+
**DON'T**:
104+
105+
- ✗ Accept without understanding
106+
- ✗ Assume AI follows conventions
107+
- ✗ Let AI make architectural decisions alone
108+
109+
**Using this guide**:
110+
111+
1. Provide guide to AI at session start
112+
2. Ask AI to follow conventions explicitly
113+
3. Review output against guide
114+
4. Request revisions if needed
115+
5. Document gaps/ambiguities
116+
117+
**This is a living document** - update when you find issues or make decisions.
118+
119+
---
120+
121+
## Discussion questions
122+
123+
**Open decisions**:
124+
125+
1. Variable renaming: Single PR or gradual? Backwards compatibility?
126+
2. Function verbs: Which to keep? Exact meanings?
127+
3. Parameter naming: Lowercase or UPPERCASE?
128+
4. Cycle-specific functions: Refactor or keep?
129+
5. Intermediate variables: Eliminate or document?
130+
6. Vignette restructuring: Rewrite existing?
131+
132+
**Next steps**:
133+
134+
1. Review together
135+
2. Discuss open questions
136+
3. Pilot with medications code
137+
4. Refine based on learnings
138+
139+
---
140+
141+
## References
142+
143+
- [Tidyverse style guide](https://style.tidyverse.org/)
144+
- [R packages book](https://r-pkgs.org/)
145+
- [cchsflow package](https://github.com/Big-Life-Lab/cchsflow)

0 commit comments

Comments
 (0)