Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Jun 2, 2025

These are notes Claude took for itself. A quick review would be appreciated, then I let it loose on those in the background.

Already noting that most of the remaining singletons it identified are probably not worth fixing, but curious on your take.


Summary by cubic

Added a set of detailed code quality reports identifying issues with ambiguous types, error handling, invalid state representations, module imports, and singleton patterns across the codebase.

  • New Reports
    • Added markdown reports in docs/code-quality-tasks/ covering: ambiguous type usage, inappropriate error handling, invalid state representations, module graph and import issues, and singleton patterns.
    • Each report lists specific code locations, describes the problem, and provides recommendations for future improvements.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic found 3 issues across 5 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.


```typescript
// Instead of module-level state
export type Cache = Map;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code snippet defines a type alias using the value identifier Map, which is not a valid TypeScript type on its own and will fail to compile; the alias should specify the generic parameters, e.g., Map<string, string>.

Suggested change
export type Cache = Map;
export type Cache = Map<string, string>;

@@ -0,0 +1,115 @@
# Ambiguous Types and Inappropriate 'any' Usage Report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document hard-codes exact source line numbers (e.g. Line 31) which will quickly become stale as code evolves, making the report misleading and harder to maintain.

2. **packages/builder/src/built-in.ts** - Core functionality with multiple 'any'
3. **packages/memory/traverse.ts** - Complex traversal logic with 'any'
4. **packages/builder/src/types.ts** - Type definitions themselves use 'any'
5. **packages/js-runtime/interface.ts** - Interface definitions with 'any' No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File lacks a trailing newline, which can cause unnecessary diffs and violates POSIX text file conventions.

@@ -0,0 +1,282 @@
# Inappropriate Error Handling Report
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,336 @@
# Invalid State Representations Report
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

export function createClock(): Clock { ... }
```

## 3. Missing or Incorrect Import Grouping
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be nice to use consistent ordering here, but doesn't seem like lint/fmt can ensure that -- this tenant could be lower priority than others as a lint preference rather than a functional change

Comment on lines 129 to 145
## 5. Module-Specific Dependencies (Good Practices Found)

The codebase correctly follows the guideline for module-specific dependencies:

### Good Examples:
- `packages/llm/deno.json` - Correctly declares `json5` dependency
- `packages/ui/deno.json` - Correctly declares `@shoelace-style/shoelace` dependency
- Most packages don't have unnecessary dependencies in their `deno.json`

**This is a positive finding** - the codebase correctly avoids adding package-specific dependencies to the workspace `deno.json`.

## 6. Non-standard JS Usage

**Positive Finding**: The codebase is clean of non-portable JavaScript patterns:
- No direct use of environment variables in module scope
- No Vite-specific APIs (`import.meta.hot`, `import.meta.glob`) outside of Vite plugin code
- Clean separation between build-time and runtime code
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

- No Vite-specific APIs (`import.meta.hot`, `import.meta.glob`) outside of Vite plugin code
- Clean separation between build-time and runtime code

## Recommendations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problems identified seem accurate, but the recommendations lack context of a package containing user/recipe-only capabilities, which could solve some of the circular dependencies as well

@@ -0,0 +1,151 @@
# Singleton Patterns Report
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining singletons here look mostly fine

- **Line 20**: `const storePath = ...`
- **Line 21**: `const STORE = new URL(...)`
- **Lines 22-29**: Module-level provider initialization
- **Issue**: Complex module-level initialization that runs on import
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memoization in a deno service, this is fine

```typescript
type CallbackResult =
| { success: true; message?: string; details?: Record<string, unknown> }
| { success: false; error: string; details?: Record<string, unknown> };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good example of multi-property, exclusive states in variants

specific error cases. Callers can't distinguish between "no data" and "error
occurred".

### `packages/ui/src/components/common-form.ts`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to ignore ui in these agent flows; mostly older code that we're using a small subset of, and unique compared to the rest of the codebase (lit elements)

Comment on lines 93 to 98
### packages/js-runtime/interface.ts
- **Lines 70-79**: `isJsModule` function uses 'unknown' but could use a more specific base type
- **Lines 97-104**: `isSourceMap` function uses 'unknown' but could use a more specific base type

### packages/memory/traverse.ts
- **Lines 371-389**: Multiple functions use 'unknown' parameters that could be more specific
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, do we not want unknown in predicate functions?

// Or better: export a factory function
export function createClock(): Clock { ... }
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting the Clock class instead, and having packages/memory/settings.ts construct it directly makes this happy, but settings has this singleton pattern as well.
This could be moved into transaction.ts where it's used, so it doesn't feel like a singleton. Clock and settings are used to set default parameters for the Transaction.create, so there's not actually an issue overriding them if needed.

@seefeldb seefeldb merged commit ca87798 into main Jun 10, 2025
2 checks passed
@seefeldb seefeldb deleted the claude-improvements branch June 10, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants