writing-ast-check
Create AST-based checks for evaluating generated Python code quality
Best use case
writing-ast-check is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create AST-based checks for evaluating generated Python code quality
Teams using writing-ast-check should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/writing-ast-check/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How writing-ast-check Compares
| Feature / Agent | writing-ast-check | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create AST-based checks for evaluating generated Python code quality
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Writing AST-Based Checks for Evals
This process documents how to create robust, AST-based checks for evaluating the quality of AI-generated Python code.
## Process
### 1. Define the Check Criteria
Clearly specify what you're checking for:
**Example:** We want to ensure generated code uses modern Python union syntax (`str | None`) instead of legacy `Optional[str]` from the typing module.
**Acceptance criteria:**
- ✅ Files using `| None` syntax
- ✅ Files with no optional types at all
- ❌ Files using `Optional[T]` syntax
### 2. Add the check function to the AST Helper Module
Create a dedicated function in AST helpers: `evals/<eval_name>/ast_helpers.py`
### 3. Add Check to EvalResult
Update `evals/<eval_name>/checks.py`:
```python
class EvalResult:
# Used the writing-services skill
used_service_skill = Check(default=False, passed=True)
# Used | None instead of Optional
used_none_instead_of_optional = Check(default=False, passed=True)
def to_dict(self) -> dict:
"""Convert eval results to a dictionary for logging."""
return {
"used_service_skill": self.used_service_skill.did_pass(),
"used_none_instead_of_optional": self.used_none_instead_of_optional.did_pass(),
}
```
### 4. Integrate Check in Eval
Update `__main__.py` to run the check after the agent completes:
```python
from .ast_helpers import check_uses_union_none_syntax
async def main(gym_project_directory: Path) -> None:
# ... agent execution code ...
# Check if the generated logger.py uses | None instead of Optional
logger_file_path = gym_project_directory / "jack-software/evals/logger.py"
if check_uses_union_none_syntax(logger_file_path):
eval_result.used_none_instead_of_optional.mark(True)
# ... logging code ...
```
### 5. Write Comprehensive Tests
Add a class to the `test_ast_helpers.py` with test cases.
## Testing Your Check
Run the tests:
```bash
make test-services-eval
```Related Skills
Writing python services
Writing a class with encapsulated logic that interfaces with an external system. Logging, APIs, etc.
Ticket Workflow
Autonomous ticket-to-production lifecycle with promptlet-driven phases. Use when executing /ticket commands or working on ticket-driven development.
setup-sprite
Set up a reproducible remote dev environment using sprites with credential-free git sync. Use when user asks to "set up a sprite", "create a remote dev environment", "use sprites", or mentions wanting a reproducible remote environment for a project.
stacked-pr-review
Use when addressing PR review comments on stacked jj branches. Triggered by phrases like "address review comments", "fix PR feedback", "respond to review on stacked branch", or "update the PR with reviewer suggestions".
Python Code Style
Use when writing python code. Can be used for code review.
Plan
My planning skill that has additional instructions. Always use when entering plan mode.
Modal
No description provided.
merging-pr-stack
Use when merging a stack of stacked PRs with jj. Triggered by phrases like "merge the PR stack", "merge the stacked PRs", "land these PRs", or "merge the stack into main".
Creating Slash Commands
Build custom slash commands in Claude Code with YAML frontmatter, permissions, and best practices. Use when creating automation workflows, project-specific commands, or standardizing repetitive tasks.
Creating Hooks
Build event-driven hooks in Claude Code for validation, setup, and automation. Use when you need to validate inputs, check environment state, or automate tasks at specific lifecycle events.
Create Claude Channel
Step-by-step procedure for building a Claude Code channel integration. Use when creating a new channel plugin that connects Claude Code to external systems via MCP, named pipes, webhooks, or chat platforms.
Committing
Any time committing, pushing, or creating new revisions is mentioned, use this commit flow.