1010
1111### Key commands
1212
13+ (All these functions have been optimized for agentic use, so they can be
14+ called directly without other arguments.)
15+
1316``` r
1417
15- # To run code
18+ # Executing code
1619devtools :: load_all()
1720code
1821
19- # To run all tests
20- devtools :: test()
21-
22- # To run all tests for files starting with {name}
23- devtools :: test(filter = ' ^{name}' )
24-
25- # To run all tests for R/{name}.R
26- devtools :: test_active_file(' R/{name}.R' )
27-
28- # To run a single test with exact description "blah" (no regexp)
29- devtools :: test_active_file(' R/{name}.R' , desc = ' blah' )
22+ # Tests
23+ devtools :: test() # all tests
24+ devtools :: test(filter = " ^{name}" ) # tests for files starting with {name}
25+ devtools :: test_active_file(" R/{name}.R" ) # tests for R/{name}.R
26+ devtools :: test_active_file(" R/{name}.R" , desc = ' blah' ) # single test with exact description "blah" (no regexp)
3027
31- # To redocument the package
32- devtools :: document()
28+ # Test coverage
29+ devtools :: test_coverage() # all files
30+ devtools :: test_coverage_active_file(" R/{name}.R" ) # coverage for R/{name}.R from tests in tests/testthat/test-{name}.R
3331
34- # To check pkgdown documentation
35- pkgdown :: check_pkgdown()
32+ # Documentation
33+ devtools :: document() # redocument package
34+ pkgdown :: check_pkgdown() # check website
3635
37- # To check the package with R CMD check
36+ # Run complete R CMD check
3837devtools :: check()
3938```
4039
40+ ### Running R
41+
4142There are three possible ways to run code, listed in rough order of
4243desirability:
4344
@@ -52,14 +53,15 @@ desirability:
5253
5354- Otherwise, use ` Rscript -e "code" ` .
5455
55- ### Coding
56+ ### Code style
5657
58+ - Follow the tidyverse style guide
5759- Always run ` air format . ` after generating code.
5860- Use the base pipe operator (` |> ` ), not the magrittr pipe (` %>% ` ).
5961- Use ` \() ... ` for single-line anonymous functions. For all other
6062 cases, use ` function() {...} ` .
6163
62- ### Testing
64+ ### Test style
6365
6466- Tests for ` R/{name}.R ` go in ` tests/testthat/test-{name}.R ` .
6567- All new code should have an accompanying test.
@@ -73,10 +75,12 @@ desirability:
7375 expectation with a better failure message. A few expectations in newer
7476 releases that you might not know about are ` expect_all_true() ` ,
7577 ` expect_all_equal() ` , and ` expect_r6_class() ` .
76- - When testing errors and warnings, don’t use ` expect_error() ` or
77- ` expect_warning() ` . Instead, use ` expect_snapshot(error = TRUE) ` for
78- errors and ` expect_snapshot() ` for warnings because these allow the
79- user to review the full text of the output.
78+ - When testing errors and warnings:
79+ - Only use ` expect_error() ` or ` expect_warning() ` if the error or
80+ warning has a known class.
81+ - Generally, prefer ` expect_snapshot(error = TRUE) ` for errors and
82+ ` expect_snapshot() ` for warnings because these allow the user to
83+ review the full text of the output.
8084- Avoid the ` .package ` argument to ` local_mocked_bindings() ` ; this
8185 modifies the namespace of another package, which is not good practice.
8286 Instead create a mockable version of the function in the current
@@ -108,6 +112,10 @@ desirability:
108112 newlines (i.e. DO NOT line wrap).
109113- If the change is related to a function, put the name of the function
110114 early in the bullet.
115+ - If the change is related to an issue, include the issue number in
116+ parentheses.
117+ - Only include a GitHub username if the PR was created by someone who
118+ isn’t an author.
111119- Order bullets alphabetically by function name. Put all bullets that
112120 don’t mention function names at the beginning.
113121
@@ -119,6 +127,13 @@ desirability:
119127 exported function? Read the output of
120128 ` usethis::learn_tidy_skill("arg-checking") ` .
121129
130+ ## Git
131+
132+ - If the user asks you to commit, use markdown in the commit message,
133+ and don’t line wrap.
134+ - If the commit fixes an issue, include ` Fixes #num. ` on its own line.
135+ - Only push when the user explicitly requests it.
136+
122137## Writing
123138
124139- Use sentence case for headings.
0 commit comments