askill
test-and-commit

test-and-commitSafety --Repository

Run unit tests, evaluate and fix relevant E2E tests, assess coverage needs, lint, and commit. Use when user says "test and commit", "run tests and commit", "verify and commit", or "CI and commit".

30 stars
1.2k downloads
Updated 1/27/2026

Package Files

Loading files...
SKILL.md

Test and Commit

Run unit tests first, evaluate/fix relevant E2Es, assess coverage, lint, then commit.

<when_to_use>

When to Use

Invoke when user says:

  • "test and commit"
  • "run tests and commit"
  • "verify and commit"
  • "CI and commit" </when_to_use>

Workflow Overview

PhaseActionGate
1Run all unit testsMust pass
2Identify relevant E2E testsBased on changes
3Fix failing E2Es, run relevant onlyMust pass
4Evaluate coverage needsAsk user
5Write new tests if neededOptional
6Lint and fix errorsMust pass
7Sync documentationUser approval
8Commit changesOnly if all pass

Track progress with TodoWrite.

Phase 1: Run All Unit Tests

Run the full unit test suite first. Stop if tests fail.

npm run test:unit -- --run
ResultAction
All passContinue to Phase 2
FailuresFix failing tests, re-run until pass

If failures are in changed files, fix them. If failures are pre-existing/unrelated, inform user and ask how to proceed.


Phase 2: Identify Relevant E2E Tests

  1. Get changed files:
git diff --name-only HEAD
  1. Map changed files to E2E tests using these rules:
Changed File PatternRelevant E2E Tests
src/pages/Sessions*.tsxplaywright/tests/session-*.spec.ts
src/pages/Accounts*.tsxplaywright/tests/account-*.spec.ts
src/pages/Contacts*.tsxplaywright/tests/contact-*.spec.ts
src/components/tables/*Table.tsxE2E for that domain
src/hooks/use*.tsE2E for features using that hook
src/services/*.service.tsE2E for features using that service
  1. List the relevant E2E tests found. If none are relevant, skip to Phase 4.

Phase 3: Run and Fix Relevant E2E Tests

Run only the relevant E2E tests identified in Phase 2:

npx playwright test <spec-file> --retries=3 --timeout=120000
ResultAction
All passContinue to Phase 4
FailuresEvaluate if failure is due to our changes

If E2E fails due to our changes:

  1. Read the failing test to understand what it expects
  2. Fix either the code or the test as appropriate
  3. Re-run until pass

If E2E fails due to pre-existing issues:

  1. Inform user of unrelated failure
  2. Ask whether to skip or fix

Phase 4: Evaluate Coverage Needs

Assess if new tests are needed for the changed files.

  1. Identify changed testable files (.ts, .tsx in src/, excluding tests)

  2. For each file, check:

    • Does a corresponding test file exist?
    • Does the test cover the changed functionality?
  3. Use AskUserQuestion if gaps exist:

{
  questions: [
    {
      question: "Found coverage gaps. Create tests for these files?",
      header: "Coverage",
      options: [
        {
          label: "Yes, create tests",
          description: "Write missing unit/E2E tests",
        },
        { label: "Skip for now", description: "Commit without new tests" },
      ],
      multiSelect: false,
    },
  ];
}

Phase 5: Write New Tests (If Needed)

If user approves, create tests following these patterns:

Code TypeTest TypeLocation
ComponentUnitsrc/**/__tests__/[name].test.tsx
HookUnitsrc/hooks/__tests__/[name].test.ts
ServiceUnitsrc/services/__tests__/[name].test.ts
Page flowE2Eplaywright/tests/[feature].spec.ts

Follow patterns in:

  • claude-patterns/testing-patterns.md (unit tests)
  • claude-patterns/playwright-best-practices.md (E2E tests)

Run new tests to verify they pass before continuing.


Phase 6: Lint and Fix Errors

Lint all changed files:

git diff --name-only HEAD | grep -E '\.(ts|tsx)$' | xargs npx eslint --max-warnings 0
ResultAction
PassContinue to Phase 8
ErrorsRun --fix, then fix remaining manually
# Auto-fix what's possible
git diff --name-only HEAD | grep -E '\.(ts|tsx)$' | xargs npx eslint --fix

Phase 7: Sync Documentation

Check if code changes affect documentation in .claude/rules/ and claude-patterns/.

  1. Get changed source files:
git diff --name-only HEAD | grep -E '\.(ts|tsx)$'
  1. Search documentation for references to changed files:
# For each changed file, search with multiple patterns
grep -rE "(src/path/to/file\.ts|filename\.ts)" claude-patterns/ .claude/rules/
  1. For each doc file with references to changed code:

    • Read the doc to understand context (not blind find/replace)
    • Verify the reference: Does the file/function still exist?
    • Identify staleness: Has the path, name, or behavior changed?
  2. Categorize updates needed:

Update TypeAction
File path renamedAuto-update (context-aware, not blind replacement)
Function/type renamed (clear 1:1)Auto-update with verification
Code deletedFlag for user - may need doc section removal
Pattern/behavior changedFlag for user - requires rewrite
Line number referencesFlag for user - inherently unstable
  1. If updates needed, use AskUserQuestion:
{
  questions: [
    {
      question: "Found stale documentation references. How to proceed?",
      header: "Doc Sync",
      options: [
        {
          label: "Update docs",
          description: "Apply context-aware updates, include in commit",
        },
        {
          label: "Review each",
          description: "Show me each change before applying",
        },
        { label: "Skip", description: "Commit code without doc updates" },
      ],
      multiSelect: false,
    },
  ];
}
ResultAction
Update docsApply updates, continue to Phase 7
Review eachShow diff for each doc, apply approved changes
SkipContinue to Phase 8 without doc changes
No stale refs foundContinue to Phase 8 (no prompt needed)

Known Limitations:

  • May miss relative paths or partial filename matches
  • Line number references become stale on any file edit
  • Cannot detect semantic/behavior changes, only structural (renames, deletions)

Phase 8: Commit

  1. Stage changed files:
git add <files>
  1. Commit with descriptive message:
git commit -m "$(cat <<'EOF'
<type>(<scope>): <description>

<body>

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"

<approval_gates>

Approval Gates

GatePhaseQuestion
Pre-existing failures1, 3"Tests failed but unrelated to changes. Skip or fix?"
Coverage gaps4"Create tests for uncovered files?"
Doc sync7"Found stale doc references. Update?"
Commit scope8"Which files to commit?" (if mixed changes)

</approval_gates>

<quick_reference>

Quick Reference

# Phase 1: Unit tests
npm run test:unit -- --run

# Phase 3: Specific E2E
npx playwright test <spec-file> --retries=3

# Phase 6: Lint changed files
git diff --name-only HEAD | grep -E '\.(ts|tsx)$' | xargs npx eslint --max-warnings 0

For commands: references/commands.md For test locations: references/test-locations.md </quick_reference>

Guidelines

  • Run unit tests before E2E (faster feedback loop)
  • Only run E2E tests relevant to changes (not full suite)
  • Fix test failures before adding new tests
  • Lint after all test work is complete
  • Ask user before creating new test files
  • Sync documentation before committing to keep docs accurate
  • Doc updates are context-aware reads, not blind find/replace

References

<version_history>

Version History

  • v5.1.0 (2026-01-20): Add Phase 7 for documentation synchronization

    • Detects when code changes affect .claude/rules/ and claude-patterns/
    • Context-aware updates (reads doc, understands purpose)
    • Auto-updates file paths and clear 1:1 renames
    • Flags deletions, behavior changes, and line numbers for user review
    • Known limitation: May miss some reference patterns
  • v5.0.0 (2026-01-20): Complete workflow restructure

    • Phase 1: Run ALL unit tests first (not just audit)
    • Phase 2-3: Evaluate and fix relevant E2E tests only
    • Phase 4-5: Coverage evaluation moved after test validation
    • Phase 6: Lint after all test work
    • Commit only after everything passes
    • Rationale: Catch test failures early, fix before committing
  • v4.1.0 (2025-01-18): AI optimization updates

    • Add blockquote summary after title
    • Soften directive language
  • v4.0.0 (2025-12-29): Slimmed down - removed checks handled by pre-push

    • Removed: typecheck, unit tests, E2E tests (pre-push hook handles these)
    • Kept: test coverage audit, selective lint, commit
  • v3.0.0 (2025-12-28): Refactored to follow skill-authoring-patterns

  • v1.0.0 (2025-11-30): Initial release </version_history>

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

AI review pending.

Metadata

Licenseunknown
Version5.1.0
Updated1/27/2026
Publisherenbyaugust

Tags

ci-cdgithub-actionslintingllmpromptingtesting