You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filter by applies_when frontmatter. Only include conventions relevant
to this repo. Frontmatter stripped from output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fish passage repos add project-specific params (`project_region`, `model_species`, `wsg_code`, update flags for forms). These are project-specific — don't add them to the general template.
124
-
125
-
## Chunk Naming
126
-
127
-
Embed context and purpose in chunk names. The principle is universal; the codes are project-specific.
Bookdown auto-prepends `fig:` or `tab:` to chunk names.
140
-
141
-
- **Tables:** `Table \@ref(tab:chunk-name)`
142
-
- **Figures:** `Figure \@ref(fig:chunk-name)`
143
-
144
-
No `fig:` or `tab:` prefix in the chunk label itself — bookdown adds it.
145
-
146
-
## Table Caption Workaround
147
-
148
-
Interactive tables (DT) can't use standard bookdown captions. Use the `my_tab_caption()` function from `staticimports.R`.
149
-
150
-
**Pattern:** Separate `-cap` chunk from table chunk.
151
-
152
-
```r
153
-
# Caption chunk — must use results="asis"
154
-
{r tab-sites-sum-cap, results="asis"}
155
-
my_caption <- "Summary of fish passage assessment procedures."
156
-
my_tab_caption()
157
-
```
158
-
159
-
```r
160
-
# Table chunk — renders the DT
161
-
{r tab-sites-sum}
162
-
data |> my_dt_table(page_length = 20, cols_freeze_left = 0)
163
-
```
164
-
165
-
`my_tab_caption()`auto-grabs the chunk label via `knitr::opts_current$get()$label` and wraps it in HTML caption tags that bookdown can cross-reference.
166
-
167
-
## Photo Layout
168
-
169
-
Separate prep chunk (find the file) from display chunk (render it).
**`references.bib` is auto-generated — never edit it manually.** On each build, `rbbt::bbt_write_bib()` scans all `.Rmd` files for `@citekey` references, pulls the BibTeX from Zotero's Better BibTeX, and overwrites `references.bib`. Any manual additions will be lost on the next build.
195
-
196
-
To add a reference: add it to the shared Zotero group library, use its BBT citation key (`@key`) in the `.Rmd` text, and build. rbbt handles the rest.
When `update_bib: FALSE` in params, the build uses the existing `references.bib` without regenerating — useful for offline builds or CI where Zotero isn't running.
Use `nocite:` in YAML to include references not cited in text.
213
-
214
-
## Acknowledgement & AI Disclosure
215
-
216
-
`index.Rmd` contains two separate front-matter sections after the setup chunks:
217
-
218
-
### Acknowledgement {.front-matter .unnumbered}
219
-
220
-
Three parts, in order:
221
-
222
-
1. **Personal connection to land** (template-level, same across all reports):
223
-
> At New Graph Environment, we understand our well-being as inseparable from the health of the land and waters we work within. When we care for ecosystems, we care for ourselves and for the communities connected to them. This relationship is not metaphorical — it is the foundation of our practice.
224
-
225
-
2. **Colonial acknowledgement** (template-level):
226
-
> Modern civilization has a long journey ahead to acknowledge and address the historic and ongoing impacts of colonialism...
227
-
228
-
3. **Territorial acknowledgement** (project-specific, must be edited per report): Name the Nations, governance systems, watersheds, and species relevant to the project. Do not use a generic office-location acknowledgement — tie it to the territory where the work happens. See the Wedzin Kwa chinook example for the pattern.
229
-
230
-
4. **Funding and partners** (project-specific).
231
-
232
-
### AI Disclosure
233
-
234
-
Do not use a `#` heading for the disclosure — this creates a separate chapter page in gitbook. Instead, add it to the YAML `date:` field so it renders in the title block:
235
-
236
-
```yaml
237
-
date: |
238
-
|
239
-
| Version X.X.X DRAFT `r format(Sys.Date(), "%Y-%m-%d")`
240
-
|
241
-
| *Claude Sonnet 4.6 (Anthropic) assisted with literature synthesis, drafting, and technical writing. All scientific interpretation, data analysis, and conclusions are the responsibility of the authors.*
242
-
```
243
-
244
-
**Wording principle:** Be accurate about what the LLM did. It assisted with drafting and synthesis — it did not make scientific interpretations or conclusions. Do not say "independently verified by the authors" (redundant) or attribute "ecological assessments" to the LLM.
245
-
246
-
For regulatory/EGBC-stamped work, use the extended disclaimer from `soul/research/20260212_ai_disclosure_research.md`. See NewGraphEnvironment/mybookdown-template#89.
247
-
248
-
## Conditional Rendering (Gitbook vs PDF)
249
-
250
-
A single boolean `gitbook_on` controls output format throughout.
The function includes a cache-busting `?v=` parameter. Bump `v` in the function default when `viewer.html` has breaking changes.
306
-
307
-
## Dependency Management
308
-
309
-
Use `renv` for reproducible package management:
310
-
- `.Rprofile`activates renv on startup
311
-
- `renv::restore()`installs from lockfile
312
-
- `renv::snapshot()`updates lockfile after adding packages
313
-
- Use `pak::pak("pkg")` to install (not `install.packages`)
314
-
315
-
## Known Drift
316
-
317
-
Production repos (2024-2025) have drifted from templates in these areas. When working in a child repo, match what that repo does, not the template:
318
-
319
-
- **Script naming in `02_reporting/`** — older repos use `tables.R`, `0165-read-sqlite.R`; newer repos use numbered `0130-tables.R`. Follow the repo you're in.
320
-
- **Removed packages** — `elevatr`, `rayshader`, `arrow` removed from production but still in template.
321
-
- **`staticimports::import()` call** — some repos skip it and source `staticimports.R` directly.
322
-
- **Hardcoded vs parameterized years** — older repos hardcode years in file paths; newer repos use `params$project_year`. Prefer parameterized.
- For production COGs on S3, `dft_map_interactive()` serves tiles via titiler — set `options(drift.titiler_url = "...")`
410
120
- See the [drift vignette](https://www.newgraphenvironment.com/drift/articles/neexdzii-kwa.html) for a worked example (Neexdzii Kwa floodplain, 2017-2023)
411
121
122
+
412
123
# Code Check Conventions
413
124
414
125
Structured checklist for reviewing diffs before commit. Used by `/code-check`.
@@ -497,6 +208,7 @@ Add new checks here when a bug class is discovered — they compound over time.
497
208
- New variables: update .tfvars.example
498
209
- New workflows: update relevant README
499
210
211
+
500
212
# Communications Conventions
501
213
502
214
Standards for external communications across New Graph Environment.
@@ -625,10 +338,10 @@ For multi-step tasks, state a brief plan:
625
338
626
339
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
627
340
628
-
---
629
341
630
342
**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
631
343
344
+
632
345
# New Graph Environment Conventions
633
346
634
347
Core patterns for professional, efficient workflows across New Graph Environment repositories.
@@ -773,6 +486,7 @@ Scripts and logs live together: `scripts/<module>/logs/`
0 commit comments