Skip to content

Commit b2a1fb0

Browse files
committed
docs: restructure repository guidance
1 parent b24b3f9 commit b2a1fb0

8 files changed

Lines changed: 356 additions & 193 deletions

File tree

‎README.md‎

Lines changed: 92 additions & 193 deletions
Large diffs are not rendered by default.

‎docs/CACHING.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Caching and remote caching
2+
3+
## Local workflow caching
4+
5+
The standard runtime uses lockfile- and configuration-keyed caches for package
6+
stores, Cargo, pip/uv, browser binaries, and applicable build artifacts. Cache
7+
misses always fall back to a clean locked install. Do not cache credentials,
8+
generated secrets, or mutable environments without an exact dependency key.
9+
10+
Repositories should measure before enabling large installed-tree or build
11+
caches. Set repository variables such as `REPO_FOUNDRY_CACHE_PACKAGES` and
12+
`REPO_FOUNDRY_CACHE_BUILD` only when a repeatable warm-cache benefit is proven.
13+
14+
## Turborepo and Vercel Remote Caching
15+
16+
Turborepo repositories can opt into Vercel Remote Caching with:
17+
18+
- Secret: `TURBO_TOKEN`
19+
- Repository variable: `TURBO_TEAM`
20+
21+
Non-Turborepo repositories do not need either setting. Deployment to Vercel is
22+
not required. Custom workflows can pass these values to Turbo directly when
23+
the repository's task graph benefits from remote reuse.
24+
25+
## Runner selection
26+
27+
Lightweight detection, orchestration, audits, and release metadata jobs can use
28+
`ubuntu-slim`. Toolchain-heavy builds, native compilation, browsers, and active
29+
CodeQL analysis should use `ubuntu-latest` unless measurements show otherwise.

‎docs/INITIALIZATION.md‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Initialization and synchronization
2+
3+
## Commands
4+
5+
Run the package from a repository root:
6+
7+
```bash
8+
npx code-foundry init [options]
9+
npx code-foundry sync [options]
10+
npx code-foundry doctor
11+
```
12+
13+
Use `--dry-run` to preview changes. Use `--no-bootstrap` when the repository is
14+
being initialized in CI or on a machine without mise. Run
15+
`bash .github/scripts/bootstrap.sh` later to install tools, enable hooks, and
16+
run the repository doctor.
17+
18+
## Profiles and features
19+
20+
Supported languages are `typescript`, `rust`, `python`, and `solidity`.
21+
`--languages auto` detects them from manifests and source files. Profiles are
22+
`auto`, `application`, `monorepo`, and `minimal`.
23+
24+
Standard features are `ci`, `codeql`, `security`, `test`, `draft-pr`,
25+
`release-pr`, `release`, and `dependabot`. `all` enables every standard
26+
feature. `--prune` removes disabled standard workflows only; it never removes
27+
custom workflows.
28+
29+
## Runtime selection
30+
31+
Reusable workflow callers require a literal repository and ref. By default,
32+
the initializer derives the runtime repository from the source template. Use
33+
these options for a fork or a staged runtime:
34+
35+
```bash
36+
npx code-foundry init \
37+
--runtime-repository OWNER/REPO \
38+
--runtime-ref v1.2.3
39+
```
40+
41+
Both values are persisted in `.github/template.yml` and rendered into the
42+
standard callers. `REPO_FOUNDRY_RUNTIME_REPOSITORY` and
43+
`REPO_FOUNDRY_RUNTIME_REF` provide equivalent environment/repository-variable
44+
overrides.
45+
46+
## Safety rules
47+
48+
Synchronization preserves authored README and policy documents, existing
49+
`.mise.toml` selections, application code, custom workflows, and repository
50+
documentation. Existing licenses are preserved unless a license or license
51+
file is explicitly selected. Use `--force` only when intentionally refreshing
52+
protected standard documents.
53+
54+
The initializer generates `.github/template.yml` as the repository-owned
55+
configuration contract. Keep project-specific settings there rather than
56+
editing generated workflow callers by hand.

‎docs/PUBLISHING.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Publishing packages
2+
3+
## npm
4+
5+
Set `npm_publish: true` only when the repository owns an npm package. Configure
6+
npm trusted publishing for the repository's `release.yml` workflow whenever
7+
possible. An `NPM_TOKEN` secret is the fallback for registries or repositories
8+
that cannot use trusted publishing.
9+
10+
The package should define its intended visibility explicitly:
11+
12+
```json
13+
{
14+
"publishConfig": {
15+
"access": "public"
16+
}
17+
}
18+
```
19+
20+
Publication occurs only from a Release Please tag; ordinary pushes do not
21+
publish. The release workflow fails clearly when npm publication is enabled but
22+
neither trusted publishing nor a token is configured.
23+
24+
## GitHub Releases and GitHub Packages
25+
26+
A GitHub Release is release metadata attached to a Git tag. It is independent
27+
of the npm registry and of GitHub Packages.
28+
29+
Publishing to npm does not populate the repository's GitHub Packages section.
30+
If a repository also needs a GitHub Container Registry or npm-compatible
31+
GitHub Package, add a repository-owned publishing workflow and credentials;
32+
that is an optional extension rather than part of the universal baseline.
33+
34+
## Provenance and verification
35+
36+
Prefer trusted publishing because it provides short-lived credentials and
37+
provenance. After a release, verify:
38+
39+
```bash
40+
npm view PACKAGE_NAME version dist-tags
41+
gh release view vVERSION
42+
```
43+
44+
For private or non-npm repositories, leave `npm_publish: false` and retain the
45+
GitHub Release portion of the standard flow if versioned releases are useful.

‎docs/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Documentation
2+
3+
These guides describe the reusable repository baseline in provider-neutral
4+
terms. They are suitable for copying into another repository and adapting with
5+
its own names, environments, and deployment details.
6+
7+
## Guides
8+
9+
- [Initialization and synchronization](INITIALIZATION.md)
10+
- [Workflow and CI conventions](WORKFLOWS.md)
11+
- [Release management](RELEASES.md)
12+
- [Publishing packages](PUBLISHING.md)
13+
- [Caching and remote caching](CACHING.md)
14+
15+
## Repository-specific documentation
16+
17+
Add project-specific guides, architecture notes, runbooks, and deployment
18+
instructions to this directory. The Code Foundry initializer preserves `docs/`
19+
files during synchronization. Prefer clear, task-oriented filenames and link
20+
new documents from this index when they become part of the supported workflow.

‎docs/RELEASES.md‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Release management
2+
3+
## Branch flow
4+
5+
The standard environment flow is:
6+
7+
```text
8+
topic branch -> staging -> main -> versioned release
9+
```
10+
11+
Keep commits Conventional Commit-shaped (`feat:`, `fix:`, `docs:`, `ci:`,
12+
`chore:`, and so on). Release Please uses them to select patch/minor/major
13+
versions and generate grouped changelog notes.
14+
15+
The release workflow opens or updates a versioned PR after changes reach
16+
`main`. Merging that PR updates the changelog, creates the Git tag and GitHub
17+
Release, and triggers any configured package publication.
18+
19+
For an explicit version, put `Release-As: 2.0.0` in a commit or pull request
20+
body. Existing `CHANGELOG.md` history remains repository-owned.
21+
22+
## Configuration
23+
24+
Set these values in `.github/template.yml`:
25+
26+
```yaml
27+
release_type: auto # auto, node, python, rust, simple, or none
28+
npm_publish: false # true only for an npm package
29+
```
30+
31+
`auto` selects a supported manifest. Use `simple` with `version.txt` for a
32+
repository without a package manifest and `none` for a repository that should
33+
not release automatically.
34+
35+
## Pull request permissions
36+
37+
If the default `GITHUB_TOKEN` cannot create pull requests, configure a narrowly
38+
scoped `RELEASE_PLEASE_TOKEN` repository or organization secret. The release
39+
workflow needs `contents`, `issues`, and `pull-requests` permissions.
40+
41+
## Operational checklist
42+
43+
1. Merge tested changes from `staging` into `main`.
44+
2. Review the generated Release Please PR and changelog.
45+
3. Merge the release PR with the repository's normal linear-history policy.
46+
4. Confirm the GitHub Release and any package publication.
47+
5. Synchronize `staging` with the new `main` release commit.

‎docs/WORKFLOWS.md‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Workflow and CI conventions
2+
3+
## Standard triggers
4+
5+
The default standard callers use:
6+
7+
```yaml
8+
push:
9+
branches: [main, staging]
10+
pull_request:
11+
branches: [staging]
12+
```
13+
14+
Draft PR automation may additionally listen to supported topic branches.
15+
Custom deployment, indexing, search, Slither, or other workflows are
16+
repository-owned extensions and should keep their own triggers and permissions.
17+
18+
## Standard workflow responsibilities
19+
20+
| Workflow | Responsibility |
21+
| --- | --- |
22+
| CI | Format, lint, type-check, and build |
23+
| Test | Unit, integration, E2E, and smoke tests |
24+
| Security | Profile, audits, and public-only Dependency Review |
25+
| CodeQL | GitHub-native code scanning, kept separate from CI |
26+
| Draft PR | Create/update development pull requests |
27+
| Release PR | Promote `staging` into `main` |
28+
| Release | Release Please, GitHub release, and optional npm publication |
29+
30+
Use concise job names such as `CI / Format`, `Test / Unit`, and
31+
`CodeQL / Analyze (Python)`. Required checks should match the jobs actually
32+
enabled for the repository profile.
33+
34+
## Language defaults
35+
36+
- TypeScript/JavaScript: ESLint, Prettier, and Bun's native `bun test`.
37+
- Rust: default `rustfmt`, Clippy with `-D warnings`, and Cargo tests.
38+
- Python: Ruff formatting/linting, uv when a compatible lockfile exists, and
39+
native Python tests.
40+
- Solidity: preserve the repository's native Hardhat, Foundry, or specialized
41+
test/security workflows.
42+
43+
Jobs detect applicability before installing tools. Empty language or test
44+
surfaces remain successful and visible, so branch protection does not become
45+
ambiguous for mixed-language repositories.
46+
47+
## Security behavior
48+
49+
CodeQL is a separate workflow using GitHub's official actions. Dependency
50+
Review is skipped where GitHub does not support it, while JavaScript, Python,
51+
and Rust audits remain available without Advanced Security. If GitHub default
52+
setup is enabled, disable its generated CodeQL workflow to avoid duplicate
53+
analysis.
54+
55+
## Branch protection
56+
57+
Use the initializer's protection helper after reviewing the repository's
58+
enabled features:
59+
60+
```bash
61+
bash .github/scripts/init-repo.sh --protection
62+
```
63+
64+
Keep strict status checks, linear history, and conversation resolution enabled.
65+
For a repository with optional features disabled, do not require checks that
66+
will never run.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"files": [
2020
"src",
21+
"docs",
2122
".github",
2223
".githooks",
2324
".editorconfig",

0 commit comments

Comments
 (0)