본문으로 건너뛰기

google/xmc

https://skillcdn.ai/gh/google/xmc

내 AI에 이 주소를 연결하면 이 스킬을 쓸 수 있어요. 연결 방법 보기

  • 미확인
  • 기본 브랜치main
  • 커밋4aa58c5
  • 라이선스Apache-2.0
  • 검색단어

커밋 4aa58c5 기준으로 보여 주고 있습니다

최신 커밋(81ffa97)을 색인하는 중입니다. 준비될 때까지 이 페이지와 모든 에이전트에는 마지막으로 색인된 커밋이 제공됩니다.
GitHub에서 보기

XMC Feature Development

Guides agents through feature development, code refactoring, Bazel test matrix execution, coverage measurement, and pre-commit verification.

경로
.agents/skills/xmc_feature_development/SKILL.md
라이선스
Apache-2.0

작성자를 위한 경고

  • "name" should use lowercase letters, digits and single hyphens only
  • "name" should match the name of the directory that holds SKILL.md
  • Not listed through the skills extension: the directory must be named after the skill.

Feature Development & Refactoring Playbook

This skill provides step-by-step procedures for implementing new features, refactoring existing code, running test matrices, measuring coverage, and preparing changes for PR submission.

[!IMPORTANT] All execution steps in this skill MUST strictly adhere to the policy rules defined in Core Engineering Standards and Skills & Automation Guidelines.


Guidelines for Using CLI Tools

When invoking helper tools under tools/ (e.g., run_affected_tests.py):

  1. Do not read tool source code: Do not open or read the Python source code of helper tools. Refer to Skills & Automation Guidelines.
  2. Use --help: Run tools with --help to inspect parameters and usage.
  3. Parse Structured Output & Handle Errors: All tools output structured JSON; check the exit code per Helper Tool Exit Codes.
  4. Shell & Payload Safety: Execute standalone .py script files or pass arguments via script parameters. Avoid double-quoted inline commands (python3 -c "...").

1. Requirements Scoping & Package Identification

  1. Scope Task & Identify Modified Files:
    • Analyze user request and identify target packages/directories (e.g., pkg/auth/oauth2, cmd/xid_service).
    • Identify existing 1-to-1 unit test files (e.g., handlers_test.go for handlers.go). If missing, plan to create a dedicated unit test file.
    • Search for existing implementations before planning new code: git grep the capability (in-repo packages, tools/), then check the standard library and declared dependencies, per the Reuse-First Policy.
  2. Dependency & Target Discovery:
    • Inspect the CI-equivalent affected test scope (including reverse dependencies and any UI/Helm suites under other_suites) without running tests:
      python3 ./tools/run_affected_tests.py --dry-run
      
    • To list affected go_binary targets for a specific package when needed:
      bazel query "kind(go_binary, rdeps(//..., //pkg/auth/oauth2/...))"
      

2. Code Implementation & Clean Code Design

  1. Apply SRP & KISS:
    • Keep functions focused and under the 20–30 line target cap.
    • Use early return guard clauses at the top of functions; eliminate redundant else blocks after returns.
    • Prefer default immutability (const in TypeScript, value receivers or immutable structs where applicable).
  2. Decouple Mocks & Baseline Test Fixtures:
    • Centralize shared helpers in global/shared packages.
    • Define baseline test fixtures and express test cases as concise deltas (e.g., using prototest.Modify).
  3. Test Inputs for Parsers & Pollers:
    • Parsers and linters: Test against the most complex real-world constructs in the target corpus (e.g., for Markdown: nested or long code fences, redirects, URLs, labels; for any parser: empty, malformed, and multibyte inputs), rather than only minimal synthetic inputs.
    • Polling and wait tools: Test every state transition, including the exact deadline boundary.
  4. Open-Source Code TODOs:
    • Ensure inline TODO comments in public packages use TODO: or public issue links TODO(#123), avoiding internal bug IDs.

3. Test Execution via Affected Tests Tool

  1. Run Affected Tests Script: Execute the automated affected tests runner to resolve all changed files since origin/main (including uncommitted and untracked files) via resolve_test_scope.py and run bazel test on affected targets with CI-equivalent flags:
    python3 ./tools/run_affected_tests.py
    
    • Output & Exit Codes: stdout emits structured JSON (changed_files, backend_mode, reason, bazel_targets, other_suites, passed_targets); Bazel output streams to stderr. Exits 0 when tests pass (or dry-run / nothing to run), 1 on test failures or handled errors (with failed targets and log paths in details), and 2 on unexpected errors.
    • Spanner Emulator: Pre-flights SPANNER_EMULATOR_HOST (default localhost:9010) and forwards non-default addresses via --test_env. Pass --skip-emulator-check when affected targets do not use Spanner.
    • Other Suites: When other_suites lists the UI or Helm chart suite, run those suites before opening a PR: bazel test //cmd/ui/... (after npm ci --legacy-peer-deps in cmd/ui) or bazel test //test/helm/....
  2. Targeted Package Iteration (During Editing):
    bazel test //pkg/auth/oauth2/...
    bazel query 'tests(//pkg/auth/oauth2/...)'  # list target names; never guess them
    
    Never run host go build, go vet, or go test. They fail on the Bazel-generated protobuf packages.

4. Code Coverage Measurement

  1. Execute Bazel Coverage: Run coverage evaluation for the target package:
    bazel coverage --combined_report=lcov //pkg/auth/oauth2/...
    
  2. Parse & Verify Coverage:
    • Locate the coverage output at bazel-out/_coverage/_coverage_report.dat.
    • Verify that 100% of newly added or modified lines of business logic are covered by unit tests.
    • Ensure 1-to-1 test file cohesion (each source file must have a dedicated *_test.go or *_test.py file).

5. Pre-Commit Verification & Staging

  1. Stage, Then Run Pre-Commit Hooks: Before committing code changes, stage them and run the repository pre-commit script, which formats files, auto-restages formatter fixes to fully staged files, runs linters, and executes run_affected_tests.py --skip-emulator-check:
    git add <changed_paths>
    ./.githooks/pre-commit
    
  2. Verify Linter & Affected Test Status: Ensure all linters and affected unit tests pass without errors or warnings.
  3. Proceed to PR Creation: Refer to the XMC Create PR Skill to format the commit message and submit a Pull Request.

이 스킬의 파일

이 스킬에는 보조 파일이 없습니다.

지원 파일 전체 둘러보기