| name | krammeverifyrun |
| description | Run verification checks (tests, formatting, builds, linting, type checking) for affected code based on the project's configuration. Use when this capability is needed. |
| metadata | {"author":"abildtoft"} |
Verify Affected Code
Run verification checks (tests, formatting, builds, linting, type checking) for affected code based on the project's configuration.
Instructions
1. Read Project Configuration
First, read the project's CLAUDE.md to understand how checks should be run. Look for:
- Formatting commands (e.g.,
nx format:check, dotnet format, prettier --check)
- Linting commands (e.g.,
nx lint, eslint, dotnet format --verify-no-changes)
- Type checking commands (e.g.,
tsc --noEmit, nx typecheck)
- Build commands (e.g.,
nx build, dotnet build, npm run build)
- Test commands for different suites:
- Unit tests (e.g.,
nx test, dotnet test --filter Category=Unit)
- Component tests (e.g.,
nx component-test, Cypress component, Storybook)
- Integration tests (e.g.,
nx integration-test, dotnet test --filter Category=Integration)
- E2E tests (e.g.,
nx e2e, dotnet test --filter Category=E2E)
2. Fallback: Check CI Configuration
If CLAUDE.md doesn't specify commands, check CI configuration files:
.github/workflows/*.yml (GitHub Actions)
.gitlab-ci.yml (GitLab CI)
azure-pipelines.yml (Azure DevOps)
Jenkinsfile (Jenkins)
.circleci/config.yml (CircleCI)
Extract the test, build, lint, and format commands from these files.
3. Detect Project Type
If no configuration specifies commands, detect the project type:
- Nx workspace: Check for
nx.json or project.json
- C#/.NET: Check for
*.csproj or *.sln files
- Node.js: Check for
package.json
4. Determine Base Branch
For affected detection and format checks, determine the base branch:
- Check CLAUDE.md for a specified base branch
- Check
nx.json for defaultBase setting (Nx projects)
- Auto-detect from git:
git symbolic-ref refs/remotes/origin/HEAD | sed 's|refs/remotes/origin/||'
- Fallback: Check if
main exists, otherwise use master
BASE_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||') || BASE_BRANCH="main"
5. Discover Available Targets (Nx)
For Nx projects, discover available targets before running:
nx show projects --affected
nx show project <project-name> --json | jq '.targets | keys'
6. Run Verification
Run checks in this order (continue through ALL checks even if some fail):
- Formatting - Check code formatting without modifying files
- Linting - Run static analysis/linting
- Type checking - Verify TypeScript types compile
- Build - Compile/build the project
- Unit tests - Fast, isolated tests
- Component tests - UI component tests (if available)
- Integration tests - Tests with dependencies (if available)
- E2E tests - End-to-end tests (if available)
Default Commands by Project Type
Nx Workspace (TypeScript/JavaScript)
nx show projects --affected --base=$BASE_BRANCH
nx format:check --base=$BASE_BRANCH
nx affected -t lint --parallel --base=$BASE_BRANCH
nx affected -t typecheck --parallel --base=$BASE_BRANCH
nx affected -t build --parallel --base=$BASE_BRANCH
nx affected -t test --parallel --base=$BASE_BRANCH
nx affected -t component-test --parallel --base=$BASE_BRANCH
nx affected -t integration-test --base=$BASE_BRANCH
nx affected -t e2e --base=$BASE_BRANCH
C#/.NET Project
dotnet restore
dotnet format --verify-no-changes
dotnet build --no-restore
dotnet test --no-build
dotnet test --no-build --filter "Category=Unit"
dotnet test --no-build --filter "Category=Integration"
dotnet test --no-build --filter "Category=E2E"
Standard Node.js Project
cat package.json | jq '.scripts | keys'
npm run format:check
npm run lint
npm run typecheck
npm run build
npm run test
npm run test:component
npm run test:integration
npm run test:e2e
Critical Requirements
Error Output
- ALWAYS capture and display the FULL error output when any check fails
- Do NOT truncate or summarize error messages
- Include file paths, line numbers, and specific error descriptions
- This allows immediate identification and fixing of issues
Test Suite Discovery
Before running tests, discover what's available:
For Nx:
nx show projects --affected --base=$BASE_BRANCH -t test
nx show projects --affected --base=$BASE_BRANCH -t component-test
nx show projects --affected --base=$BASE_BRANCH -t integration-test
nx show projects --affected --base=$BASE_BRANCH -t e2e
For C#:
- Check test project files for
[Category("Unit")] etc. attributes
- Check CI configuration for test filter patterns
For Node.js:
- Check
package.json scripts section for test variations
Handling Failures
- Run ALL verification steps even if earlier steps fail
- Collect ALL errors from ALL failed steps
- Present a comprehensive summary with all issues at the end
- Format errors clearly so they can be acted upon immediately
Parallelization
Use parallel execution where possible for faster feedback:
- Nx: Use
--parallel flag (e.g., nx affected -t lint --parallel)
- dotnet: Tests run in parallel by default, can configure with
--parallel
- npm: Check if scripts support parallel execution
Output Format
After running all checks, provide:
1. Individual Step Results with Errors
## Formatting
Status: PASS
## Linting
Status: FAIL
Errors:
src/components/Button.tsx:15:3
error: 'unused' is defined but never used @typescript-eslint/no-unused-vars
src/utils/helpers.ts:42:10
error: Missing return type on function @typescript-eslint/explicit-function-return-type
## Type Checking
Status: PASS
## Build
Status: PASS
## Unit Tests
Status: FAIL
Errors:
FAIL src/utils/helpers.test.ts
● calculateTotal › should handle empty array
Expected: 0
Received: undefined
at Object.<anonymous> (src/utils/helpers.test.ts:25:14)
## Component Tests
Status: SKIPPED (no component-test target found)
## Integration Tests
Status: PASS
## E2E Tests
Status: SKIPPED (not running E2E for this verification)
2. Summary
Verification Summary:
- Formatting: PASS
- Linting: FAIL (2 errors)
- Type Checking: PASS
- Build: PASS
- Unit Tests: FAIL (1 error)
- Component Tests: SKIPPED
- Integration Tests: PASS
- E2E Tests: SKIPPED
Issues Found: 2 steps failed - see errors above for details
Important Notes
- Always prefer commands from CLAUDE.md over defaults
- Use
--affected or equivalent to minimize scope when possible
- Do NOT automatically fix issues - this is a verification command only
- If CLAUDE.md specifies a base branch for affected detection, use it; otherwise auto-detect (see step 4)
- If a test suite/target doesn't exist, mark it as SKIPPED, don't fail
- For faster iteration, E2E tests can be skipped with user confirmation
- Always verify targets exist before running them to avoid confusing errors
Converted and distributed by TomeVault — claim your Tome and manage your conversions.