Skip to content

feat: Learning & Adaptation - Pattern Memory and Codebase Conventions #233

Closed

Description

@admarble

Summary

Add lightweight convention awareness so sequant-generated code better matches existing codebase style.

Scope: Simple, deterministic analysis - not AI "learning".


Proposed Features

Convention Hints (Single Feature)

During sequant init, scan codebase for observable patterns and store hints:

// .sequant/conventions.json
{
  "detected": {
    "testFilePattern": "*.test.ts",      // from existing test files
    "componentDir": "src/components/",   // from package structure  
    "exportStyle": "named",              // named vs default exports
    "asyncPattern": "async/await"        // vs .then() chains
  },
  "manual": {
    // User can add/override
    "prTitleFormat": "feat(#N): description"
  }
}

How it works:

  1. sequant init runs detection, saves to .sequant/conventions.json
  2. /exec reads conventions before generating code
  3. Conventions included in skill context: "This codebase uses named exports"
  4. User can edit file to correct/add conventions

Detection methods (deterministic, not AI):

  • Test file pattern: glob for *.test.*, *.spec.*, __tests__/
  • Export style: grep for export default vs export {
  • Component structure: check for components/, pages/, etc.

What This Is NOT


Acceptance Criteria

  • sequant init detects 5+ conventions from codebase
  • Conventions stored in .sequant/conventions.json
  • /exec skill template references conventions
  • sequant conventions command shows current settings
  • User can manually edit conventions file

Value

Reduces "doesn't match our style" feedback by giving Claude observable context about codebase patterns. Simple, transparent, user-controllable.


Out of Scope (Future Consideration)

  • Learning from PR feedback
  • Automatic convention updates
  • Cross-project convention sharing

Revised from original feature planning discussion - scoped down to deterministic detection only

Activity

  1. added
    enhancement
    on Feb 2, 2026
  2. added
    auto-ready
    on Feb 16, 2026
  3. admarble commented on Feb 26, 2026

    @admarble
    ContributorAuthor

    Spec Plan: #233 — Codebase Conventions Detection

    AC Checklist with Verification

    AC Description Verification Method
    AC-1 sequant init detects 5+ conventions from codebase Unit test: detector returns ≥5 items for sequant's own codebase Unit Test
    AC-2 Conventions stored in .sequant/conventions.json Unit test: file created with correct schema Unit Test
    AC-3 /exec skill template references conventions Manual review: exec SKILL.md loads conventions.json Manual Review
    AC-4 sequant conventions command shows current settings Integration test: CLI command outputs detected + manual conventions Integration Test
    AC-5 User can manually edit conventions file Manual review: manual section persists across re-detection Manual Review

    Non-Goals

    Implementation Plan

    1. Create src/lib/conventions-detector.ts — Deterministic detection module

      • Detect test file pattern: glob *.test.*, *.spec.*, __tests__/
      • Detect export style: grep export default vs export { in src/
      • Detect async pattern: grep async/await vs .then(
      • Detect component structure: check for components/, pages/, app/
      • Detect package manager from lockfiles
      • Detect TypeScript strictness from tsconfig
      • Detect naming conventions from file patterns
      • Interface: detectConventions(projectRoot): ConventionsResult
    2. Create src/lib/conventions-detector.test.ts — Unit tests

      • Test each detector individually with mock file structures
      • Test full detection against sequant's own codebase (≥5 items)
      • Test merge of detected + manual conventions
    3. Integrate into src/commands/init.ts — Run detection during init

      • After createDefaultSettings(), call detectAndSaveConventions()
      • Save to .sequant/conventions.json with detected and manual sections
      • Preserve existing manual section on re-init
    4. Create src/commands/conventions.ts — New CLI command

      • sequant conventions — display all detected + manual conventions
      • sequant conventions --detect — re-run detection and update
      • sequant conventions --reset — clear detected, keep manual
    5. Register in bin/cli.ts — Wire up conventions command

      • Add .command("conventions") with options
    6. Update exec skill template — Reference conventions in context

      • .claude/skills/exec/SKILL.md — add step to read conventions.json
      • templates/skills/exec/SKILL.md — mirror the change

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: disabled
    Skip test: Yes (CLI/library feature, no UI)

  4. added
    ai-in-progress
    on Feb 27, 2026
  5. added a commit that references this issue on Feb 27, 2026
  6. admarble commented on Mar 13, 2026

    @admarble
    ContributorAuthor

    Solve Analysis

    Recommended Phases: spec → testgen → exec → qa
    Skip Spec: No (enhancement needs spec to verify remaining work vs active worktree)
    Browser Testing: No (CLI/config feature, no UI)
    Quality Loop: Yes (multi-component feature: detector, CLI, init, skill templates)

    Reasoning

    • Enhancement with testable ACs → includes /testgen
    • Active worktree exists with 8 changed files — resolve before re-running
    • Convention detection spans multiple components (detector, CLI wiring, init, exec skill)
    • Quality loop helps catch integration issues across components

    Flags

    Flag Value Reasoning
    -q (quality-loop) ✓ Multi-component feature benefits from retry
    --chain ✗ Independent issue, no dependencies
    --qa-gate ✗ No chain mode
    --base ✗ Branching from main
    --testgen ✓ Testable ACs (detect 5+ conventions, CLI command, init integration)

    📝 Generated by /solve

  7. added 2 commits that reference this issue on Mar 13, 2026
  8. admarble commented on Mar 13, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #233
    Status: READY_FOR_MERGE
    PR: #362

    Summary

    • AC: 5/5 met
    • Tests: 1532/1532 passed (21 conventions-specific)
    • Build: Clean
    • Smoke tests: All passed (help, detect, show, reset)

    AC Coverage

    AC Status Notes
    AC-1 ✅ MET 8 conventions detected (5+ required)
    AC-2 ✅ MET .sequant/conventions.json with detected/manual/detectedAt
    AC-3 ✅ MET Both exec SKILL.md files reference conventions
    AC-4 ✅ MET sequant conventions with --detect and --reset
    AC-5 ✅ MET Manual section preserved on re-detect and reset

    Iterations

    • Spec: 1 (prior session)
    • Exec: 1 (prior session)
    • QA: 1
    • Test: Skipped (CLI feature)

    Self-Evaluation

    • Verified working: Yes — all CLI commands executed and verified
    • Test efficacy: High — 21 tests cover individual detectors, persistence, merging
    • Likely failure mode: Unusual project structures may produce unexpected values (non-blocking, informational)
    • Verdict confidence: High

    Fixes Applied During QA

    1. Rebased from 22 commits behind main
    2. Resolved merge conflicts in CHANGELOG.md and templates/skills/exec/SKILL.md
    3. Removed stale conflict marker in templates/skills/exec/SKILL.md
    4. Moved CHANGELOG entry from [1.18.0] to [Unreleased]

    Ready for human review and merge.

  9. added 3 commits that reference this issue on Mar 13, 2026
  10. admarble commented on Mar 13, 2026

    @admarble
    ContributorAuthor

    Documentation Generated

    File: docs/features/codebase-conventions.md

    Sections Included:

    • Quick Start — what it does and why
    • How It Works — detected conventions table (9 conventions)
    • Usage — init, view, re-detect, reset commands
    • Manual Overrides — editing conventions.json directly
    • How Skills Use Conventions — /exec integration
    • Options & Settings — CLI flags
    • Troubleshooting — no detection, wrong values, not affecting output

    Next Steps:

    1. Review generated documentation for accuracy
    2. Merge to deploy documentation

    Ready to merge!

  11. added 2 commits that reference this issue on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-in-progressauto-readyenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions