Index of every page on this site: llms.txt
All skills
comet-ml avatar

/opik-backend

@9b3d88e
by Cometcomet-ml/opik23k stars
1,964
Run it yourself

Java backend patterns for Opik. Use when working in apps/opik-backend, designing APIs, database operations, or services.

Use this Skill: https://skilld.dev/gh/comet-ml/opik/opik-backend

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

mysql.md

≈557 tokens on demand. Your agent reads this file only when SKILL.md points to it.

MySQL Transaction Patterns

Always Use TransactionTemplate

import static com.comet.opik.infrastructure.db.TransactionTemplateAsync.READ_ONLY;
import static com.comet.opik.infrastructure.db.TransactionTemplateAsync.WRITE;

@Singleton
@RequiredArgsConstructor(onConstructor_ = @Inject)
public class UserService {

    private final @NonNull TransactionTemplate transactionTemplate;

    // Read operations
    public UserResponse getUser(String id) {
        return transactionTemplate.inTransaction(READ_ONLY, handle -> {
            var repository = handle.attach(UserDao.class);
            return repository.findById(id)
                .orElseThrow(() -> new NotFoundException("User not found: '%s'".formatted(id)));
        });
    }

    // Write operations
    public UserResponse createUser(UserCreateRequest request) {
        return transactionTemplate.inTransaction(WRITE, handle -> {
            var repository = handle.attach(UserDao.class);
            var user = buildUser(request);
            return repository.create(user);
        });
    }
}

Transaction Block Best Practices

// ✅ GOOD - Only database operations inside transaction
public UserResponse createUser(UserCreateRequest request) {
    return transactionTemplate.inTransaction(WRITE, handle -> {
        var repository = handle.attach(UserDao.class);
        var user = buildUser(request);
        return repository.create(user);
    });
}

// ❌ BAD - Unrelated logic in transaction block
public UserResponse createUser(UserCreateRequest request) {
    return transactionTemplate.inTransaction(WRITE, handle -> {
        sendEmailNotification(request.getEmail());  // Don't!
        updateCache();  // Don't!

        var repository = handle.attach(UserDao.class);
        return repository.create(buildUser(request));
    });
}

DAO Interface Pattern

@RegisterRowMapper(UserRowMapper.class)
public interface UserDao {

    @SqlQuery("SELECT * FROM users WHERE id = :id")
    Optional<User> findById(@Bind("id") String id);

    @SqlUpdate("INSERT INTO users (id, name, email, created_at) VALUES (:id, :name, :email, :createdAt)")
    @GetGeneratedKeys
    User create(@BindBean User user);
}

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning6mo4 checks · Risk SAFE
  • Gen Agent Trust Hub6mo

    The skill provides comprehensive coding standards and architectural patterns for a Java backend. It explicitly promotes security best practices, such as using parameter binding to prevent SQL injection and maintaining a strict 'Never Log' policy for sensitive data like credentials and PII.

  • Socket6mo

    No alerts

  • Snyk6mo

    Risk: LOW · No issues

  • Runlayer8mo

    2/5 files flagged

Signed by skilld at 9b3d88e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 weeks ago

README badge

README badge for comet-ml/opik/opik-backend