Project-Level Skills for AI Coding Platforms: A Practical Guide to A-Share Quantitative Strategy Development
This article explains how to turn quantitative strategy generation into a project-level Skill for AI coding platforms, addressing the common problem where a model writes plausible code that fails because it does not understand project constraints. It covers the design principles of project isolation, centralized rules, and data-schema-first generation, along with concrete examples of framework rules, a data dictionary, and a recommended generation workflow. Readers will learn how to reduce rework, improve first-pass success, and keep rules and documentation under version control.
1. Problem Background: Why Quantitative Strategies Need Project-Level Skills
When using AI coding tools to develop A-share quantitative strategies, the common pain point is not that the model cannot write code. It is that the model does not understand the constraints of the current project. The same requirement can produce completely different field names, different backtest API call patterns, or even unauthorized changes to existing framework scripts in different projects. The generated code may look reasonable but still fail to run.
The core goal of turning strategy generation into a project-level Skill is to make three types of implicit knowledge explicit:
- Project boundaries: Configuration serves only the current project and does not affect other projects.
- Code constraints: Stock selection and factor code must follow unified framework rules.
- Data contracts: Fields and types in the underlying data structures must be used accurately.
2. Design Principles: From Prompt Migration to Engineering Constraints
Many practices stay at the prompt level, where results are unstable. A more reliable approach is to treat the Skill as a combination of a project specification, a code standard, and a data dictionary.
2.1 Package the Configuration as a Whole for Project Isolation
Package all Skill-related files together. After extraction, place them in the project directory to activate them. The benefits are:
- Configuration travels with the project, and versions are traceable.
- Team members do not overwrite each other’s settings.
- Global configuration side effects are avoided.
Example directory structure:
project/.skill/skill.configrules/stock_framework.rulesdocs/data_schema.mdframework/stock_runner.pystrategies/
2.2 Centralize Rules to Prevent Failures Caused by Scattering
Rules such as “do not modify framework scripts,” “factor function signatures are fixed,” and “output fields are fixed” are easier to maintain in one place than scattered across multiple prompt fragments. The more centralized the rules, the less likely the model is to follow them selectively.
2.3 Prioritize the Data Dictionary to Reduce Field Guessing
One of the most common model errors is using the wrong field name, such as replacing a Chinese trading-date field with an English column name. Providing documentation for the underlying data structures lets the model read the contract before writing code, which significantly reduces rework.
3. Key Implementation: How to Write the Three File Types Effectively
3.1 Stock Selection Framework Code Rules (rules)
Rules should be written as verifiable items rather than vague suggestions. For example:
- Do not modify any file under framework/- The strategy entry function name must be run(ctx)- Factor output must include: trading date, security code, factor value- All date fields must come from the data dictionary definitions- If a field is missing, raise an error and stop generation; do not guess
This style encourages the model to follow a “validate first, then code” path during generation.
3.2 Underlying Data Structure Documentation (data_schema)
The document should include at least the field name, type, meaning, example, and null-value policy. Example:
| Field | Type | Meaning | Example | Null Policy ||---|---|---|---|---|| Trading Date | date | Trading day | 2025-01-02 | Must not be null || Security Code | string | Instrument code | 000001.SZ | Must not be null || Closing Price | float | Price before adjustment | 12.34 | Null allowed; filter required |
3.3 Generation Workflow Constraints (Optional but Recommended)
Fix the workflow in the Skill: read the schema → select the framework API → generate factors → self-check fields → output runnable code. A defined workflow noticeably improves the first-pass success rate.
4. Practical Benefits and Implementation Advice
- Lower migration cost: Configuration travels with the project, so replacing the underlying model or tool does not affect project assets.
- Higher first-pass usability: Data contracts and code rules constrain the output together.
- Easier team collaboration: Rules and documentation enter version control, providing a basis for review.
Implementation advice: Start with a minimal rule set to get one stock-selection factor working, then gradually add rules for risk control, position adjustment, backtest output, and more. Add only one type of constraint at a time to make it easier to locate the source of problems.
