jac-has-fields

Declares typed fields on Jac archetypes with defaults, postinit, properties, and access tags.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-has-fields-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-has-fields
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-has-fields
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-has-fields-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing stateful types in Jac requires knowing the exact has field syntax, and mistakes like ordering defaulted fields before required ones or adding dynamic attributes cause cryptic compile errors or runtime crashes. This Skill provides the authoritative rules and patterns for declaring fields on any Jac archetype. ## Core Features & Use Cases - Field Declaration Rules: Covers types, defaults, multi-field declarations, static fields, and the mandatory required-before-default ordering for obj, node, edge, and walker archetypes. - Computed Fields and Properties: Documents the postinit pattern for derived values and getter/setter property blocks with backing fields, including read-only enforcement. - Pitfall Prevention: Explains inheritance default constraints, reserved-word naming limits, access tag encapsulation (has:pub, has:protect, has:priv), and walker spawn parameter traps. - Use Case: When defining a node Account with a validated balance property and a computed interest field, load this Skill to get the correct has declarations, property accessors, and postinit implementation without hitting E2004 or E0080 errors. ## Quick Start Ask the AI to declare a Jac object with typed fields, a computed postinit field, and a validated property using the jac-has-fields conventions.

Frequently Asked Questions about jac-has-fields

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I declare typed fields on a Jac object?▼

Use the `has` keyword inside any Jac archetype: `has name: str;` for required fields and `has age: int = 0;` for defaults. All non-default fields must be declared before any defaulted field, and instances are built with kwargs since the constructor is auto-generated.

How do I create a computed field in Jac?▼

Declare the field with the `postinit` modifier, such as `has area: float postinit;`, then define `def postinit` to assign it after the auto-generated constructor runs. The field is excluded from the constructor and derived from other fields.

Why does Jac fail with non-default argument follows default argument?▼

This happens when a parent class has a defaulted field and the subclass adds a required field, violating dataclass ordering. It passes `jac check` but crashes at runtime, so give every subclass field a default value.

Can Jac fields use Python reserved words like class?▼

No, Python reserved words cannot name fields even when backtick-escaped, because the generated Python needs a real identifier and `jac check` fails with E0067. Use an alternative name like `kind` or `cls` instead.

How do getter and setter properties work in Jac?▼

A `has` declaration with an accessor block becomes a property with no storage, backed by a separate underscore-prefixed field. Omitting the setter makes it read-only, and combining a default value with an accessor block is rejected with E0080.