Skip to content

Commit c9d8714

Browse files
committed
chore: Create CLAUDE.md
1 parent e9246e4 commit c9d8714

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

CLAUDE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Overview
6+
7+
ghats is a TypeScript library for defining GitHub Actions workflows using TypeScript instead of YAML. It allows developers to write workflows with type safety and autocompletion, then compile them to standard GitHub Actions YAML files.
8+
9+
## Common Commands
10+
11+
### Development
12+
- `bun install` - Install dependencies
13+
- `bun run lint` - Run Biome linter with error-on-warnings flag
14+
- `bun run fmt` - Format code with Biome (auto-fix mode)
15+
- `bun test` - Run tests
16+
- `bun test --coverage` - Run tests with coverage reporting
17+
18+
### Building
19+
- `bun run build:package` - Build the package (runs tasks/build.ts)
20+
- `bun run gha:build` - Build GitHub Actions workflows from TypeScript files
21+
22+
### ghats CLI Commands
23+
- `ghats install [actions...]` or `bun run gha:install` - Install and generate type definitions for GitHub Actions
24+
- `ghats build [workflows...]` or `bun run gha:build` - Build workflow YAML files from TypeScript
25+
- `ghats cache clear` - Clear the action cache
26+
27+
### Testing Workflows
28+
- When testing workflow generation, create an example TypeScript workflow and use `bun run ./lib/cli/index.ts build` to compile it
29+
30+
## High-Level Architecture
31+
32+
### Core Library Structure (`lib/`)
33+
- **package/**: Core workflow definition classes
34+
- `workflow.ts`: Main Workflow class for defining GitHub Actions workflows
35+
- `job.ts`: Job class supporting both normal jobs and reusable workflow calls
36+
- `step.ts`, `on.ts`, `permissions.ts`, etc.: Type definitions for workflow components
37+
38+
- **internal/**: JSON serialization and transformation logic
39+
- Each component has a corresponding internal module that handles conversion to YAML-compatible JSON
40+
41+
- **cli/**: Command-line interface implementation
42+
- `commands/build/`: Compiles TypeScript workflows to YAML
43+
- `commands/install/`: Fetches action schemas and generates TypeScript type definitions
44+
- Stores action metadata in `.github/workflows/actions.json` and `actions-lock.json`
45+
46+
### Key Design Patterns
47+
48+
1. **Builder Pattern**: Jobs and workflows use method chaining for configuration
49+
```typescript
50+
new Job("test", { runsOn: "ubuntu-latest" })
51+
.uses("actions/checkout@v4")
52+
.run("npm test")
53+
```
54+
55+
2. **Type-Safe Actions**: The `action()` function provides typed inputs for installed actions
56+
- Action schemas are fetched from GitHub and stored locally
57+
- TypeScript definitions are generated in `.github/workflows/actions.d.ts`
58+
59+
3. **File Conventions**:
60+
- Workflow TypeScript files in `.github/workflows/*.ts` are compiled to `*.yml`
61+
- Files starting with `_` (e.g., `_helpers.ts`) are ignored during build
62+
63+
### Build System
64+
65+
The project uses Bun as its runtime and build tool:
66+
- `tasks/build.ts`: Custom build script that:
67+
- Generates TypeScript declarations using oxc-transform
68+
- Builds CLI entry point with Node target
69+
- Builds library with external packages
70+
71+
### Code Quality
72+
73+
- **Linter**: Biome with strict configuration (must pass with --error-on-warnings)
74+
- **Formatter**: Biome with 2-space indentation and double quotes
75+
- **TypeScript**: Strict mode enabled with ESNext target
76+
- **Pre-commit**: Husky hooks configured (run with `husky` prepare script)

0 commit comments

Comments
 (0)