Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9d8775b
SK-2832 add Claude Code setup (CLAUDE.md, commands, workflows)
Devesh-Skyflow May 29, 2026
08df1ab
SK-2832 remove release-v1.yml — not part of Claude setup
Devesh-Skyflow May 29, 2026
1819b05
SK-2832 split samples context into samples/CLAUDE.md
Devesh-Skyflow May 29, 2026
c8b52b0
SK-2832 add basic samples reference to root CLAUDE.md
Devesh-Skyflow May 29, 2026
50fe8bf
SK-2832 make commit guidelines directive for Claude
Devesh-Skyflow May 29, 2026
c3ec30f
SK-2832 replace redundant commit rules with /commit reference
Devesh-Skyflow May 29, 2026
9de9e92
fix: example
Devesh-Skyflow May 29, 2026
a9647ce
SK-2832 rename /test to /quality, add 100% coverage requirement
Devesh-Skyflow May 29, 2026
1b54cee
SK-2832 reference /quality in code-review final verdict
Devesh-Skyflow May 29, 2026
d3dc74b
SK-2832 add /quality check step to /commit before committing
Devesh-Skyflow May 29, 2026
390b513
SK-2832 enforce /commit rule in CLAUDE.md, add /quality to review skill
Devesh-Skyflow May 29, 2026
2f1eac1
SK-2832 require /quality before code-review, not just after
Devesh-Skyflow May 29, 2026
80a5ebf
SK-2832 add descriptive header to checkstyle-on-edit.py
Devesh-Skyflow May 29, 2026
fedad62
SK-2832 remove paths from review skill, delegate all rules to code-re…
Devesh-Skyflow May 29, 2026
cadbca9
SK-2832 restore paths to review skill for proactive review triggers
Devesh-Skyflow May 29, 2026
eceba8f
Merge remote-tracking branch 'origin/main' into devesh/SK-2832-claude…
Devesh-Skyflow May 29, 2026
967c3c9
SK-2832 add devesh to cspell wordlist
Devesh-Skyflow May 29, 2026
ed287b1
SK-2832 suppress cspell on branch name example, revert devesh from wo…
Devesh-Skyflow May 29, 2026
e437f44
SK-2832 update the claude setup and remove duplicate things
skyflow-bharti Jun 1, 2026
d571bef
SK-2832 Rename the commit md file to git-commit
skyflow-bharti Jun 1, 2026
5ad91d6
SK-2832 Removed the duplicate section from commands
skyflow-bharti Jun 1, 2026
10b523e
SK-2832 Removed the duplicate section from skill
skyflow-bharti Jun 1, 2026
72e0853
SK-2832 Removed the duplicate claude setup file from samples
skyflow-bharti Jun 1, 2026
b8fb38b
SK-2832 Removed the unused code patterns
skyflow-bharti Jun 1, 2026
976079b
SK-2832: Updated pr review workflow
aadarsh-st Jun 2, 2026
10e1c09
SK-2832: Fix claude issue
aadarsh-st Jun 2, 2026
7953daa
SK-2832: fix
aadarsh-st Jun 2, 2026
ec3e412
SK-2832: check api key valid or not
aadarsh-st Jun 2, 2026
93f8bd5
SK-2832: Debug
aadarsh-st Jun 2, 2026
e409f0a
SK-2832: Updated the token count
aadarsh-st Jun 2, 2026
376bdef
SK-2832: Updated condition for code-review
aadarsh-st Jun 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .claude/commands/code-quality.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
name: code-quality
description: Quality pipeline — compile, checkstyle, build, tests, coverage check. Pass a class name to target a single test class.
paths:
- src/**/*.java
- pom.xml
exclude:
- src/main/java/com/skyflow/generated/**
context: fork
---

Run the Skyflow Java SDK quality pipeline.

Use `$ARGUMENTS` to target a specific test class (e.g. `BearerTokenTests`). If empty, run the full suite.

> Baseline failures are documented in the Known Pre-existing Test Failures table.
> Do not investigate them unless specifically asked. Only report failures **beyond** that baseline.

## Coverage Requirements

Follow the Tests coding rules (100% instruction + branch coverage). Public interface packages:
- `src/main/java/com/skyflow/vault/` (controllers, data, tokens, connection, audit, bin, detect)
- `src/main/java/com/skyflow/config/`
- `src/main/java/com/skyflow/serviceaccount/`

Flag any gap as a blocker — **NEEDS FIXES** if coverage is below 100% on Claude-written or public interface code.

---

## Pipeline

### Step 1 — Compile
```bash
mvn compile -q 2>&1 | tail -20
```
Expected: no output (clean compile). Report any errors.

### Step 2 — Checkstyle
```bash
mvn checkstyle:check -q 2>&1 | tail -20
```
Note: `failsOnError=false` in pom.xml means the build will not fail even if violations exist — check the output for `[WARN]` checkstyle lines. Violations are excluded from `generated/` by pom config.

### Step 3 — Build
```bash
mvn package -DskipTests -q 2>&1 | tail -20
```
Expected: BUILD SUCCESS.

### Step 4 — Tests
If `$ARGUMENTS` is set:
```bash
mvn test -Dtest=$ARGUMENTS -q 2>&1 | tail -40
```
Otherwise:
```bash
mvn test -q 2>&1 | tail -40
```
Report: tests run, failures, errors. Flag any pre-existing failures separately from new ones.

### Step 5 — Coverage analysis
For every public interface class and every class touched by Claude in this session:
- Check for a corresponding test file under `src/test/`
- Check that every public method has at least one positive and one negative test case
- Check that every branch (if/else, switch, try/catch) is covered

List all gaps. Any gap on Claude-written or public interface code is a **blocker**.

### Step 6 — Edge case identification
For any class below 100% coverage, identify missing scenarios:
- Null / empty inputs
- Invalid types / wrong enum values
- Concurrent / reuse scenarios
- Error paths (API rejection, network failure)

Write concrete JUnit 4 test method stubs (not full implementations) for each gap.

### Step 7 — Report

```
| Step | Status | Notes |
|------------------|-----------|------------------------------|
| Compile | ✅ / ❌ | ... |
| Checkstyle | ✅ / ❌ | ... |
| Build | ✅ / ❌ | ... |
| Tests | ✅ / ❌ | N passed, M failed |
| Coverage (100%) | ✅ / ❌ | list classes with gaps |
```

Conclude with **READY TO MERGE** or **NEEDS FIXES** and a prioritised fix list.
83 changes: 83 additions & 0 deletions .claude/commands/code-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
name: code-review
description: Full code review — SDK patterns, naming, test coverage, then runs /code-smell and /code-security.
paths:
- src/main/java/**/*.java
- src/test/java/**/*.java
exclude:
- src/main/java/com/skyflow/generated/**
context: fork
---

You are a senior engineer performing a thorough code review on the Skyflow Java SDK.

## Pre-requisite

If `GITHUB_ACTIONS` environment variable is set, skip this step (CI runs compile/test in a separate job).

Otherwise, confirm `/code-quality` has been run and passed (compile, tests, 100% coverage). If it has not been run, run it now before proceeding with the review.

## Scope

Use `$ARGUMENTS` to determine scope:
- `full review` — scan all files under `src/main/java/com/skyflow/` recursively (exclude `generated/`)
- A file or directory path — review only that path
- Empty / default — review files changed on current PR/branch vs base:
```bash
BASE="${GITHUB_BASE_REF:+origin/$GITHUB_BASE_REF}"
BASE="${BASE:-main}"
git diff "$BASE"...HEAD --name-only | grep '\.java$' | grep -v 'generated'
```
**If `GITHUB_ACTIONS` is set:** work from the diff output directly (changed lines only) instead of reading full files:
```bash
git diff "$BASE"...HEAD -- '*.java' | grep -v 'src/main/java/com/skyflow/generated/'
```
Review only added lines (`+` prefix) from the diff. Do not comment on unchanged context lines or pre-existing code.

---

## Step 1 — SDK Pattern Review

Review all files in scope against the rules defined in `CLAUDE.md` (loaded automatically from the project root). Check every rule category: naming conventions, error handling, request/response patterns, string literals, tests, and code quality.

Group findings by file and produce a table:

```
### path/to/File.java

| Severity | Line | Finding |
|----------|------|---------|
| Critical | 42 | SkyflowException swallowed in catch block |
| Bug | 87 | skyflow_id not normalised to skyflowId |
| Quality | 103 | Magic string "records" — use Constants |
```

**Severities:**

| Level | Meaning |
|---|---|
| **Critical** | Data loss, silent failure, security risk — must fix before merge |
| **Bug** | Wrong behaviour, incorrect output — must fix before merge |
| **Edge Case** | Unhandled input that will cause runtime failure — fix before merge |
| **Quality** | Maintainability issue, naming violation, missing pattern — fix before merge |

---

## Step 2 — Code Smell Analysis

Read the file `.claude/commands/code-smell.md` and follow all of its instructions for the same files in scope. Produce its full output (per-file smell table + smell summary + recommendation).

---

## Step 3 — Security Audit

Read the file `.claude/commands/code-security.md` and follow all of its instructions for the same files in scope. Produce its full output (per-finding blocks + summary table + overall risk rating).

---

## Final Verdict

After all three steps, close with:
1. A tech-debt summary table grouped by category (SDK Patterns / Error Handling / Naming / Tests / Smells / Security)
2. A verdict: `APPROVE` / `APPROVE WITH FIXES` / `REQUEST CHANGES`
3. Remind: run `/code-quality` again after any fixes before merging.
71 changes: 71 additions & 0 deletions .claude/commands/code-security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: code-security
description: Security audit — credential exposure, input validation, path traversal, HTTP security, token lifecycle, dependency CVEs.
paths:
- src/main/java/com/skyflow/**/*.java
- pom.xml
exclude:
- src/main/java/com/skyflow/generated/**
context: fork
---

You are a security engineer auditing the Skyflow Java SDK for vulnerabilities.

## Audit Scope

Use `$ARGUMENTS` to determine target files. If none provided, run:
```bash
# CI: GITHUB_BASE_REF is set (e.g. "main") — use origin/ prefix
# Local: unset — use main directly
BASE="${GITHUB_BASE_REF:+origin/$GITHUB_BASE_REF}"
BASE="${BASE:-main}"
git diff "$BASE"...HEAD --name-only | grep '\.java$' | grep -v 'generated'
```

## Security Checks

### 1. Credential and token exposure (Critical)
- Bearer tokens, API keys, and private keys must never appear in logs, error messages, exception messages, or `toString()` output
- `Credentials` fields (`path`, `token`, `apiKey`, `credentialsString`) must not be serialised to logs
- JWT claims must not be logged

### 2. Input validation (High)
- All string inputs from callers must be null/empty checked before use
- File paths passed to `new File(path)` must not allow path traversal (`../`)
- JSON strings parsed with `JsonParser` must be wrapped in try/catch for `JsonSyntaxException`

### 3. Credentials file handling (High)
- Credentials files must only be read from paths provided by the caller — no environment variable path injection without sanitisation
- `FileReader` must be in a try-with-resources or explicitly closed

### 4. HTTP security (Medium)
- All API calls must go over HTTPS — verify `Utils.getBaseURL` enforces this
- Authorization headers must not be logged at any log level
- HTTP timeouts must be configured

### 5. Error information leakage (Medium)
- `SkyflowException` messages must not include raw server response bodies that could contain PII
- Stack traces must not be surfaced to callers — wrap in `SkyflowException`

### 6. Dependency vulnerabilities (Low)
- Note any dependencies that are known to have CVEs (check pom.xml versions)

### 7. Authentication lifecycle (Medium)
- Bearer token caching must check expiry before reuse
- Token refresh must be thread-safe (`synchronized` or equivalent)

## Output Format

For each finding:

```
### path/to/File.java : line N

**Severity:** Critical / High / Medium / Low / Info
**Risk:** What an attacker could do
**Trigger:** Input or code path that triggers the vulnerability
**Fix:** Concrete remediation with code example
**CWE:** CWE-NNN
```

End with a summary table and overall risk rating.
149 changes: 149 additions & 0 deletions .claude/commands/code-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
---
name: code-smell
description: Structural smell analysis + spell check — long methods, dead code, misplaced validation, deep nesting, magic numbers. Does not check patterns or security.
paths:
- src/main/java/**/*.java
- src/test/java/**/*.java
- .claude/**/*.md
- docs/**/*.md
exclude:
- src/main/java/com/skyflow/generated/**
context: fork
---

You are a senior engineer performing a code smell analysis on the Skyflow Java SDK.

## Scope

Use `$ARGUMENTS` to determine scope:
- A file or directory path — analyse only that path
- Empty / default — analyse files changed on current branch vs `main`:
```bash
git diff main...HEAD --name-only | grep '\.java$' | grep -v 'generated'
```

---

## Spell check

Before analysing smells, run cspell on the files in scope:

```bash
npx cspell --no-progress "src/**/*.java" ".claude/**/*.md" "CLAUDE.md" "docs/**/*.md" 2>&1 | grep "Unknown word"
```

Report any spelling violations at **Smell** severity in the per-file table. The word list is in `.cspell.json` — add legitimate project-specific terms there rather than fixing them as typos.

---

## What Are Code Smells

Code smells are structural signals — they do not necessarily mean the code is broken, but they indicate areas of technical debt, reduced readability, or future maintenance risk. All findings are reported at **Smell** severity and do not block merge unless they indicate a design violation.

---

## Smell Catalogue

### Method & Class Size

**Long method** — any method over 40 lines.
Signal: the method is doing too much. Candidate for decomposition into named private helpers.

**Long class** — any class over 300 lines.
Signal: the class may be taking on too many responsibilities. Check if it can be split by concern.

**Large parameter list** — more than 4 parameters on a method.
Signal: consider a config/options object or a builder to group related parameters.

---

### Responsibility Violations

**Business logic in Request/Response classes**
Request and Response classes are data holders — they carry data, nothing more. Flag any conditional logic, field transformation, or computation beyond null-safe getters.
Example of a violation: a Response class that renames map keys in `toString()` instead of letting the controller do it.

**toString() with business logic**
`toString()` should only serialise state for debugging. Logic like field renaming, manual JSON construction, conditional field injection, or iteration belongs in the controller or formatter methods.

**Validation outside `Validations.java`**
Any `if (x == null) throw new SkyflowException(...)` outside `src/main/java/com/skyflow/utils/validations/` is misplaced validation. All request validation must live in `Validations.validateXxxRequest()`.

---

### Control Flow

**Deep nesting** — more than 3 levels of `if` / `for` / `try` nesting.
Signal: extract inner blocks to named private methods. Deep nesting hides the happy path.

**Long if-else chains** — more than 4 branches on the same condition.
Signal: consider a `Map`, `switch`, or polymorphism.

**Null checks scattered**
Multiple consecutive null guards that could be replaced with `Optional` or an early return guard clause.

---

### Data

**Magic numbers**
Literal integers or sizes (e.g. `25`, `3600`, `100`) without a named constant. Use `Constants`.

**Raw HashMap chains**
`HashMap<String, Object>` passed through more than 2 method boundaries without a typed wrapper or explanatory comment. Flag for awareness — do not require an immediate fix.

**Temporary field**
A class field that is only set in certain code paths and is `null` the rest of the time. Should be a local variable or method parameter instead.

---

### Dead Code

**Unused private methods** — private methods with no callers.

**Unused imports** — any `import` not referenced in the file.

**Unreachable code** — code after `return` / `throw` in the same branch.

**Commented-out code** — blocks of commented code without explanation. Remove entirely or add a `// TODO: [ticket]` with context.

---

### Comments

**Explains what, not why**
A comment that restates what the code does (`// get the vault ID`) adds no value. Only flag comments that explain the *what* without explaining *why*.

**Stale comment**
A comment that contradicts the current code — e.g. references a removed parameter, an old method name, or a behaviour that has changed.

---

## Output Format

Group findings by file:

```
### path/to/File.java

| Smell | Line | Detail |
|---------------------------|------|-----------------------------------------------------------|
| Long method | 42 | processInsertResponse() is 67 lines — decompose |
| Business logic in Response| 88 | toString() renames skyflow_id — move to formatter |
| Magic number | 103 | Literal 25 — extract to Constants.MAX_QUERY_RECORDS |
| Stale comment | 210 | References removed tokenizedData field |
| Dead code | 315 | Private method buildHeaders() has no callers |
```

End with a **Smell Summary** table:

```
| Category | Count | Files affected |
|-----------------------|-------|------------------------|
| Long methods | 2 | VaultController.java |
| Business logic in DTO | 1 | QueryResponse.java |
| Magic numbers | 3 | Validations.java |
| Dead code | 2 | Utils.java |
```

Close with a recommendation: **CLEAN** / **MINOR DEBT** / **SIGNIFICANT DEBT** and a one-sentence summary.
Loading
Loading