Claude
Skills
Sign in
Back

init

Included with Lifetime
$97 forever

Initialize Triqual for this project. Analyzes project structure, detects existing tests, generates config. Run on first use or after major changes.

General

What this skill does


# /init - Project Genesis

Configure Triqual for the current project by analyzing its structure and generating personalized configuration files.

## When to Use

- **First time using Triqual** in a project
- **After major project restructuring** (new test directories, different framework setup)
- **When onboarding a new team member** to ensure consistent configuration
- **After updating Triqual plugin** to regenerate configuration with new features

## Quick Start

```bash
/init                    # Interactive - analyzes and generates config
/init --force            # Regenerate even if config exists
```

## Workflow Overview

```
┌─────────────────────────────────────────────────────────────────┐
│                     TRIQUAL INIT PROCESS                        │
├─────────────────────────────────────────────────────────────────┤
│  0. CREATE .TRIQUAL DIRECTORY                                   │
│     ├── mkdir -p .triqual/runs                                  │
│     ├── mkdir -p .triqual/context                               │
│     └── Create knowledge.md from template                       │
│                                                                 │
│  1. CHECK EXISTING CONFIG                                       │
│     └── Skip if triqual.config.ts exists (unless --force)       │
│                                                                 │
│  2. DETECT PROJECT STRUCTURE                                    │
│     ├── Find playwright.config.ts/js                            │
│     ├── Locate test directories                                 │
│     ├── Identify Page Objects                                   │
│     └── Scan package.json for dependencies                      │
│                                                                 │
│  3. ANALYZE EXISTING TESTS                                      │
│     ├── Count .spec.ts / .test.ts files                         │
│     ├── Extract common selectors                                │
│     ├── Detect timeout patterns                                 │
│     └── Identify helper functions                               │
│                                                                 │
│  4. DETECT AUTHENTICATION STRATEGY                              │
│     ├── Check for .auth/ storageState files                     │
│     ├── Find auth.setup.ts / global-setup.ts                    │
│     ├── Locate test credentials (users.ts, .env.test)           │
│     ├── Parse playwright.config for storageState usage          │
│     └── Determine best auth strategy for /test                  │
│                                                                 │
│  5. DETECT MCP CAPABILITIES                                     │
│     ├── Check Playwright MCP availability                       │
│     ├── Verify browser_run_code for storageState                │
│     ├── Check Quoth/Exolar connectivity                         │
│     └── Configure fallback strategies                           │
│                                                                 │
│  6. GENERATE CONFIGURATION                                      │
│     ├── triqual.config.ts (root) - TypeScript with defineConfig │
│     └── Docs/context/ (optional detailed config)                │
│         ├── project.json                                        │
│         ├── patterns.json                                       │
│         └── selectors.json                                      │
│                                                                 │
│  7. DISPLAY SUMMARY                                             │
│     └── Show what was detected and generated                    │
└─────────────────────────────────────────────────────────────────┘
```

---

## Step 0: Create .triqual Directory Structure

Before anything else, ensure the .triqual directory structure exists:

```bash
# Create .triqual directory structure
mkdir -p .triqual/runs .triqual/context

# Check if knowledge.md exists, create from template if not
ls .triqual/knowledge.md 2>/dev/null
```

If `.triqual/knowledge.md` doesn't exist, create it from the template at `${PLUGIN_ROOT}/context/knowledge.template.md`:

```bash
# Get plugin root (where Triqual is installed)
# Copy knowledge template
cp "${PLUGIN_ROOT}/context/knowledge.template.md" .triqual/knowledge.md
```

The `.triqual/` directory structure:
```
.triqual/
├── runs/           # Run logs for each feature (e.g., login.md, dashboard.md)
├── knowledge.md    # Project-specific test knowledge (accumulated learnings)
└── context/        # Pre-built context files per feature (generated by triqual_load_context)
```

**Important:** Run logs in `.triqual/runs/` are required by hooks before writing test files.
Context files in `.triqual/context/` are required by hooks before dispatching test-planner.

---

## Step 1: Check Existing Configuration

First, check if Triqual is already configured:

```bash
# Check for existing configuration files (prefer .ts)
ls triqual.config.ts 2>/dev/null || ls triqual.config.json 2>/dev/null
```

**If configuration exists:**
- Inform user: "Triqual is already configured. Use `/init --force` to regenerate."
- Exit unless `--force` flag is provided

**If no configuration:**
- Proceed with analysis

---

## Step 2: Detect Project Structure

### 2.1 Find Playwright Configuration

```bash
# Look for Playwright config files
ls playwright.config.ts playwright.config.js 2>/dev/null
```

If found, read it to extract:
- `testDir` - Where tests are located
- `baseURL` - Default application URL
- `timeout` - Global timeout settings
- `projects` - Multi-project setup

### 2.2 Analyze package.json

```bash
cat package.json | grep -E '"@playwright|"playwright|"test":'
```

Extract:
- Playwright version
- Test scripts (npm test, npm run test:e2e, etc.)
- Related dependencies (test utilities)

### 2.3 Find Test Directories

Search in common locations:

```bash
# Common test directory patterns
ls -d tests/ test/ e2e/ automation/ playwright/ spec/ __tests__/ 2>/dev/null

# Playwright-specific
ls -d automation/playwright/tests/ e2e/tests/ tests/e2e/ 2>/dev/null
```

### 2.4 Locate Page Objects

```bash
# Find Page Object files
find . -name "*.page.ts" -o -name "*.page.js" -o -name "*Page.ts" -o -name "*Page.js" 2>/dev/null | head -20
```

### 2.5 Find Helpers and Utilities

```bash
# Find helper/utility files
find . -path "*/helpers/*" -name "*.ts" -o -path "*/utils/*" -name "*.ts" 2>/dev/null | head -20
```

---

## Step 3: Analyze Existing Tests

### 3.1 Count Test Files

```bash
# Count .spec.ts and .test.ts files
find . -name "*.spec.ts" -o -name "*.test.ts" 2>/dev/null | wc -l
```

### 3.2 Extract Common Selectors

Read a sample of test files and identify selector patterns:

```bash
# Find most common selector patterns
grep -Erh "locator|getByRole|getByTestId|data-testid" --include="*.spec.ts" . 2>/dev/null | head -50
```

Identify:
- Primary strategy (data-testid, role, text)
- Custom attributes
- Page-specific patterns

### 3.3 Detect Timeout Patterns

```bash
# Check for timeout usage
grep -rh "timeout:" --include="*.spec.ts" . 2>/dev/null | head -20
```

### 3.4 Find Authentication Setup

```bash
# Look for auth setup
ls .auth/ auth.setup.ts global-setup.ts 2>/dev/null
grep -rh "storageState" --include="*.ts" . 2>/dev/null | head -10
```

---

## Step 4: Detect Authentication Strategy

This is critical for `/test` to work with authenticated flows. Detect what auth methods are available and choose the best strategy.

### 4.1 Check for Saved StorageState

```bash
# Check for .auth/ directory with saved state
ls -la .auth/*.json 2>/dev/null

# Common patterns
ls .auth/user.json .auth/admin.json .auth/storageState.json 2>/dev/null
```

**If found:** Can use `storageState` directly via Playwright MCP's `browser_run_code`:

```javascript
browser_run_code({
  code: `async (page) => {
    await page.context().addCookies(require('./.auth/user.json').cookies);
  }`
})
Files: 1
Size: 27.7 KB
Complexity: 31/100
Category: General

Related in General