kcl-azure-pipelines
CLAUDE.md1 starsChanged 8 months agoMITView on GitHub
This document describes the coding conventions and patterns used in this repository for implementing Azure Pipelines schemas in KCL. Don't use relative imports: For file-level documentation (especially for types): Pattern: type Name = SimpleForm | ComplexForm | ... Don't create separate schemas for identical structures:
We split this CLAUDE.md into the rules it gives an agent
15 rules. About 0 are common, 10 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Always use absolute imports starting with ap.:
- Distinctive: line 16
Don't: use relative imports:
- Distinctive: line 23
Import the module and use qualified references:
- Distinctive: line 47
Every schema must include a docstring with Azure DevOps documentation link.
- Distinctive: line 68
Use type unions for flexible schemas that accept multiple forms:
- Very specific: line 79
Use CamelCase for schema names: Pipeline, PoolFull, TriggerFull
- Very specific: line 82
Use ? for optional fields (most fields are optional in Azure Pipelines)
- Distinctive: line 83
Use camelCase for field names to match Azure Pipelines YAML syntax
- Distinctive: line 93
If multiple schemas share the same structure, consolidate them into a single reusable schema:
- Distinctive: line 108
Don't: create separate schemas for identical structures:
- Distinctive: line 123
Use string literals for enums:
- Very specific: line 170
Use check blocks for validation rules:
- Very specific: line 184
Prefer strongly-typed unions over any:
- Distinctive: line 221
Test that examples validate correctly:
- Distinctive: line 253
Always include links to official Azure DevOps documentation:
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
KCL Azure Pipelines - Coding Style Guide
This document describes the coding conventions and patterns used in this repository for implementing Azure Pipelines schemas in KCL.
Import Conventions
1. Use Absolute Imports
Always use absolute imports starting with ap.:
import ap.steps
import ap.pool
import ap.jobs.deploymentDon't use relative imports:
import .steps # Bad
import ..pool # Bad2. Import Modules, Not Individual Types
Import the module and use qualified references:
import ap.steps
schema Hook:
steps?: [steps.Step] # Use module.Type
pool?: pool.Pool3. Package-Level Type Availability
Types defined in a package are available to sibling files without explicit imports:
# In ap/jobs/deployment/strategy.k
# Hook and OnSuccessOrFailureHook from hooks.k are available
schema RunOnceDetails:
preDeploy?: Hook # No import needed
on?: OnSuccessOrFailureHook # No import neededSchema Conventions
1. Documentation
Every schema must include a docstring with Azure DevOps documentation link. Do not include description of the schema's purpose, unless it's really necessary.
schema Pipeline:
"""
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/pipeline
"""
name?: str
# ... fieldsFor file-level documentation (especially for types):
"""
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps
"""
type Step = Task | Script | Bash | ...2. Type Unions
Use type unions for flexible schemas that accept multiple forms:
type Pool = str | PoolFull
type Trigger = "none" | [str] | TriggerFull
type Variables = {str: str} | [Name | Group | tpl.Template]Pattern: type Name = SimpleForm | ComplexForm | ...
3. Schema Naming
- Use CamelCase for schema names:
Pipeline,PoolFull,TriggerFull
4. Field Conventions
- Use
?for optional fields (most fields are optional in Azure Pipelines) - Use camelCase for field names to match Azure Pipelines YAML syntax
schema Task:
task: str # Required
inputs?: {str: str} # Optional
displayName?: str # Optional5. Consolidate Duplicate Schemas
If multiple schemas share the same structure, consolidate them into a single reusable schema:
# Good: Single reusable schema
schema Hook:
steps?: [steps.Step]
pool?: pool.Pool
# Used by multiple lifecycle hooks
schema RunOnceDetails:
preDeploy?: Hook
deploy?: Hook
routeTraffic?: HookDon't create separate schemas for identical structures:
# Bad: Duplicate schemas
schema PreDeployHook:
steps?: [steps.Step]
pool?: pool.Pool
schema DeployHook:
steps?: [steps.Step]
pool?: pool.PoolType Patterns
1. String Enumerations
Use string literals for enums:
schema TargetFull:
commands?: "any" | "restricted"File Organization
1. Import Order
- External/package imports
- Blank line
- Module documentation (if applicable)
- Type definitions
- Schema definitions
import ap.steps
import ap.pool
"""
Module documentation
"""
type Strategy = RunOnce | Rolling | Canary
schema RunOnce:
# ...2. One Concept Per File
Each file should focus on a single concept:
pool.k- Pool configurationstrigger.k- Trigger configurationssteps.k- Step type union- Individual step files:
task.k,script.k,bash.k, etc.
3. Nested Schemas
For complex schemas with nested components, create subdirectories:
ap/jobs/job/- Job-related schemasap/jobs/deployment/- Deployment-related schemasap/steps/- Step type implementationsap/resources/- Resource type implementations
Validation and Constraints
1. Schema Checks
Use check blocks for validation rules:
schema Pipeline:
stages?: [Stage]
jobs?: [Job]
steps?: [Step]
extends?: Extends
check:
stages or extends or jobs or steps, "Pipeline must specify one of: stages, extends, jobs, or steps"2. Type Safety
Prefer strongly-typed unions over any:
# ✅ Good: Type-safe union
type Pool = str | PoolFull
# ❌ Bad: Using any
pool?: anyExamples and Testing
1. Provide Examples
Include an example.k file demonstrating usage:
import ap
myPipeline: ap.Pipeline {
name = "CI-Build"
trigger = ap.TriggerFull {
branches = {
include = ["main"]
}
}
stages = [
ap.Stage {
stage = "Build"
jobs = [
# ...
]
}
]
}2. Validation
Test that examples validate correctly:
kcl run example.k -S myPipelineAzure Pipelines Mapping
1. Mirror YAML Structure
KCL schemas should mirror the YAML structure from Azure Pipelines:
# Azure Pipelines YAML
trigger:
branches:
include:
- main# KCL Schema
schema TriggerFull:
branches?: Branches
type Branches = [str] | IncludeExcludeFilters
schema IncludeExcludeFilters:
include?: [str]
exclude?: [str]2. Maintain Azure Documentation Links
Always include links to official Azure DevOps documentation:
schema Task:
"""
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-task
"""Summary
Key Principles:
- ✅ Use absolute imports (
ap.module) - ✅ Import modules, not individual types
- ✅ Document with Azure DevOps links
- ✅ Use type unions for flexibility
- ✅ Consolidate duplicate schemas
- ✅ Mirror Azure Pipelines YAML structure
- ✅ Provide type safety over
any - ✅ One concept per file
- ✅ Include validation examples
In this repositoryOne other file it gives its agents.
- kclSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

