This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SkillLens GitHub Action is a TypeScript-based GitHub Action that analyzes PR review feedback and posts learning recommendations from Hyperskill. The action reads review comments from pull requests, sends them to a SkillLens Proxy backend, and creates/updates a single PR comment with relevant educational resources.
Key Architecture: This is a custom TypeScript Action built from the actions/typescript-action template. TypeScript sources in src/ are bundled into a single JavaScript file in dist/index.js (which must be committed) so consumers don't need to install dependencies.
IMPORTANT: The dist/ directory contains generated JavaScript code that MUST be kept in sync with TypeScript sources. A GitHub Actions workflow validates this.
- Make changes to TypeScript files in
src/ - Run
npm run bundleto regeneratedist/index.js - Commit both the TypeScript changes AND the generated
dist/files - When reviewing PRs: do not review changes in
dist/— they mirror the TypeScript sources
# Install dependencies
npm install
# Run all checks (format, lint, test, coverage, bundle)
npm run all
# Bundle TypeScript to dist/index.js (MUST run after src/ changes)
npm run bundle
# Run tests
npm run test
# Run tests with coverage
npm run ci-test && npm run coverage
# Format code
npm run format:write
# Lint code
npm run lint
# Test locally with stubbed GitHub Actions environment
npm run local-action
# Requires .env file (see .env.example)- Trigger: PR review events (
pull_request_review,pull_request_review_comment,issue_comment) - Fetch: Use Octokit (via
@actions/github) withGITHUB_TOKENto fetch:- Inline review comments (
pulls.listReviewComments) - PR reviews with state/body (
pulls.listReviews) - Conversation comments (
issues.listComments)
- Inline review comments (
- Normalize: Filter noisy comments
- Authenticate: Request GitHub OIDC ID token (requires
id-token: writepermission) - API Call: POST to SkillLens Proxy with normalized reviews + OIDC token
- Comment: Upsert single PR comment using marker (
<!-- SkillLens:v0 -->) for idempotency
src/main.ts: Main entry point containing:
run(): Main execution function called by GitHub ActionslistData(): Fetches and normalizes all review data from GitHub APIisNoisy(): Filters trivial comments (emoji-only, "LGTM", etc.)upsertComment(): Creates or updates the single SkillLens PR comment
action.yml: Action metadata defining:
- Inputs:
oidc-audience,default-language,max-topics,min-confidence,comment-marker,fail-on-proxy-error - Outputs:
topics-json,comment-url - Runtime:
node24executingdist/index.js
- Location:
__tests__/directory - Framework: Jest with TypeScript support
- Fixtures: Place in
__fixtures__/directory - Run:
npm run test
- Write tests for both success path and edge cases
- Mock Octokit responses for GitHub API calls
- Mock fetch responses for SkillLens Proxy API
- Ensure tests maintain coverage requirements
- After refactoring, always run
npm run test
Use @github/local-action to test without committing:
npx @github/local-action . src/main.ts .envCreate .env file based on .env.example to simulate GitHub Actions environment.
- Follow TypeScript and JavaScript best practices
- Maintain consistency with existing patterns
- Keep functions focused and manageable
- Use descriptive names that convey purpose
- Document with JSDoc comments (focus on "why", not "what")
- Follow DRY principles
- Consider long-term maintainability
- Use TypeScript's type system for safety and clarity
- Avoid
anytypes where possible - Export types that may be useful for testing
- Always use
@actions/corefor logging (notconsole) - Methods:
core.info(),core.warning(),core.setFailed(),core.debug() - Ensures compatibility with GitHub Actions logging features
- Use consistent error handling patterns
- Respect
fail-on-proxy-errorinput for proxy failures - Use
core.setFailed()for critical errors - Use
core.warning()for non-critical issues - Exit gracefully when no data to process
Action consumers should use these simplified permissions in their workflow:
permissions:
pull-requests: write # Read PR reviews and create/update PR comments
id-token: write # Request OIDC tokenIf the minimal permissions don't work due to repository settings, try:
permissions:
contents: read # Read repo metadata
pull-requests: write # Read PR reviews and comments + write comments
issues: read # Additional PR comment read access
id-token: write # Request OIDC tokenNote: The pull-requests: write permission typically provides all necessary access for reading PR data and creating comments, as PRs use the Issues API for comments.
- Follow Semantic Versioning
- Update
package.jsonversion with each release - Create release tags (e.g.,
v1.0.0) - Move major tag (
v1) to latest stable release - Use
script/releasehelper for tagging and pushing releases
- Run
npm run allto ensure all checks pass - Ensure
dist/is up-to-date withsrc/changes - Update
README.mdif functionality/usage changed - Update version in
package.jsonif needed
- Keep changes focused and minimal
- Include summary of changes
- Note any dependency changes
- Link to relevant issues/discussions
- Provide context for reviewers
- Action uses built-in
GITHUB_TOKEN(not user-provided secrets) - OIDC token obtained via
core.getIDToken(audience) - Workflow must grant
id-token: writepermission - No repository source code is accessed or transmitted
- Only review comments are processed
| Path | Purpose |
|---|---|
src/main.ts |
Core action logic (fetch, normalize, call API, post comment) |
src/index.ts |
Entry point that calls run() from main.ts |
action.yml |
Action metadata (inputs, outputs, branding) |
dist/index.js |
Bundled JavaScript (generated, must commit) |
__tests__/ |
Jest test files |
rollup.config.ts |
Bundler configuration |
package.json |
Dependencies and scripts |
tsconfig.json |
TypeScript compiler configuration |
.env.example |
Template for local action testing |
- Forgetting to bundle: After changing
src/, must runnpm run bundleand commitdist/ - Reviewing dist/: Don't review
dist/changes in PRs — they mirror TypeScript sources - Using console: Use
@actions/corelogging methods instead ofconsole.log - Missing permissions: Consumers need
pull-requests: writeandid-token: writeat minimum - Testing without mocks: Mock GitHub API and proxy responses in tests
The repository includes a .devcontainer/ configuration for consistent development environments using VS Code Dev Containers or GitHub Codespaces.