threadlines
v0.6.0
Published
Threadlines CLI - AI-powered linter based on your natural language documentation
Maintainers
Readme
Threadline
Threadline CLI - AI-powered linter based on your natural language documentation.
Why Threadline?
Getting teams to consistently follow coding patterns and quality standards is hard. Really hard.
- Documentation → Nobody reads it. Or it's outdated before you finish writing it.
- Linting → Catches syntax errors, but misses nuanced stuff.
- AI Code Reviewers → Powerful, but you can't trust them. Did they actually check what you care about? Can you customize them with your team's specific rules?
Threadline solves this by running separate, parallel, highly focused AI-powered reviews - each focused on a single, specific concern or pattern: the stuff that takes engineers months to internalise - and they keep forgetting. Your coding patterns live in your repository as 'Threadline' markdown files, version-controlled and always in sync with your codebase. Each threadline is its own AI agent, ensuring focused attention on what matters to your team.
What Makes Threadline Different?
Focused Reviews - Instead of one AI agent checking everything, Threadline runs multiple specialized AI reviewers in parallel. Each threadline focuses on one thing and does it well.
Documentation That Lives With Your Code - Your coding standards live in your repo, in a
/threadlinesfolder. They're version-controlled, reviewable, and always in sync with your codebase.Fully Auditable - Every AI review decision is logged and traceable. You can see exactly what was checked, why it passed or failed, and have confidence in the results.
Fast & Parallel - Multiple threadlines run simultaneously, so you get comprehensive feedback in seconds, not minutes.
Installation
Option 1: Use with npx (No Installation)
npx threadlines checkFor non-interactive environments (CI/CD, AI assistants like Cursor):
npx --yes threadlines checkThe --yes flag auto-confirms package installation, preventing prompts that block automation.
Quick Start
1. Initialize Your First Threadline
npx threadlines initThis command:
- Creates a
/threadlinesdirectory in your project root - Generates
threadlines/example.mdwith a template threadline - Provides instructions for setting up your API key
2. Configure API Key
Create a .env.local file in your project root:
THREADLINE_API_KEY=your-api-key-hereImportant: Make sure .env.local is in your .gitignore file!
For CI/CD environments, set THREADLINE_API_KEY as an environment variable in your platform settings.
3. Edit Your Threadline
Edit threadlines/example.md with your coding standards, then rename it to something descriptive (e.g., error-handling.md).
4. Run Checks
npx threadlines checkBy default, analyzes your staged/unstaged git changes against all threadlines in the /threadlines directory.
Review Context Types:
local- Staged/unstaged changes (default for local development)commit- Specific commit (when using--commitflag)pr- Pull Request/Merge Request (auto-detected in CI)file- Single file (when using--fileflag)folder- Folder contents (when using--folderflag)files- Multiple files (when using--filesflag)
Common Use Cases:
Check latest commit locally:
threadlines check --commit HEADCheck a specific commit:
threadlines check --commit abc123defCheck entire file(s):
threadlines check --file src/api/users.ts
threadlines check --files src/api/users.ts src/api/posts.ts
threadlines check --folder src/apiDebug mode (verbose output):
threadlines check --debugShow all results (not just violations):
threadlines check --fullEnable debug logging:
threadlines check --debugOptions:
--commit <ref>- Review specific commit. Accepts commit SHA or git reference (e.g.,HEAD,HEAD~1,abc123). Sets review context tocommit.--file <path>- Review entire file (all lines as additions). Sets review context tofile.--folder <path>- Review all files in folder recursively. Sets review context tofolder.--files <paths...>- Review multiple specified files. Sets review context tofiles.--full- Show all results (compliant, attention, not_relevant). Default: only attention items--debug- Enable debug logging (verbose output for troubleshooting)
Note: Flags (--commit, --file, --folder, --files) are for local development only. In CI/CD environments, these flags are ignored and the CLI auto-detects the appropriate context.
Auto-detection in CI:
- Pull Request/Merge Request context → Reviews all changes in the PR/MR (review context:
pr) - Push to any branch → Reviews the commit being pushed (review context:
commit) - Local development → Reviews staged/unstaged changes (review context:
local)
Configuration
Environment Variables
| Variable | Purpose | Required |
|----------|---------|----------|
| THREADLINE_API_KEY | Authentication with Threadlines API | Yes |
| THREADLINE_ACCOUNT | Your Threadlines account email | Yes |
Both required variables can be set in a .env.local file (recommended for local development) or as environment variables (required for CI/CD).
Local Development:
Create a .env.local file in your project root:
THREADLINE_API_KEY=your-api-key-here
[email protected]CI/CD: Set these as environment variables in your platform:
- GitHub Actions: Settings → Secrets → Add variables
- GitLab CI: Settings → CI/CD → Variables
- Bitbucket Pipelines: Repository settings → Repository variables
- Vercel: Settings → Environment Variables
Get your credentials at: https://devthreadline.com/settings
Configuration File (.threadlinerc)
You can customize the API endpoint and other settings by creating a .threadlinerc file in your project root:
{
"mode": "online",
"api_url": "https://devthreadline.com",
"openai_model": "gpt-5.2",
"openai_service_tier": "Flex",
"diff_context_lines": 10
}The api_url field allows you to point to a custom server if needed. Default is https://devthreadline.com.
Threadline Files
Create a /threadlines folder in your repository. Each markdown file is a threadline defining a code quality standard.
Format
Each threadline file must have YAML frontmatter and a markdown body:
---
id: unique-id
version: 1.0.0
patterns:
- "**/api/**"
- "**/*.ts"
context_files:
- "path/to/context-file.ts"
---
# Your Threadline Title
Your guidelines and standards here...Required Fields
id: Unique identifier (e.g.,sql-queries,error-handling)version: Semantic version (e.g.,1.0.0)patterns: Array of glob patterns matching files to check (e.g.,["**/api/**", "**/*.ts"])- Body: Markdown content describing your standards
Optional Fields
context_files: Array of file paths that provide context (always included, even if unchanged)
Example: Feature Flagging Standards
---
id: feature-flags
version: 1.0.0
patterns:
- "**/features/**"
- "**/components/**"
- "**/*.tsx"
- "**/*.ts"
context_files:
- "config/feature-flags.ts"
---
# Feature Flag Standards
All feature flag usage must:
- Check flags using the centralized `isFeatureEnabled()` function from `config/feature-flags.ts`
- Never hardcode feature flag names as strings (use constants from the config)
- Include proper cleanup: remove feature flag checks when features are fully rolled out
- Document rollout plan in PR description (target percentage, timeline)
- Use feature flags for gradual rollouts, not as permanent configuration
**Violations:**
- ❌ `if (process.env.NEW_FEATURE === 'true')` (hardcoded, not using registry)
- ❌ `if (flags['new-feature'])` (string literal instead of constant)
- ✅ `if (isFeatureEnabled(FeatureFlags.NEW_DASHBOARD))` (using centralized function)The config/feature-flags.ts file will always be included as context, ensuring the AI reviewer can verify that:
- Feature flag names match the registry
- The correct flag checking function is used
- Flags are properly typed and documented
