用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/shader-slang/slang-skills --skill slang-code-writer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | slang-code-writer |
| license | MIT |
| description | Implement changes in the Slang compiler. Edit code, write tests, format, commit. |
| provides | ["code.read","code.edit","test.gen"] |
| allowed-tools | Bash, Read, Write, Edit, Grep, Glob |
Drawn from shader-slang/slang repository guidance: AGENTS.md, CLAUDE.md,
CONTRIBUTING.md, and .github/copilot-instructions.md. When working inside the Slang
repository, also consult any repository-local skills under .claude/skills/ if the user's workflow
matches one of those skills.
Slang is a shading-language compiler and runtime implemented primarily in C++20 and built with CMake.
Key directories:
source/: core implementation, including source/slang/, source/core/,
source/compiler-core/, and tools like source/slangc/.include/: public API headers.prelude/ and source/standard-modules/: standard/prelude headers.tests/: test suites grouped by feature or target.tools/: test infrastructure and developer tools.docs/: documentation.examples/: runnable samples.cmake/: CMake helpers.external/: vendored dependencies.When working in this repository from WSL on Windows, use Windows-native developer tools by default unless the user explicitly asks for the WSL/Linux version.
git.exe, not bare git. These worktrees use Windows path conventions; WSL Git can corrupt
or misinterpret worktree state, and Windows Git has much better file I/O performance on this
checkout.cmake.exe, not bare cmake, so Visual Studio
presets and toolchains are found correctly.gh.exe instead of bare gh when GitHub CLI commands need to share the same Windows-native
Git and credential context.wslpath -w "$path". Convert
paths printed by Windows tools back before using them in shell commands, for example
wslpath -u "$win_path"..exe tool is unavailable, stop and report it instead of silently falling back to
the WSL/Linux tool.Slang build setup is platform-specific, especially under WSL. For compiler builds, use the
slang-build skill from shader-slang/slang-skills instead of following hard-coded generic CMake
commands. If the skill is unavailable because skills cannot be installed or network access is
limited, use docs/building.md as the fallback build reference.
Examples:
/slang-build build debug: build the Debug configuration./slang-build rebuild debug: discard the existing build directory and rebuild Debug./slang-build configure releasewithdebug: configure an optimized build with symbols./slang-build clean: rename and remove the existing build directory.Do not infer WSL build commands from generic Linux instructions. Follow the platform detection, host-tool selection, CMake preset choice, and clean-build steps defined by the skill.
After building, run tests from the repository root using the generated slang-test binary in the
directory for the selected configuration:
build/Debug/bin/slang-test: run the Debug test suite.build/RelWithDebInfo/bin/slang-test -use-test-server -server-count 8: run optimized tests with
symbols in parallel using test servers.build/Release/bin/slang-test -use-test-server -server-count 8: run Release tests in parallel
using test servers.On Windows-hosted builds, use the .exe suffix if that is the generated binary name.
Prefer direct paths over relative traversal in #include directives. The source/ directory is on
the compiler include path, exposed by the core CMake target, so cross-module headers are reachable
without ../:
// Preferred in new code
#include "core/slang-string.h"
#include "compiler-core/slang-source-loc.h"
// Existing code still uses the relative form; do not change it purely for style
#include "../core/slang-string.h"
#include "../compiler-core/slang-source-loc.h"
New files should use direct paths. Existing files need not be converted purely for style, but may be opportunistically updated when the file is already being substantially modified for other reasons.
Follow Slang coding conventions (docs/design/coding-conventions.md):
./extras/formatting.sh before committing to apply rules from .clang-format and
.editorconfig.<stdio.h> rather than <cstdio>.UpperCamelCase. Values: lowerCamelCase. Macros: SLANG_SCREAMING_SNAKE.g prefix. Static class members: s prefix. Constants: k prefix. Members: m_
prefix. Private member functions: _ prefix.p for pointers.in, out, or io prefix for pointer/reference direction.Comments should explain why code exists and should help reviewers understand the invariant being maintained.
Recurring review feedback distilled into rules:
slang-ast-type.h, slang-ir-util.h, and
the *-util.h files for existing helpers before adding one.Val representation of a value that already has one; multiple
spellings break equals, identity checks, and deduplication. Assert invariants at construction
sites.SLANG_RELEASE_ASSERT on out-of-contract input instead of silently returning a default.Scripts under extras/ and other repository shell scripts must run on bash 3.2, the version Apple
ships as /bin/bash on macOS.
Avoid bash 4+ features such as:
${var,,} or ${var^^} case conversion.declare -A).mapfile or readarray.local -n).Prefer portable equivalents, for example lowercase with tr '[:upper:]' '[:lower:]'. Validate
scripts with bash -n script.sh under the system bash.
Add tests near related coverage in tests/.
Slang tests use leading directives such as //TEST(smoke):SIMPLE:. Use //DISABLE_TEST only with a
clear reason. For targeted runs, pass a prefix, for example:
build/Debug/bin/slang-test tests/diagnostics/my-test
Unit tests live under tools/slang-unit-test and typically use SLANG_UNIT_TEST(name).
Common no-GPU patterns:
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type
// ... shader code ...
//CHECK: expected_output
//TEST:INTERPRET(filecheck=CHECK):
void main()
{
//CHECK: hello!
printf("hello!");
}
Diagnostic tests verify compiler errors:
//DIAGNOSTIC_TEST:SIMPLE(diag=CHECK):-target spirv
int foo = undefined;
//CHECK: E01234
//CHECK: ^^^^^^^^^ error
All files under include/ are public API. Changes must preserve binary and source compatibility for
callers compiled against older versions of the header.
Enums:
REMOVED_<Name> and keep the original integer value.
Never reuse a retired integer.COM-style interfaces:
SLANG_E_NOT_IMPLEMENTED and
keep the declaration in place.Follow the principled path, not the minimal-edit-distance path.
Before finalizing a non-trivial compiler change, review the diff for signs that the fix is
compensating for a bad AST/IR/Val/witness representation. Treat the following patterns as
high-risk until you can prove they are the right layer:
DeclRef, Val, Type, Witness, or IR shapes, such as
recursive helpers named like are...Equivalent, does...Match, or try...Match. First ask why
normal substitute, resolve, getCanonicalType, equals, or an existing canonical builder
does not already make the two values identical.try... function that exists only to make one failing test pass. Audit
every new helper, even small ones: if it redoes substitution, resolution, AST copy, generic
solving, lookup, or lowering, it is probably hiding the actual invariant break.Expr or
TypeExp from a Val, Type, DeclRef, or witness. The checked semantic field should usually
remain the source of truth.DeclRef subclasses, builtin magic type names, generic
argument indices, witness-table entry order, or nested-vs-flat specialization shape. Such code
needs a strong invariant and should usually live at a canonical construction boundary.Start each review by making a short inventory of every new helper, fallback, and special case in the diff. For each flagged change, answer:
substitute/resolve/canonicalization path?Do not keep a flagged change merely because it makes tests pass. If it remains necessary, the
Process report section of the PR description must justify why this input shape is valid and why
this layer owns the logic, with a code trace from producer to consumer.
Adding a new language feature usually involves:
source/compiler-core/slang-lexer.cpp).source/slang/slang-parser.cpp).source/slang/slang-check-*.cpp).source/slang/slang-ir-*.cpp).source/slang/slang-emit-*.cpp).tests/.Other common tasks:
source/slang/slang-ir-insts.lua, then regenerate generated
sources as required by the build.prelude/.source/slang/slang-emit-*.cpp.Reject invalid descriptor heap access.master.pr: non-breaking or pr: breaking change
label../extras/install-git-hooks.sh or request the
format bot with /format.Write PR descriptions in this five-part format:
Write for a reviewer without the full context in their head. Use the same conversational style expected in code comments: start from a concrete user-code example, include the full relevant snippet rather than just a type or function name, and explain the logical steps in order. Say what the compiler builds, how that representation flows through named functions or IR instructions, and why the chosen fix preserves the invariant. Avoid terse headings like "AST trace"; make the prose read like an explanation to a reviewer who is learning the scenario for the first time.
Autonomy: Proceed through format, test, and commit without asking for confirmation. Only stop and notify the user if tests fail and the failure is not self-fixable.