patterner is a tool to analyze and present best practices (patterns) for Tailor Platform applications.
Patterner is a command-line tool designed to help developers identify patterns and best practices within Tailor Platform workspaces. It provides linting capabilities and metrics collection to ensure your Tailor Platform application follows recommended patterns.
- Lint - Analyze resources in your workspace and identify potential issues or deviations from best practices
- Metrics - Collect and display metrics about resources in your workspace
- Coverage - Analyze and display pipeline resolver step coverage to monitor execution quality
- Configuration - Flexible configuration system with YAML-based settings
go install github.com/tailor-platform/patterner@latestCreate a .patterner.yml configuration file in your project:
patterner initYou can also specify a workspace ID during initialization:
patterner init -w YOUR_WORKSPACE_IDCheck your workspace resources against configured patterns:
patterner lintOr specify a workspace ID directly:
patterner lint -w YOUR_WORKSPACE_IDNote: The lint command requires a Tailor Platform access token. Set the TAILOR_TOKEN environment variable:
# Using tailorctl to get access token
env TAILOR_TOKEN=$(tailorctl auth get accessToken) patterner lint
# Or set the token directly
export TAILOR_TOKEN=your_access_token
patterner lintDisplay metrics about resources in your workspace:
patterner metricsNote: The metrics command requires a Tailor Platform access token. Set the TAILOR_TOKEN environment variable:
# Using tailorctl to get access token
env TAILOR_TOKEN=$(tailorctl auth get accessToken) patterner metrics
# Or set the token directly
export TAILOR_TOKEN=your_access_token
patterner metricsThe metrics command displays metrics in a table format. Use the --out-octocov-path option to output metrics in octocov custom metrics format with configurable acceptable thresholds.
--since, -s(default: "30min") - Analyze execution results since the specified time period--out-octocov-path- Output metrics in octocov custom metrics format to the specified file--with-lint-warnings(default: false) - Display lint warnings along with metrics output--with-coverage-full-report(default: false) - Display detailed pipeline resolver step coverage along with metrics output
--with-coverage-full-report vs --with-lint-warnings:
--with-coverage-full-report: Displays detailed pipeline resolver step coverage information for execution quality monitoring- Shows coverage percentage and executed steps count for each resolver
- Format:
Coverage Rate% [Executed Steps/Total Steps] Resolver Name
--with-lint-warnings: Displays detailed lint warnings list for code quality monitoring- Shows specific lint issues and recommendations for code improvements
Both options can be used together to provide comprehensive analysis combining execution quality and code quality insights.
# Basic metrics (last 30 minutes)
patterner metrics
# Metrics for the past hour
patterner metrics --since 1hour
# Display metrics with lint warnings
patterner metrics --with-lint-warnings
# Display metrics with coverage details
patterner metrics --with-coverage-full-report
# Display metrics with both coverage and lint warnings
patterner metrics --with-coverage-full-report --with-lint-warnings
# Output metrics to octocov custom metrics file
patterner metrics --out-octocov-path metrics.json
# Comprehensive analysis with all options
patterner metrics --since 24hours --out-octocov-path metrics.json --with-coverage-full-report --with-lint-warningsWhen using the --out-octocov-path option, patterner outputs metrics in octocov custom metrics format. This format includes:
- Metrics data - All collected metrics with their values and units
- Acceptable thresholds - Configurable conditions that define acceptable metric values
- Configured via
metrics.octocov.acceptablesin.patterner.yml - Used by octocov to evaluate whether metrics meet quality standards
- Configured via
Example octocov output:
[
{
"key": "patterner-metrics",
"name": "Patterner Metrics",
"metrics": [
{
"key": "pipeline_resolver_step_coverage_percentage",
"name": "Pipeline Resolver Step Coverage",
"value": 75.0,
"unit": "%"
},
{
"key": "lint_warnings_total",
"name": "Lint Warnings Total",
"value": 3,
"unit": "count"
}
],
"acceptables": [
"current.pipeline_resolver_step_coverage_percentage >= 80",
"diff.lint_warnings_total <= 0"
]
}
]Display pipeline resolver step coverage for your workspace:
patterner coverageNote: The coverage command requires a Tailor Platform access token. Set the TAILOR_TOKEN environment variable:
# Using tailorctl to get access token
env TAILOR_TOKEN=$(tailorctl auth get accessToken) patterner coverage
# Or set the token directly
export TAILOR_TOKEN=your_access_token
patterner coverageThe coverage command analyzes pipeline resolver step execution and displays coverage percentages to help monitor pipeline execution quality.
--since, -s(default: "30min") - Analyze execution results since the specified time period--full-report, -f(default: false) - Display detailed coverage report including per-resolver breakdown--workspace-id- Target workspace ID to analyze
# Basic coverage analysis (last 30 minutes)
patterner coverage
# Coverage for the past hour
patterner coverage --since 1hour
# Detailed coverage report
patterner coverage --full-report
# Detailed report for the past 24 hours
patterner coverage --since 24hours --full-reportStandard output:
Pipeline Resolver Step Coverage 75.0% [3/4]
Detailed report: Shows coverage breakdown per resolver in addition to overall coverage statistics.
The following metrics are collected and displayed:
Pipeline Metrics:
pipelines_total- Total number of pipelines (Unit: count)pipeline_resolvers_total- Total number of pipeline resolvers (Unit: count)pipeline_resolver_steps_total- Total number of pipeline resolver steps (Unit: count)pipeline_resolver_graphql_steps_total- Total number of Pipeline resolver GraphQL steps (Unit: count)pipeline_resolver_function_steps_total- Total number of Pipeline resolver Function steps (Unit: count)pipeline_resolver_execution_paths_total- Total number of pipeline resolver execution paths (Unit: count)- Calculation: Based on the number of steps and tests in each resolver (steps * 2^tests)
- Includes overflow detection: Reports error if negative values are encountered
- Used to understand the total number of execution paths based on testable step combinations
TailorDB Metrics:
tailordbs_total- Total number of TailorDBs (Unit: count)tailordb_types_total- Total number of TailorDB types (Unit: count)tailordb_type_fields_total- Total number of TailorDB type fields (Unit: count)
StateFlow Metrics:
stateflows_total- Total number of StateFlows (Unit: count)
Coverage Metrics:
pipeline_resolver_step_coverage_percentage- Pipeline resolver step coverage (Unit: %)- Calculation: (covered steps / total steps) * 100
- Provides percentage representation of pipeline resolver step execution coverage
Lint Metrics:
lint_warnings_total- Total number of lint warnings (Unit: count)- Calculation: Number of warnings returned from the lint function
- Helps monitor code quality and adherence to best practices
Patterner uses a .patterner.yml file for configuration. The configuration includes various lint rules for different Tailor Platform components:
workspaceID: xxxxxxxXXxxxxxxxxxxxxx
lint:
acceptable: 5
rules:
pipeline:
deprecatedFeature:
enabled: true
allowCELScript: false
allowDraft: false
allowStateFlow: false
insecureAuthorization:
enabled: false
stepCount:
enabled: true
max: 30
multipleMutations:
enabled: true
queryBeforeMutation:
enabled: true
tailordb:
deprecatedFeature:
enabled: true
allowDraft: false
allowCELHooks: false
stateflow:
deprecatedFeature:
enabled: true
metrics:
octocov:
acceptables:
- "current.pipeline_resolver_step_coverage_percentage >= 80"
- "diff.lint_warnings_total <= 0"- octocov - Configuration for octocov custom metrics format output
acceptables- List of acceptable threshold conditions for metrics- Define minimum acceptable values for metrics in octocov format
- Used when outputting metrics with
--out-octocov-pathoption - Format:
"metric_name operator value"(e.g.,"coverage_percentage >= 80") - Supports various metrics including coverage percentages and lint warning counts
- Example:
["pipeline_resolver_step_coverage_percentage >= 80", "lint_warnings_total <= 5"]
- acceptable - Set the maximum number of acceptable lint warnings (default: 0)
- When the number of warnings exceeds this value, the lint command will exit with a failure status
- This allows you to gradually improve code quality by setting a reasonable warning threshold
- Example:
acceptable: 5allows up to 5 warnings before failing
- deprecatedFeature - Identify deprecated features and promote modern alternatives
enabled(default: true) - Enable/disable deprecated feature detectionallowCELScript(default: false) - Allow CEL script usage in pipelinesallowDraft(default: false) - Allow draft resources in pipeline configurationsallowStateFlow(default: false) - Allow StateFlow resources in pipeline configurations- Detects deprecated patterns and recommends modern Pipeline alternatives
- Enabled by default to promote migration away from deprecated features
- insecureAuthorization - Detect insecure authorization patterns
- stepCount - Ensure pipeline steps don't exceed maximum count
- multipleMutations - Identify multiple mutations in a single operation
- queryBeforeMutation - Check for queries before mutations
- deprecatedFeature - Identify deprecated TailorDB features and promote modern alternatives
enabled(default: true) - Enable/disable deprecated feature detectionallowDraft(default: false) - Allow draft resources in TailorDB configurationsallowCELHooks(default: false) - Allow CEL hook usage in TailorDB configurations- Detects deprecated patterns and recommends modern TailorDB alternatives
- Enabled by default to promote migration away from deprecated features
- deprecatedFeature - Identify deprecated StateFlow features and promote modern alternatives
enabled(default: true) - Enable/disable deprecated feature detection- Detects deprecated StateFlow patterns and recommends modern alternatives
- Enabled by default to promote migration away from deprecated features
-w, --workspace-id string- Workspace ID (can be set in configuration file)
patterner init- Initialize configuration filepatterner lint- Lint workspace resourcespatterner metrics- Display workspace metrics--since, -s(default: "30min") - Analyze execution results since the specified time period--out-octocov-path- Output metrics in octocov custom metrics format to the specified file--with-lint-warnings- Display lint warnings along with metrics output--with-coverage-full-report- Display detailed pipeline resolver step coverage along with metrics output
patterner coverage- Display pipeline resolver step coverage
Copyright © 2025 Tailor Inc.