diff --git a/docs/checks/examples.mdx b/docs/checks/examples.mdx index e7cddab35..4f0b79d02 100644 --- a/docs/checks/examples.mdx +++ b/docs/checks/examples.mdx @@ -1,224 +1,69 @@ --- -title: "Example Checks" +title: "Generating Checks" --- -The fastest way to create checks is to ask your coding agent to write them. The prompts below are organized by category — paste any of them into Claude Code or your preferred coding agent. Because the agent can read your codebase, the result is tailored to your actual code. +The best way to create checks is to have your coding agent write them. Install the writing-checks skill to teach your agent the check file format and best practices: -## Discovery prompts +```bash +npx skills add continuedev/skills --skill writing-checks +``` -### Security +Then describe what you want to enforce and the agent writes the check file, tailored to your actual frameworks, file structure, and conventions. Here are some prompts to try: + +## Security + +Catch vulnerabilities specific to your stack — auth gaps, injection vectors, leaked secrets. ``` Look at our codebase and write checks for the most likely security issues — think auth bypasses, injection vectors, secrets in source, and missing input validation. Tailor the checks to the frameworks and patterns we actually use. ``` -``` -Write a check that verifies new API endpoints follow our existing auth middleware pattern -``` +## Code review patterns -### Code review patterns +Turn recurring PR feedback into automated checks so reviewers don't have to repeat themselves. ``` Look through our recent PR review comments and identify things reviewers say repeatedly. Write checks that automate those recurring review comments. ``` -``` -Read our CONTRIBUTING.md and any style guides in the repo, then write checks that enforce the conventions we've documented but reviewers still have to catch manually -``` +## QA and browser testing -### QA and browser testing +Verify that UI changes render correctly and don't break links or layouts. ``` Write a check that uses a browser to verify any new or changed pages render without errors and match our design system ``` -``` -Write a check that visits any URLs added or changed in this PR, takes screenshots, and flags layout issues or broken links -``` +## Best practices -### Best practices +Enforce the conventions your team already follows — error handling, naming, migration safety. ``` Analyze our codebase and write checks for the patterns that matter most — error handling conventions, logging standards, naming conventions, or whatever you see us being inconsistent about ``` -``` -Write a check that makes sure database migrations are safe to run on a production table with 100M+ rows -``` +## Test coverage -### Test coverage +Make sure new code ships with tests that match your project's existing patterns. ``` Write a check that verifies new code has corresponding tests, following the test file naming and structure conventions already in our project ``` -### Documentation +## Documentation + +Flag PRs where public APIs or config changed but the docs didn't. ``` Write a check that flags PRs where public API or configuration changes aren't reflected in documentation ``` ---- +## Iterate locally -## Static examples +Write the check (or have your agent write it), run it against a real PR branch, read the output, refine. Run `/checks` in your coding agent to test: -Complete check files you can copy into `.continue/checks/` directly. These are generic starting points — checks generated by your coding agent from the prompts above will be more specific to your project. +``` +/checks .continue/checks/migration-safety.md +``` -### Security review - -````markdown security-review.md ---- -name: Security Review -description: Flag hardcoded secrets, injection vectors, and missing input validation ---- - -Review the pull request diff for security issues. - -Flag as **failing** if any of these are true: - -- Hardcoded API keys, tokens, passwords, or connection strings in source files -- New API endpoints or request handlers without input validation or sanitization -- SQL queries built with string concatenation or template literals instead of parameterized queries -- Sensitive data (passwords, tokens, PII) written to logs or stdout -- New cryptographic code using weak algorithms (MD5, SHA1 for security purposes, ECB mode) -- Secrets added to files that are not in `.gitignore` - -If none of these issues are found, pass the check. -```` - -### Test coverage - -````markdown test-coverage.md ---- -name: Test Coverage -description: Verify new code has corresponding tests ---- - -Review the pull request diff and check that new code is tested. - -Flag as **failing** if any of these are true: - -- A new source file was added without a corresponding test file (e.g., `utils.ts` added but no `utils.test.ts`) -- New exported functions or public methods have no test exercising them -- An existing test file was deleted without the corresponding source file also being deleted - -Pass the check if: - -- All new source files have corresponding test files -- New functions/methods are covered by at least one test -- Only test files, docs, or config files were changed -- The PR modifies existing code and existing tests still cover the changed paths -```` - -### Documentation freshness - -````markdown docs-freshness.md ---- -name: Documentation Freshness -description: Ensure docs are updated when public APIs or configuration changes ---- - -Review the pull request diff for changes to public-facing APIs or configuration, and verify documentation was updated. - -Flag as **failing** if any of these are true: - -- A public function, class, or type signature was added or changed, but no documentation file (README, docs/, or inline JSDoc/docstrings) was updated -- Configuration options were added or renamed (config files, environment variables, CLI flags) without updating the corresponding docs -- API route paths or request/response shapes changed without updating API documentation - -Pass the check if: - -- No public API or configuration changes were made -- Documentation files were updated in the same PR as the API/config change -- Changes are purely internal (private functions, refactors with no public interface change) -```` - -### Conventional commits - -````markdown conventional-commits.md ---- -name: Conventional Commits -description: Verify the PR title follows conventional commit format ---- - -Check that the pull request title follows the Conventional Commits specification. - -The title must match this format: `type(optional scope): description` - -Valid types: - -- `feat` — new feature -- `fix` — bug fix -- `docs` — documentation only -- `style` — formatting, no code change -- `refactor` — code change that neither fixes a bug nor adds a feature -- `perf` — performance improvement -- `test` — adding or updating tests -- `build` — changes to build system or dependencies -- `ci` — changes to CI configuration -- `chore` — maintenance tasks -- `revert` — reverts a previous commit - -Flag as **failing** if: - -- The PR title does not start with a valid type from the list above -- The type is not followed by a colon and a space -- The description after the colon is empty -- The type is capitalized (must be lowercase) - -Pass the check if the PR title matches the format with a valid type prefix. -```` - -### Dependency audit - -````markdown dependency-audit.md ---- -name: Dependency Audit -description: Review new or updated dependencies for risk ---- - -Review the pull request diff for changes to dependency manifests (`package.json`, `requirements.txt`, `pyproject.toml`, `go.mod`, `Cargo.toml`, `Gemfile`, or similar). - -If no dependency files were changed, pass the check. - -When dependencies were added or updated, flag as **failing** if any of these are true: - -- A new dependency has fewer than 100 GitHub stars or appears unmaintained (no commits in the last 12 months) -- A dependency was bumped by more than one major version (e.g., v2.x to v4.x) without a note in the PR description explaining the jump -- A known deprecated or security-flagged package was added -- A dependency was added that duplicates functionality already available from an existing dependency -- Dev dependencies were added to production dependency sections (e.g., a test framework in `dependencies` instead of `devDependencies`) - -Pass the check if: - -- All new dependencies are well-maintained and widely used -- Version bumps are single major versions or minor/patch updates -- Dependency changes are documented in the PR description if non-trivial -```` - -### Migration safety - -````markdown migration-safety.md ---- -name: Migration Safety -description: Check database migrations for destructive operations ---- - -Review the pull request diff for database migration files (SQL migrations, ORM migration files like Alembic, Knex, ActiveRecord, Prisma, or similar). - -If no migration files were added or changed, pass the check. - -When migrations are present, flag as **failing** if any of these are true: - -- `DROP TABLE` or `DROP COLUMN` without a preceding migration that backs up or migrates the data -- Column type narrowing (e.g., `TEXT` to `VARCHAR(50)`, `BIGINT` to `INT`) without a backfill step -- `NOT NULL` constraint added to an existing column without a `DEFAULT` value or a data backfill -- Renaming a column or table that is referenced by application code without updating that code in the same PR -- A destructive and a constructive change in the same migration file (split these into separate migrations for safe rollback) - -Pass the check if: - -- The migration only adds new tables, columns, or indexes -- Destructive operations include a clear backfill or data migration step -- The migration is idempotent (uses `IF EXISTS` / `IF NOT EXISTS` guards) -```` +See [Run Checks Locally](/checks/running-locally) for the full local testing workflow. diff --git a/docs/checks/running-locally.mdx b/docs/checks/running-locally.mdx index 5de256521..a2580f156 100644 --- a/docs/checks/running-locally.mdx +++ b/docs/checks/running-locally.mdx @@ -2,53 +2,36 @@ title: "Run Checks Locally" --- -Run your checks locally before pushing to CI using the `/checks` command in your coding agent (Claude Code, Cursor, or any agent that supports skills). +Run your checks locally before pushing to CI using the `/check` command in your coding agent (Claude Code, Cursor, or any agent that supports skills). -## Run all checks +## Install -Type `/checks` in your coding agent. It discovers every check file in `.continue/checks/` (and `.agents/checks/`), runs each one as a subagent against your current branch, and reports the results. - -``` -/checks +```bash +npx skills add continuedev/skills --skill check ``` -Output looks like: +## Run checks + +Type `/check` in your coding agent. It discovers every check file in `.continue/checks/`, runs each one as a subagent against your current branch, and reports the results. To run a single check, pass the file path: `/check .continue/checks/security-review.md`. ``` -✓ Security Review — PASS - No hardcoded secrets or SQL injection vectors found in the diff. - -✗ Migration Safety — FAIL - migrations/024_drop_legacy_users.sql drops the legacy_users table - without a preceding data migration. Add a backfill step or split - into two migrations. - -✓ Test Coverage — PASS - All new source files have corresponding test files. -``` - -## Run a single check - -To run one specific check, pass the file path: - -``` -/checks .continue/checks/security-review.md +/check ``` ## Iterate on a check -The local feedback loop is: edit the check file, run `/checks`, read the output, refine. Because checks run inside your coding agent, you can ask it to fix issues in the same session: +The local feedback loop is: edit the check file, run `/check`, read the output, refine. Because checks run inside your coding agent, you can ask it to fix issues in the same session: ``` The migration safety check is flagging additive-only migrations as failures. Update the check to only flag destructive operations. ``` -## Automate with AGENTS.md +## Run checks automatically -You can add `/checks` to your `AGENTS.md` so your coding agent runs checks automatically as part of its workflow — for example, after creating a PR: +You can add `/check` to your `AGENTS.md` so your coding agent runs checks automatically as part of its workflow — for example, after creating a PR: ```markdown AGENTS.md -After creating or updating a pull request, run /checks and fix any failures before requesting review. +After creating or updating a pull request, run /check and fix any failures before requesting review. ``` ## Why local?